[go: up one dir, main page]
More Web Proxy on the site http://driver.im/

CN116318861A - Ether-mill intelligent contract return value non-testing method based on dynamic transaction information - Google Patents

Ether-mill intelligent contract return value non-testing method based on dynamic transaction information Download PDF

Info

Publication number
CN116318861A
CN116318861A CN202310107069.3A CN202310107069A CN116318861A CN 116318861 A CN116318861 A CN 116318861A CN 202310107069 A CN202310107069 A CN 202310107069A CN 116318861 A CN116318861 A CN 116318861A
Authority
CN
China
Prior art keywords
transaction
information
ethernet
operation code
data
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
CN202310107069.3A
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.)
Xidian University
Original Assignee
Xidian 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 Xidian University filed Critical Xidian University
Priority to CN202310107069.3A priority Critical patent/CN116318861A/en
Publication of CN116318861A publication Critical patent/CN116318861A/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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L63/00Network architectures or network communication protocols for network security
    • H04L63/12Applying verification of the received information

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Computer Security & Cryptography (AREA)
  • General Business, Economics & Management (AREA)
  • Theoretical Computer Science (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • Physics & Mathematics (AREA)
  • Economics (AREA)
  • General Physics & Mathematics (AREA)
  • Marketing (AREA)
  • Development Economics (AREA)
  • Computer Hardware Design (AREA)
  • Computing Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses an Ethernet intelligent contract return value non-testing method based on dynamic transaction information, which comprises the steps of executing Ethernet transaction replay operation based on a platform above 2.0 of Ethernet and recording the operation code information of the replayed transaction; extracting key logic of the operation code information, performing a transaction execution simulation process, and collecting data information after transaction simulation; extracting the needed key operation code information from the data information and converting the key operation code information into a data file which can be identified by a logical relation detector; a logical relation detector is constructed based on Datalog, and whether the replayed transaction has a return value undetected problem is detected by using the constructed logical relation detector and detection rules and data files which are preset in the logical relation detector. The invention can fully simplify the logic of the detection rule, expand the detection range and improve the detection accuracy, does not need to worry about the problem of state space explosion, and can ensure the high efficiency and accuracy of verification by adopting a dynamic verification method.

Description

Ether-mill intelligent contract return value non-testing method based on dynamic transaction information
Technical Field
The invention belongs to the technical field of intelligent contract dynamic verification, and particularly relates to an Ethernet intelligent contract return value non-testing verification method based on dynamic transaction information.
Background
At present, ethernet has been developed as a biggest blockchain development platform and is still developing rapidly, and it is an important metric we refer to ethernet as blockchain 2.0 era that we can use intelligent contracts in a variety of scenarios, such as financial derivatives, insurance, real estate, legal flows, etc. The intelligent contracts allow the decentralised application built based on the ethernet to have unlimited imagination and powerful vitality, but at the same time the security problems in the intelligent contract development process become more serious. Since many deployments of smart contracts are unverified, a significant number of smart contracts can present serious security concerns and even lead to hacking, a typical situation being return undetected.
The problem of undetected return value is mostly occurred in the smart contracts related to the transfer transaction, so there is a case that the smart contracts of undetected return value are likely to cause economic loss once they encounter transfer failure. On the ethernet decentralised platform, once economic losses occur, it is mostly irreversible. Thus, security verification of smart contracts is critical.
In smart contracts, return value undetected mainly occurs after a function call or after a smart contract call, which may result in a failure of the function or smart contract call but subsequent code still continues to execute, thereby creating an error. Since the defect of undetected return value is easily utilized by hackers, which causes economic loss, it is necessary to verify the return value of the smart contract.
Most existing intelligent contract security detection tools are static detection tools, namely, detection is carried out on intelligent contracts which are not really deployed. However, without a truly running smart contract, it is difficult for static inspection tools to achieve both efficiency and accuracy. In particular, static detection tools may present a verification state space explosion problem on the one hand, and on the other hand, it is difficult for the static detection tools to detect for inter-invocation of smart contracts. Thus, for the case where the return value existing in the smart contract is not detected, the existing static tool still has a large disadvantage.
In addition, the Ethernet platform completes the platform upgrade in 2022, 9 and 15 days, the consensus mechanism is upgraded from the original workload certification mechanism to the benefit certification mechanism, and the synchronization mechanism of the nodes is changed. These two significant changes make it difficult for existing intelligent contract dynamic detection tools to detect directly against the newly conducted ethernet transactions.
Through the analysis, aiming at the problem that the return value of the intelligent contract of the Ethernet is not detected, the main problems and defects existing in the prior art are as follows:
(1) Most of the prior art is a static detection tool, all possible execution branches in an undeployed intelligent contract need to be verified, verification state space explosion problems easily occur, and detection is difficult to be carried out on the mutual call of the intelligent contract, so that the verification efficiency and accuracy cannot be ensured at the same time;
(2) The existing dynamic verification tool cannot adapt to the changes of a consensus mechanism and a node synchronization mechanism caused by the update of the Ethernet platform, and is difficult to directly detect the latest Ethernet transaction.
The difficulty of solving the problems and the defects is as follows: part of intelligent contract logic is complex, and static analysis of intelligent contracts is easy to cause a state space explosion problem; in addition, for the call between the intelligent contracts, the specific execution condition of the called intelligent contract cannot be known without specific execution of the real deployed intelligent contract, so that the safety verification of the called intelligent contract cannot be performed; on the other hand, the common-knowledge mechanism and the node synchronization mechanism are changed due to the update of the Ethernet platform, so that a new pile-inserting module is needed to be realized to acquire the related dynamic information generated by the intelligent contract operation.
The meaning of solving the problems and the defects is as follows: because the ethernet platform has the characteristics of decentralizing, the transaction that the intelligent contract of ethernet produced once produced can't be revoked. Therefore, verification of smart contract security is necessary, especially for return value undetected problems that are very easy to exploit by hackers. In addition, in the condition that the return value is not detected, the mutual calling of the intelligent contracts is quite common, so that accurate and efficient safety verification is carried out on the intelligent contracts with the mutual calling condition of the intelligent contracts, the coverage range of the return value not detected verification can be greatly improved, and the safety of the intelligent contracts of the Ethernet is ensured.
Disclosure of Invention
In order to solve the problems in the prior art, the invention provides an Ethernet intelligent contract return value non-testing method based on dynamic transaction information. The technical problems to be solved by the invention are realized by the following technical scheme:
in a first aspect, an embodiment of the present invention provides a method for testing the return value of an intelligent contract of an ethernet based on dynamic transaction information, where the method includes:
executing the playback operation of the Ethernet transaction based on the platform above Ethernet 2.0 and recording the operation code information of the played transaction;
Extracting key logic of the operation code information, performing a transaction execution simulation process, and collecting data information after transaction simulation;
extracting the needed key operation code information from the data information and converting the key operation code information into a data file which can be identified by a logic relation detector;
a logical relationship detector is constructed based on Datalog, and whether the replayed transaction has a return value undetected problem is detected by using the constructed logical relationship detector, a detection rule preset in the logical relationship detector and the data file.
In one embodiment of the present invention, the executing the ethernet transaction replay operation based on the platform above ethernet 2.0 and recording the operation code information of the replayed transaction comprises:
and replaying the transaction which is already executed by synchronizing nodes of the Ethernet network and modifying source codes of clients of an Ethernet execution layer according to a preset mode, and storing operation code information of the replayed transaction into a data set.
In one embodiment of the invention, the manner of synchronizing the nodes of the ethernet network includes:
the execution layer adopts a complete synchronization mode for synchronization, and the consensus layer adopts an optimistic synchronization mode for synchronization.
In one embodiment of the invention, the recorded opcode information for a replayed transaction comprises:
the name of the operation code, the execution parameters of the operation code and the position identification value of the operation code.
In one embodiment of the present invention, the extracting key logic of the operation code information and performing a transaction execution simulation process, collecting data information after transaction simulation includes:
performing data dependency partitioning processing, including assigning data with dependency relationships to uniform specific parameters according to the relative positions of the opcodes in the contracts to realize the coding of the dependency relationships between the data, and assigning an opcode locating value to each opcode to distinguish the data without the dependency relationships; wherein the specific parameters comprise depth and calling times;
and executing transaction execution simulation processing based on stack operation simulating the EVM of the Ethernet virtual machine according to the data dependence division processing result, and collecting data information after transaction simulation.
In one embodiment of the present invention, the extracting the required key operation code information from the data information and converting it into a data file that can be identified by the logical relationship detector includes:
Respectively extracting information of all key operation codes in the replay transaction from the data information according to different information types to obtain information of various key operation codes; wherein the key operation codes comprise call, callcode, delegatecall and jumpi;
and storing the key operation code information of various types into the data file in a classified manner.
In one embodiment of the present invention, the detecting whether the replayed transaction has a return value undetected problem using the constructed logical relationship detector and the detection rules pre-formulated therein and the data file includes:
according to the requirement of the use record of the parameters in the detection rule, performing first screening on call, callcode and delete operation codes in the data file to obtain a first result file;
using the first result file, based on the depth and the requirement of the operation code positioning value in the detection rule, judging the matching value of call, callcode and degatecal operation codes and the jump operation code, obtaining call, callcode and degatecal operation code information representing successful matching and having a return value detection, and storing the information into a second result file;
and matching the first result file and the second result file to obtain call, callcode and delete operation codes without jumpi matching as operation codes with undetected return values, and storing information called by the operation codes into a final result file.
In a second aspect, an embodiment of the present invention provides an ethernet intelligent contract return value non-testing device based on dynamic transaction information, where the device includes:
the transaction replay recording module is used for executing the transaction replay operation of the Ethernet based on the platform above Ethernet 2.0 and recording the operation code information of the replayed transaction;
the simulated transaction execution module is used for extracting key logic of the operation code information, carrying out a transaction execution simulation process and collecting data information after transaction simulation;
the key information extraction module is used for extracting the required key operation code information from the data information and converting the key operation code information into a data file which can be identified by the logic relation detector;
the return value undetected verification module is used for constructing a logic relation detector based on Datalog and detecting whether the replayed transaction has a return value undetected problem by utilizing the constructed logic relation detector, a detection rule preset in the logic relation detector and the data file.
In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
The memory is used for storing a computer program;
and the processor is used for realizing the step of the method for testing the return value of the intelligent contract of the Ethernet based on the dynamic transaction information.
In a fourth aspect, an embodiment of the present invention provides a computer readable storage medium, where a computer program is stored, where the computer program when executed by a processor implements the steps of the method for returning an intelligent contract to an ethernet based on dynamic transaction information provided by the embodiment of the present invention to a value-off test.
The invention has the beneficial effects that:
the method for verifying the return value of the intelligent contract of the Ethernet based on the dynamic transaction information comprises the following steps: firstly, executing the operation of replaying the transaction of the Ethernet based on the platform above 2.0 of the Ethernet and recording the operation code information of the replayed transaction; secondly, extracting key logic of the operation code information, carrying out a transaction execution simulation process, and collecting data information after transaction simulation; then extracting the needed key operation code information from the data information and converting the key operation code information into a data file which can be identified by a logic relation detector; finally, a logic relation detector is built based on Datalog, and whether the replayed transaction has a return value undetected problem or not is detected by using the built logic relation detector, a detection rule preset in the logic relation detector and the data file, so that the mark of the transaction with the return value undetected can be realized.
The logic rule detector constructed based on datalog is used in the embodiment of the invention, so that the construction of the logic rule can be more free, the constructed logic rule can have pertinence, and the detection rule formulated for the problem of undetected return value is simpler, so that the logic of the detection rule can be fully simplified. The data file generated is concise, so that the data quantity required to be analyzed is reduced, and the detection speed can be improved. In addition, in the stage of extracting and analyzing the operation code information, the embodiment of the invention considers more operation codes which possibly cause the problem of undetected return values, thereby expanding the detection range and improving the detection accuracy due to the increase of the detection range.
Moreover, since the collection of the opcode information is based on replay of executed transactions, there is no concern about state space explosion. In addition, the transaction with intelligent contract interaction can also be tracked when the transaction is obtained through the replay record of the transaction, so that whether the return value undetected problem exists is verified. Before the Ethernet merging, the user does not need to run a local execution layer client, but can access the Ethernet network only by using a server similar to Inura; after merging, the user must run an execution layer client, and only if the execution layer client and the consensus layer client run together, the ethernet network can be accessed. The execution layer is responsible for processing transaction transactions and data, and the consensus layer is responsible for processing POS consensus mechanisms, so that the consensus layer is required to synchronize so as to detect the latest Ethernet transactions. Therefore, the embodiment of the invention can be applied to the return value undetected verification of the intelligent contract of the Ethernet.
Meanwhile, the embodiment of the invention belongs to the technical field of intelligent contract dynamic verification, and the verified transaction is a transaction really existing in reality, so that the dynamic verification method is applied to detect whether the truly occurring transaction has the problem of undetected return value, so that the corresponding parameters of each operation code are determined when the intelligent contract runs, and the execution condition of each branch is determined, thereby effectively ensuring the high efficiency and accuracy of intelligent contract verification.
Drawings
FIG. 1 is a flow chart of a method for testing return value of an intelligent contract of an Ethernet based on dynamic transaction information according to an embodiment of the invention;
FIG. 2 is a schematic diagram of the logic relationship detector according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an apparatus for testing return value of an intelligent contract of an Ethernet based on dynamic transaction information according to an embodiment of the invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following description of the embodiments of the present invention will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present invention, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the invention without making any inventive effort, are intended to be within the scope of the invention.
In the following, an ethernet intelligent contract return value non-testing method based on dynamic transaction information provided by the embodiment of the present invention is first described.
As shown in fig. 1, the method for verifying the return value of the intelligent contract of the ethernet based on the dynamic transaction information without testing provided by the embodiment of the present invention is actually a method for verifying the return value of the intelligent contract of the ethernet based on the dynamic transaction information without detection, and may include the following steps S1 to S4:
s1, executing the playback operation of the Ethernet transaction based on the platform above Ethernet 2.0 and recording the operation code information of the played transaction;
it will be appreciated by those skilled in the art that the ethernet has completed merging at 2022, 9 and 15, and has been upgraded to ethernet 2.0, and the consensus mechanism has changed from the original workload proof to the equity proof, and the mechanism of the synchronization node has also changed. Before merging, the user does not need to run a local execution client, but can access the Ethernet network only by using a server similar to Inura; after merging, the user must run an execution layer client, and only if the execution layer client and the consensus layer client run together, the ethernet network can be accessed. The execution layer is responsible for processing transaction transactions and data, and the consensus layer is responsible for processing POS consensus mechanisms.
Because the co-mechanism in the Ethernet 2.0 is transferred from PoW to PoS, the Ethernet 2.0 network has one beacon chain and 1024 fragment chains so as to realize capacity expansion. These different shard chains may communicate with each other and be uniformly controlled and verified by the backbone beacon chain. And the main network can be added only when the update client is more than 1.10 versions, and the full nodes are further synchronized to extract the byte codes, so that the mode of dynamically acquiring transaction information can be used all the time if the consensus mechanism of the Ethernet and the synchronous full node mode are not changed in the future, and therefore, the application range of the embodiment of the invention comprises 2.0 of the Ethernet and the later developed new platform version.
Regarding the selection of the execution layer Client and the consensus layer Client, according to the statistics of the utilization rate conditions of all clients of the Ethernet Client, the embodiment of the invention preferentially selects the combination of the execution layer Client Geth+consensus layer Client Prysm which is ranked at the front, the collocation utilization rate is the highest, and the community updating condition is more comprehensive and friendly. Specifically, the execution body of the method of the embodiment of the present invention may be an execution layer client.
In S1, the operation code information of the transaction replayed by the ethernet transaction replaying operation and the transaction replayed by the ethernet transaction replaying operation based on the platform above ethernet 2.0 is recorded, so as to provide the logic relationship of the required intelligent contract execution for the subsequent dynamic verification framework. The operation code information for executing the playback operation of the transaction based on the Ethernet of the platform above 2.0 of Ethernet and recording the played back transaction comprises the following steps:
And replaying the transaction which is already executed by synchronizing nodes of the Ethernet network and modifying source codes of clients of an Ethernet execution layer according to a preset mode, and storing operation code information generated when replaying the transaction into a data set.
In the embodiment of the invention, to acquire byte code level information during the transaction processing of the intelligent contract of the Ethernet, the executed transaction is replayed by synchronizing the nodes of the Ethernet network and modifying the source codes of the client side of the execution layer of the Ethernet so as to extract the transaction record, generate the operation code information of the transaction, and store the operation code information and related data together in a data set. Wherein, the byte code is a string of hexadecimal digital coded byte arrays formed by compiling the intelligent contract through a compiler. The parsing of the bytecode is in units of one byte, each of which represents one EVM (Ethereum Virtual Machine, ethernet virtual machine) instruction or one operation data. The EVM further converts the bytecode into an operation code that the operating system can understand when executing the bytecode. Bytecode can be understood as a bridge between intelligent contracts and EVM level, while opcodes can be understood as a bridge between EVM and operating system and hardware.
In order to obtain complete transaction operation code information, in the embodiment of the present invention, a method for synchronizing nodes of an ethernet network includes:
the execution layer adopts a complete synchronization mode for synchronization, and the consensus layer adopts an optimistic synchronization mode for synchronization. For concepts of the full sync mode and the optimistic sync mode, see related art understanding, which are not described in detail herein.
The embodiment of the invention can adopt the execution layer client Geth to modify the source code part thereof and store the replayed transaction byte code information into the data set.
For example, the source code of the latest version 1.10.25 of Geth may be selected for modification. Specifically, under the source directory, adding a configuration file of a mongoDB, and adding global variables related to transactions; in the core module, the application transfer () function and the prefatch () function in the state_processor file and the state_prefatcher file are modified: the function of the apply transaction () is to replay the transaction in the EVM, collect the generated bytecode during the execution of the function, and store the bytecode and other related information of the transaction (such as block number, gas cost, etc.) in the local molgnodb, and the function of the Prefetch () is to eliminate redundancy generated during the Prefetch, and add a boolean type parameter abundon into the function, and cancel the Prefetch if false, thereby reducing unnecessary network overhead generated by preheating the slots. Modifying the intermediate file and the instructions file under the vm module, modifying the parameters of the Run () function and the execution function corresponding to the operation code, and adding a third return value of the character string type, namely the necessary information corresponding to each operation code, in the return values so as to facilitate the analysis of the operation code parameters later; modify Stop () function of tx_pool file, add write operation of mongDB, and save the remaining transaction record in tx_pool to mongDB. Wherein, the names of the files, functions or variables related to Geth above are understood in connection with the prior art, and are not explained in detail herein. Of course, the source code modification mode for the rest versions of Geth is similar, and the source code modification mode can be adaptively adjusted.
Wherein the recorded opcode information for the replayed transaction comprises:
the name of the operation code, the execution parameters of the operation code and the position identification value of the operation code.
Wherein, the execution parameter of the operation code refers to the corresponding value of the operation code when executing, for example, an action is executed as spending 20, the operation code refers to "spending", and the execution parameter refers to "20"; the location identification value of the opcode is used to distinguish the location of all opcodes in the same transaction.
S2, extracting key logic of the operation code information, performing a transaction execution simulation process, and collecting data information after transaction simulation;
in an alternative embodiment, S2 includes the steps of:
s21, performing data dependency division processing, wherein the data dependency division processing comprises the steps of endowing data with dependency relationship with uniform specific parameters according to the relative positions of operation codes in contracts so as to realize the coding of the dependency relationship between the data, and endowing each operation code with an operation code positioning value so as to distinguish the data without the dependency relationship;
the data dependency division processing is to obtain the dependency relationship between the operation codes by using the operation code information extracted in S1.
Specific:
firstly, coding the dependence between data in the operation code information: and giving the data with the dependency relationship to uniform specific parameters according to the relative position of the operation code in the contract, wherein the specific parameters comprise depth and calling times, and the uniform specific parameters are used for determining the execution sequence of the operation code in the actual execution process and are used as detection basis in the subsequent rule detection stage. Depth refers to the execution depth of a contract call; the number of calls refers to the number of times that the contract was invoked by the transaction when the opcode was executed.
Meanwhile, in order to distinguish data without dependency, the embodiment of the invention assigns an operation code positioning value to each operation code for distinguishing the operation code from the relative position data in the contract, and because the contract has a plurality of operation codes, the relative position of the operation code in the contract as data can cause detection errors when the data among the operation codes are identical, and the operation code positioning values of each operation code are different. After the data dependency division is finished, the data with the dependency relationship have the same parameters for distinguishing operation codes in a transaction execution simulation processing link.
S22, executing transaction execution simulation processing based on stack operation of the simulation Ethernet virtual machine EVM according to the data dependency division processing result, and collecting data information after transaction simulation.
The transaction execution simulation process uses the result process from the data dependent partitioning process to obtain further opcode information. The stack operation of the EVM is simulated for the operation code information for further analysis. For part of operation codes, the execution parameters of the operation codes are known in the information collection stage, the execution parameters are collected for push processing, the execution parameters of the other part of operation codes such as jumpi, mstore and the like cannot be obtained in the information collection stage, the push operation is carried out in the simulation of the stack, and the obtained data after push is the execution parameters of the operation codes.
This step is to obtain more complete data information, and the analysis in the subsequent step requires the execution parameters of all the operation codes to be used for judging more detailed relations between the operation codes.
S3, extracting the needed key operation code information from the data information, and converting the key operation code information into a data file which can be identified by a logic relation detector;
s3, the required intelligent contract dynamic operation information is provided for the subsequent dynamic verification framework.
In an alternative embodiment, S3 may include:
s31, respectively extracting information of all key operation codes in the replay transaction from the data information according to different information types to obtain information of various key operation codes;
in this step, all key opcodes in the replay transaction are first found from the data information, where the key opcodes include call, callcode, delegatecall and jumpi, and so on. Then, in order to make the extracted information available for detection by the logical relation detector, different types of information of the operation codes are extracted respectively, and the different information types include basic information such as depth and calling times and other operation code information related to the operation codes in calling.
It should be emphasized that the operation codes such as call in the embodiments of the present invention refer to the related art for understanding the meaning, and are not described herein.
S32, storing the information of the key operation codes of various types into the data file in a classified mode.
It should be noted that, the logical relationship detector constructed based on Datalog cannot directly detect the operation code information, and the data of the same category in the logical relationship needs to be extracted to generate a data file. The opcodes required for the return value undetected problem include call, callcode, delegatecall and jumpi, in addition to the parameters involved in the execution of each operation, the opcode location value, depth, and number of calls at execution, which are sorted into data files for subsequent logical detection.
S4, constructing a logic relation detector based on Datalog, and detecting whether the replayed transaction has a return value undetected problem by using the constructed logic relation detector, a detection rule preset in the logic relation detector and the data file.
S4, a detection rule is formulated in advance based on Datalog, a logic relation detector is constructed based on Datalog, the data file given in S3 is detected, and an operation code containing a return value which is not detected is recorded in a final result file.
The logical relation detector constructed based on Datalog comprises an open-source Datalog engine and detection rules formulated for return value undetected problems. The open source Datalog engine includes an interpreter and a compiler to execute the Datalog program, and the detection rules are Datalog programs written according to the collected information and the functions that need to be completed. The logic relation detector detects the extracted key operation code information according to the formulated detection rule, judges whether the transaction has a return value undetected problem, and records the operation code information into a final result file if the transaction has the return value undetected problem.
In the embodiment of the invention, the fact that the return value is not detected means that a transaction uses call, callcode or delete operation code when being executed, and the return value is not judged after the use is finished, that is, the corresponding jumpi operation of call, callcode or delete operation code does not exist. For a transaction that has this phenomenon, it is considered that there is a return value undetected problem.
Detecting a transaction in which such a phenomenon exists requires making a detection rule in advance, which determines the detection order and detection result of the data file. In an alternative embodiment, the detecting whether the replayed transaction has a return value undetected problem by using the constructed logical relation detector and the detection rule preset therein and the data file includes:
S41, performing first screening on call, callcode and delete operation codes in the data file according to the use record requirement of the parameters in the detection rule to obtain a first result file;
specifically, the detection rule performs condition screening on call, callcode and delete operation codes during preparation, and needs to determine whether the operation code may have a return value detection operation code matched with the operation code according to other operation code information related to the operation code, so that call, callcode and delete operation codes meeting the condition can perform matching detection with jumpi.
S41, performing a first step of detecting a data file of the extracted call operation code execution related information, wherein the step of detecting is to screen call, callcode and degatectoal calls which meet the rule, and the condition of screening is that a certain parameter related to the use of call, callcode and degatectoal calls needs to be recorded in another data file used for recording the used operation code, and the information screened in the step is stored in a first result file, wherein the first result file can be named as s_first.
S42, using the first result file, based on the depth and the requirement of the operation code positioning value in the detection rule, performing matching value judgment on call, callcode and degatetech operation codes and jump operation codes, and obtaining call, callcode and degatetech operation code information representing successful matching and having a return value detection, and storing the information into a second result file;
In this step, call, callcode and degatetech opcodes and jumpi will also be screened, specifically, using the first result file, each call, callcode and degatetech call is matched with jumpi opcode, because the matching operation is time-consuming, in order to save detection time, it needs to determine whether the depth of two opcodes is consistent before the matching operation is performed, and the matching judgment can be performed by using the opcode with consistent depth, that is, the matched opcode must have the same depth parameter, and the number of opcode location values of the opcode performing the call must be greater than the opcode location value performing the return value detection operation, and the final matching will be performed after these screening.
S42 the successfully matched opcode information is stored in a second result file, which may be named s_second.
S43, matching the first result file and the second result file to obtain call, callcode and delete operation codes without jumpi matching as operation codes with undetected return values, and storing information called by the operation codes into a final result file.
Matching the two result files obtained in S41 and S42 can obtain call, callcode and delete call information without jumpi matching, and store the information into a final result file, wherein the final result file can be named result.
Specifically, the call, callcode and degatectol opcodes in S43 will match the eligible jumpi opcodes, and if call, callcode or degatectol cannot match any jumpi opcode, then the call, callcode or degatectol opcode will be recorded, indicating that the transaction has a return value undetected problem.
The execution logic for the logical relationship detector to detect the return value is understood with reference to fig. 2. In fig. 2, the initial data file is the data file provided in S3. The call, callcode, delegatecall operation code capable of detecting the return value is obtained through the step S41, then the matching value judgment is carried out through the step S42 and the jump operation code, all call, callcode, delegatecall operation codes with the return value detection are obtained, finally the result files obtained through the step S41 and the step S42 are matched, call, callcode, delegatecall operation codes with the return value undetected are obtained, and specific processes are described in the above description. In the stage of generating the data file for the detection of the logic relation detector, the embodiment of the invention screens the generated data file so that the generated data file is more concise, thereby fully simplifying the logic of the detection rule.
The method for verifying the return value of the intelligent contract of the Ethernet based on the dynamic transaction information comprises the following steps: firstly, executing the operation of replaying the transaction of the Ethernet based on the platform above 2.0 of the Ethernet and recording the operation code information of the replayed transaction; secondly, extracting key logic of the operation code information, carrying out a transaction execution simulation process, and collecting data information after transaction simulation; then extracting the needed key operation code information from the data information and converting the key operation code information into a data file which can be identified by a logic relation detector; finally, a logic relation detector is built based on Datalog, and whether the replayed transaction has a return value undetected problem or not is detected by using the built logic relation detector, a detection rule preset in the logic relation detector and the data file, so that the mark of the transaction with the return value undetected can be realized.
The logic rule detector constructed based on datalog is used in the embodiment of the invention, so that the construction of the logic rule can be more free, the constructed logic rule can have pertinence, and the detection rule formulated for the problem of undetected return value is simpler, so that the logic of the detection rule can be fully simplified. The data file generated is concise, so that the data quantity required to be analyzed is reduced, and the detection speed can be improved. In addition, in the stage of extracting and analyzing the operation code information, the embodiment of the invention considers more operation codes which possibly cause the problem of undetected return values, thereby expanding the detection range and improving the detection accuracy due to the increase of the detection range.
Moreover, since the collection of the opcode information is based on replay of executed transactions, there is no concern about state space explosion. In addition, the transaction with intelligent contract interaction can also be tracked when the transaction is obtained through the replay record of the transaction, so that whether the return value undetected problem exists is verified. Before the Ethernet merging, the user does not need to run a local execution layer client, but can access the Ethernet network only by using a server similar to Inura; after merging, the user must run an execution layer client, and only if the execution layer client and the consensus layer client run together, the ethernet network can be accessed. The execution layer is responsible for processing transaction transactions and data, and the consensus layer is responsible for processing POS consensus mechanisms, so that the consensus layer is required to synchronize so as to detect the latest Ethernet transactions. Therefore, the embodiment of the invention can be applied to the return value undetected verification of the intelligent contract of the Ethernet.
The static detection tools employed in the prior art do not know the specific orientation of each branch. Since the effective transactions in the ethernet are recorded in the blocks, and the embodiment of the invention further analyzes the loopholes by recording the specific byte codes generated by the transactions recorded in the execution blocks of the EVM virtual machine in the process of synchronizing the full nodes, the byte codes can be extracted for subsequent analysis as long as the transactions are recorded in the chain, and therefore the embodiment of the invention belongs to the technical field of intelligent contract dynamic verification. The dynamic detection tool adopted by the embodiment of the invention is based on the fact that the transaction exists in reality during detection, so that the specific trend of each branch is determined, and the problem of statement explosion does not occur. And the information of the byte code level collected by the dynamic detection tool is not careful about which contract the information comes from, so that the information can be normally collected for the call between contracts. The verification transaction is a transaction which does exist in reality, so that the dynamic verification method is applied to detect whether the transaction which actually occurs has the problem of undetected return value, the corresponding parameter of each operation code in the intelligent contract operation process is determined, and the execution condition of each branch is determined, thereby effectively ensuring the high efficiency and accuracy of intelligent contract verification.
In a second aspect, corresponding to the above method embodiment, the embodiment of the present invention further provides an ethernet intelligent contract return value non-testing device based on dynamic transaction information, as shown in fig. 3, where the device includes:
a transaction replay recording module 301, configured to perform an ethernet transaction replay operation based on the ethernet platform 2.0 or more and record operation code information of the replayed transaction;
the simulated transaction execution module 302 is configured to extract key logic of the operation code information and perform a transaction execution simulation process, and collect data information after transaction simulation;
a key information extraction module 303, configured to extract the required key operation code information from the data information, and convert the key operation code information into a data file that can be identified by the logical relationship detector;
the return value undetected verification module 304 is configured to construct a logical relationship detector based on Datalog, and detect whether a replay transaction has a return value undetected problem using the constructed logical relationship detector and a detection rule preset therein and the data file.
Further, the transaction replay recording module 301 is specifically configured to:
and replaying the transaction which is already executed by synchronizing nodes of the Ethernet network and modifying source codes of clients of an Ethernet execution layer according to a preset mode, and storing operation code information of the replayed transaction into a data set.
Further, the method for synchronizing the nodes of the ethernet network includes:
the execution layer adopts a complete synchronization mode for synchronization, and the consensus layer adopts an optimistic synchronization mode for synchronization.
Further, the recorded opcode information for the replayed transaction comprises:
the name of the operation code, the execution parameters of the operation code and the position identification value of the operation code.
Further, the simulation transaction execution module 302 is specifically configured to:
performing data dependency partitioning processing, including assigning data with dependency relationships to uniform specific parameters according to the relative positions of the opcodes in the contracts to realize the coding of the dependency relationships between the data, and assigning an opcode locating value to each opcode to distinguish the data without the dependency relationships; wherein the specific parameters comprise depth and calling times;
and executing transaction execution simulation processing based on stack operation simulating the EVM of the Ethernet virtual machine according to the data dependence division processing result, and collecting data information after transaction simulation.
Further, the key information extraction module 303 is specifically configured to:
respectively extracting information of all key operation codes in the replay transaction from the data information according to different information types to obtain information of various key operation codes; wherein the key operation codes comprise call, callcode, delegatecall and jumpi;
And storing the key operation code information of various types into the data file in a classified manner.
Further, the return-value-undetected verification module 304 is specifically configured to, in a process of detecting whether a replay transaction has a return-value-undetected problem using the constructed logical relationship detector and the detection rules predefined therein and the data file:
according to the requirement of the use record of the parameters in the detection rule, performing first screening on call, callcode and delete operation codes in the data file to obtain a first result file;
using the first result file, based on the depth and the requirement of the operation code positioning value in the detection rule, judging the matching value of call, callcode and degatecal operation codes and the jump operation code, obtaining call, callcode and degatecal operation code information representing successful matching and having a return value detection, and storing the information into a second result file;
and matching the first result file and the second result file to obtain call, callcode and delete operation codes without jumpi matching as operation codes with undetected return values, and storing information called by the operation codes into a final result file.
Please refer to the related matters of the first aspect, and detailed descriptions thereof are omitted herein.
In a third aspect, an embodiment of the present invention further provides an electronic device, as shown in fig. 4, including a processor 401, a communication interface 402, a memory 403, and a communication bus 404, where the processor 401, the communication interface 402, and the memory 403 complete communication with each other through the communication bus 404;
the memory is used for storing a computer program;
the processor is configured to implement the step of any method for testing whether the return value of the ethernet intelligent contract based on the dynamic transaction information is not tested according to the first aspect of the present invention when executing the program stored in the memory.
The communication bus mentioned above for the electronic devices may be a peripheral component interconnect standard (Peripheral Component Interconnect, PCI) bus or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, etc. The communication bus may be classified as an address bus, a data bus, a control bus, or the like. For ease of illustration, the figures are shown with only one bold line, but not with only one bus or one type of bus.
The communication interface is used for communication between the electronic device and other devices.
The Memory may include random access Memory (Random Access Memory, RAM) or may include Non-Volatile Memory (NVM), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the aforementioned processor.
The processor may be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; but also digital signal processors (Digital Signal Processing, DSP), application specific integrated circuits (Application Specific Integrated Circuit, ASIC), field programmable gate arrays (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
The method provided by the embodiment of the invention can be applied to electronic equipment. Specifically, the electronic device may be: desktop computers, portable computers, intelligent mobile terminals, servers, etc. Any electronic device capable of implementing the present invention is not limited herein, and falls within the scope of the present invention.
According to a fourth aspect, corresponding to the method for testing the return value of the ethernet intelligent contract based on the dynamic transaction information provided in the first aspect, an embodiment of the present invention further provides a computer readable storage medium, where a computer program is stored, and when the computer program is executed by a processor, the steps of any one of the methods for testing the return value of the ethernet intelligent contract based on the dynamic transaction information provided in the first aspect of the present invention are implemented.
For the apparatus/electronic device/storage medium embodiments, the description is relatively simple as it is substantially similar to the method embodiments, as relevant see the section description of the method embodiments.
It should be noted that, the device, the electronic device and the storage medium according to the embodiments of the present invention are the device, the electronic device and the storage medium applying the method for testing the return value of the ethernet intelligent contract based on the dynamic transaction information, respectively, so that all the embodiments of the method for testing the return value of the ethernet intelligent contract based on the dynamic transaction information are applicable to the device, the electronic device and the storage medium, and the same or similar beneficial effects can be achieved.
Furthermore, the terms "first," "second," and the like, are used for descriptive purposes only and are not to be construed as indicating or implying a relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defining "a first" or "a second" may explicitly or implicitly include one or more such feature. In the description of the present invention, the meaning of "a plurality" is two or more, unless explicitly defined otherwise.
The foregoing description is only of the preferred embodiments of the present invention and is not intended to limit the scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims (10)

1. An ethernet intelligent contract return value non-testing method based on dynamic transaction information is characterized by comprising the following steps:
executing the playback operation of the Ethernet transaction based on the platform above Ethernet 2.0 and recording the operation code information of the played transaction;
extracting key logic of the operation code information, performing a transaction execution simulation process, and collecting data information after transaction simulation;
extracting the needed key operation code information from the data information and converting the key operation code information into a data file which can be identified by a logic relation detector;
a logical relationship detector is constructed based on Datalog, and whether the replayed transaction has a return value undetected problem is detected by using the constructed logical relationship detector, a detection rule preset in the logical relationship detector and the data file.
2. The method for testing the return value of an ethernet intelligent contract based on dynamic transaction information according to claim 1, wherein said executing the ethernet transaction replay operation based on the ethernet platform of 2.0 or more and recording the operation code information of the replayed transaction comprises:
and replaying the transaction which is already executed by synchronizing nodes of the Ethernet network and modifying source codes of clients of an Ethernet execution layer according to a preset mode, and storing operation code information of the replayed transaction into a data set.
3. The method for testing the return value of an ethernet intelligent contract based on dynamic transaction information according to claim 2, wherein the means for synchronizing the nodes of the ethernet network comprises:
the execution layer adopts a complete synchronization mode for synchronization, and the consensus layer adopts an optimistic synchronization mode for synchronization.
4. The dynamic transaction information based ethernet intelligent contract return value non-test method according to claim 1, wherein the recorded opcode information for the replayed transaction comprises:
the name of the operation code, the execution parameters of the operation code and the position identification value of the operation code.
5. The method for testing the return value of the intelligent ethernet contract based on the dynamic transaction information according to any one of claims 1 to 4, wherein the steps of extracting key logic of the operation code information and performing a transaction execution simulation process, collecting data information after the transaction simulation, include:
performing data dependency partitioning processing, including assigning data with dependency relationships to uniform specific parameters according to the relative positions of the opcodes in the contracts to realize the coding of the dependency relationships between the data, and assigning an opcode locating value to each opcode to distinguish the data without the dependency relationships; wherein the specific parameters comprise depth and calling times;
And executing transaction execution simulation processing based on stack operation simulating the EVM of the Ethernet virtual machine according to the data dependence division processing result, and collecting data information after transaction simulation.
6. The method for testing the return value of an intelligent ethernet contract based on dynamic transaction information according to claim 5, wherein said extracting the required key operation code information from said data information and converting it into a data file recognizable by a logical relationship detector comprises:
respectively extracting information of all key operation codes in the replay transaction from the data information according to different information types to obtain information of various key operation codes; wherein the key operation codes comprise call, callcode, delegatecall and jumpi;
and storing the key operation code information of various types into the data file in a classified manner.
7. The method for testing return value of intelligent ethernet contract based on dynamic transaction information according to claim 6, wherein said detecting whether a replayed transaction has a return value non-detection problem using a constructed logical relationship detector and a detection rule pre-formulated therein and said data file, comprises:
According to the requirement of the use record of the parameters in the detection rule, performing first screening on call, callcode and delete operation codes in the data file to obtain a first result file;
using the first result file, based on the depth and the requirement of the operation code positioning value in the detection rule, judging the matching value of call, callcode and degatecal operation codes and the jump operation code, obtaining call, callcode and degatecal operation code information representing successful matching and having a return value detection, and storing the information into a second result file;
and matching the first result file and the second result file to obtain call, callcode and delete operation codes without jumpi matching as operation codes with undetected return values, and storing information called by the operation codes into a final result file.
8. An ethernet intelligent contract return value non-checking verification device based on dynamic transaction information, which is characterized by comprising:
the transaction replay recording module is used for executing the transaction replay operation of the Ethernet based on the platform above Ethernet 2.0 and recording the operation code information of the replayed transaction;
the simulated transaction execution module is used for extracting key logic of the operation code information, carrying out a transaction execution simulation process and collecting data information after transaction simulation;
The key information extraction module is used for extracting the required key operation code information from the data information and converting the key operation code information into a data file which can be identified by the logic relation detector;
the return value undetected verification module is used for constructing a logic relation detector based on Datalog and detecting whether the replayed transaction has a return value undetected problem by utilizing the constructed logic relation detector, a detection rule preset in the logic relation detector and the data file.
9. An electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory are in communication with each other through the communication bus;
the memory is used for storing a computer program;
the processor is configured to implement the method steps of any of claims 1-7 when executing a program stored on the memory.
10. A computer-readable storage medium comprising,
the computer readable storage medium has stored therein a computer program which, when executed by a processor, carries out the method steps of any of claims 1-7.
CN202310107069.3A 2023-02-13 2023-02-13 Ether-mill intelligent contract return value non-testing method based on dynamic transaction information Pending CN116318861A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310107069.3A CN116318861A (en) 2023-02-13 2023-02-13 Ether-mill intelligent contract return value non-testing method based on dynamic transaction information

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310107069.3A CN116318861A (en) 2023-02-13 2023-02-13 Ether-mill intelligent contract return value non-testing method based on dynamic transaction information

Publications (1)

Publication Number Publication Date
CN116318861A true CN116318861A (en) 2023-06-23

Family

ID=86831535

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310107069.3A Pending CN116318861A (en) 2023-02-13 2023-02-13 Ether-mill intelligent contract return value non-testing method based on dynamic transaction information

Country Status (1)

Country Link
CN (1) CN116318861A (en)

Similar Documents

Publication Publication Date Title
CN106940695B (en) Data source information verification method and device
US10049031B2 (en) Correlation of violating change sets in regression testing of computer software
WO2016026328A1 (en) Information processing method and device and computer storage medium
US20170153969A1 (en) System and method for executing integration tests in multiuser environment
CN109871312B (en) Interface testing method, device, equipment and readable storage medium
Cao et al. Symcrash: Selective recording for reproducing crashes
CN111767226A (en) Method, system and equipment for testing cloud computing platform resources
CN114969760A (en) Vulnerability detection method and device, computer readable medium and electronic equipment
CN111428233A (en) Security analysis method for embedded equipment firmware
Espada et al. Performance Analysis of Spotify® for Android with Model‐Based Testing
CN112241370B (en) API interface class checking method, system and device
CN111919214A (en) Automatic generation of patches for security violations
CN113632067A (en) Emulating non-trace code with recorded execution of trace code
US11249880B1 (en) Debugging and simulating application runtime execution
US8997048B1 (en) Method and apparatus for profiling a virtual machine
CN111651346B (en) Method and device for testing front-end component, storage medium and computer equipment
CN116861433A (en) No GIL parallel-based intelligent Ethernet contract transaction defect detection method and device
US20230141948A1 (en) Analysis and Testing of Embedded Code
CN115422865B (en) Simulation method and device, computing equipment and computer readable storage medium
CN116318861A (en) Ether-mill intelligent contract return value non-testing method based on dynamic transaction information
CN116069650A (en) Method and device for generating test cases
CN110795338B (en) Front-end and back-end interaction-based automatic testing method and device and electronic equipment
CN114676436A (en) Android application multimedia analysis library vulnerability mining system and method based on structural variation
CN116775202A (en) Fuzzy test method, device, medium, electronic equipment and computer program product
CN113342632A (en) Simulation data automatic processing method and device, electronic 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