An intelligent contract execution engine, an intelligent contract execution method and related devices

The PHP-based smart contract execution engine addresses performance limitations of existing engines by leveraging optimized PHP operations and register-based access, enhancing execution efficiency and database compatibility in blockchain applications.

CN114723446BActive Publication Date: 2025-07-15SUN YAT SEN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210265825.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-17
Publication Date
2025-07-15
Estimated Expiration
2042-03-17

AI Technical Summary

Technical Problem

When existing Ethereum virtual machines (EVMs) are used as smart contract execution engines, their performance is not fully optimized, resulting in low execution efficiency.

Method used

The PHP interpreter is used as the smart contract execution engine, and through the interface call unit, the contract reading unit, the interpretation execution unit and the data management unit, the pre-encapsulated PHP constraint class performs database operation and environmental information management of the world state, and variable reading and writing are carried out in registers.

Benefits of technology

It improves the execution efficiency of smart contracts, improves the performance of blockchain business scenarios, and supports high-frequency operations.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114723446B_ABST
    Figure CN114723446B_ABST
Patent Text Reader

Abstract

The present application discloses an intelligent contract execution engine, an intelligent contract execution method, and related devices. The execution engine includes: an interface call unit for calling a specified intelligent contract according to interface parameters; a contract reading unit for obtaining target contract content; an interpretation execution unit for detecting the target contract content, interpreting the target contract content that passes the detection as machine code, and executing the machine code; and a data management unit for performing database operations on the world state to be persisted through a pre-encapsulated PHP constraint class and operating on the environment information during runtime. Since the PHP interpreter is an execution engine widely supported and optimized by the community and has relatively stable execution capabilities; at the same time, since the PHP execution process reads and writes variables based on the register method, it can maintain higher execution performance compared to the Ethereum virtual machine that reads and writes variables based on the stack, and better supports high-frequency blockchain business scenarios.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and more specifically, to an intelligent contract execution engine, an intelligent contract execution method, and related devices. Background Art

[0002] Blockchain is a chain data structure that connects data blocks in sequence according to the principle of head-to-tail connection in chronological order, and is a distributed ledger technology combined with multiple network technologies. Essentially, blockchain is a decentralized database. Simply put, the database can be regarded as a ledger, and everyone can participate in bookkeeping. A person's bookkeeping behavior will be sent to everyone in the system for backup, so that everyone in the system has a complete ledger. When a bookkeeping behavior occurs, all ledgers are updated through a peer-to-peer network. Based on the consensus mechanism and timestamp technology, the accuracy and immutability of the ledger information are ensured, and asymmetric encryption and digital signatures ensure the security of the ledger content and that the bookkeeping behavior is authorized and verifiable; these technologies guarantee the real-time, immutable, and transparent nature of information.

[0003] An intelligent contract refers to a computer program that can automatically execute the terms of a contract. Its concept was proposed by Nick Szabo in 1996 and has characteristics such as event-driven, value transfer, and automatic execution. Taking a common vending machine as an example, it can be regarded as an intelligent contract with the following characteristics: (1) Event-driven: The contract takes actions such as coin insertion as input to trigger the execution of its actions; (2) Value transfer: The external input is money, and the contract outputs goods such as beverages and food, completing the exchange or transfer of value; (3) Automatic execution: This performance of fulfilling the contract is completely automatic and does not require human intervention (except for the coin insertion action).

[0004] Generally speaking, developers will use high-level languages such as Solidity or Vyper to write the code of intelligent contracts, then compile it into machine code instructions that can be recognized by the Ethereum Virtual Machine (EVM), and finally it can be executed on the Ethereum platform using the EVM. Existing blockchains (such as Ethereum, Tron, FISCO-BCOS, etc.) generally use the Ethereum Virtual Machine (EVM) as the intelligent contract execution engine. The Ethereum Virtual Machine is an environment introduced by Ethereum for the execution of its own blockchain contracts. The Solidity language and the EVM were initially developed by Ethereum's founder Vitalik Buterin, and the design principle is simplicity and security, without considering performance issues; at the same time, the EVM started relatively late and has received few improvements, resulting in its performance not being optimized to the maximum extent. Summary of the Invention

[0005] In view of this, the present application provides an intelligent contract execution engine, an intelligent contract execution method and related devices to improve the execution efficiency of intelligent contracts.

[0006] To achieve the above object, the first aspect of the present application provides an intelligent contract execution engine, including:

[0007] An interface call unit for calling a specified intelligent contract according to interface parameters;

[0008] A contract reading unit for obtaining target contract content according to the intelligent contract called by the interface call unit;

[0009] An interpretation and execution unit for detecting the target contract content, interpreting the detected target contract content as machine code, and executing the machine code;

[0010] A data management unit for performing database operations on the world state to be persisted through a pre-packaged PHP constraint class during the execution of the machine code, and operating on the runtime environment information through a pre-packaged PHP constraint class.

[0011] Preferably, the process of the data storage unit performing database operations on the world state to be persisted through a pre-packaged PHP constraint class includes:

[0012] Performing state addition, state deletion, state modification and state query operations on the database through a pre-packaged PHP constraint class.

[0013] Preferably, the process of the interpretation and execution unit detecting the target contract content includes:

[0014] Detecting whether the target contract content contains a preset disabled function in the form of a regular expression.

[0015] Preferably, the interface parameters include the address of the target contract, the target contract function, and the parameters of the target contract function;

[0016] The process of the interface call unit calling a specified intelligent contract according to the interface parameters includes:

[0017] Calling the intelligent contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

[0018] Preferably, the process of the contract reading unit obtaining the target contract content according to the intelligent contract called by the interface call unit includes:

[0019] Obtaining the target contract address according to the intelligent contract called by the interface call unit;

[0020] Obtain the target contract content from a preset blockchain status table according to the target contract address, where the blockchain status table contains the mapping relationship between the target contract content and the target contract address.

[0021] The second aspect of this application provides a method for executing a smart contract, including:

[0022] Invoke a specified smart contract according to the interface parameters;

[0023] Obtain the target contract content according to the invoked smart contract;

[0024] Detect the target contract content, interpret the target contract content that passes the detection as machine code, and execute the machine code;

[0025] During the execution of the machine code, perform database operations on the world state that needs to be persisted through a pre-encapsulated PHP constraint class, and perform operations on the runtime environment information through a pre-encapsulated PHP constraint class.

[0026] Preferably, the process of performing database operations on the world state that needs to be persisted through a pre-encapsulated PHP constraint class includes:

[0027] Perform operations such as state addition, state deletion, state modification, and state query on the database through a pre-encapsulated PHP constraint class;

[0028] Preferably, the process of detecting the target contract content includes:

[0029] Detect whether the target contract content contains preset disabled functions in the form of regular expressions.

[0030] Preferably, the interface parameters include the address of the target contract, the target contract function, and the parameters of the target contract function;

[0031] Preferably, the process of invoking a specified smart contract according to the interface parameters includes:

[0032] Invoke the smart contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

[0033] The third aspect of this application provides a smart contract execution device, including: a memory and a processor;

[0034] The memory is used to store programs;

[0035] The processor is used to execute the program to implement each step of the smart contract execution method as described above.

[0036] A third aspect of the present application provides a storage medium with a computer program stored thereon. When the computer program is executed by a processor, each step of the intelligent contract execution method as described above is implemented.

[0037] As can be seen from the above technical solutions, the intelligent contract execution engine of the present application includes an interface call unit for calling a specified intelligent contract according to interface parameters, a contract reading unit for obtaining target contract content according to the intelligent contract called by the interface call unit, an interpretation execution unit for detecting the target contract content, interpreting the detected target contract content as machine code, and executing the machine code, and a data management unit for performing database operations on the world state to be persisted through a pre-packaged PHP constraint class during the execution of the machine code, and operating on the runtime environment information through the pre-packaged PHP constraint class. Among them, for the world state to be persisted, it is managed by a database, and the database is operated by a pre-packaged PHP constraint class. Since the PHP interpreter is an execution engine widely supported and optimized by the community and has relatively stable execution capabilities; at the same time, since the PHP execution process reads and writes variables based on the register method, compared with the Ethereum virtual machine that reads and writes variables based on the stack, it can maintain higher execution performance and better support high-frequency blockchain business scenarios. BRIEF DESCRIPTION OF THE DRAWINGS

[0038] In order to more clearly illustrate the technical solutions in the embodiments of the present application or in the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only the embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on the provided drawings.

[0039] Figure 1 Schematic diagram of the intelligent contract execution engine disclosed in the embodiments of the present application;

[0040] Figure 2 Schematic diagram exemplifying the intelligent contract development and deployment process based on the PHP constraint class disclosed in the embodiments of the present application;

[0041] Figure 3 Schematic diagram of the intelligent contract execution method disclosed in the embodiments of the present application;

[0042] Figure 4 Schematic diagram exemplifying the intelligent contract execution process diagram based on the PHP script executor disclosed in the embodiments of the present application;

[0043] Figure 5 Schematic diagram of the intelligent contract execution device disclosed in the embodiments of the present application. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0044] Next, in combination with the accompanying drawings in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0045] The inventors of the present application have noticed that since EVM is a stack-based virtual machine, on the one hand, translating contract execution instructions into machine instructions (i.e., operating system instructions and CPU instructions) consumes the translation time of the virtual machine; on the other hand, the reading and writing of elements are completed through operations on the stack, and the reading and writing efficiency of the stack is much lower than that of registers; furthermore, for a blockchain that adopts a Merkle world state tree, reading a key-value pair once needs to be manifested as multiple read and write jumps to the state in the hard disk, resulting in low execution performance.

[0046] PHP (Hypertext Preprocessor) is an open-source general-purpose computer scripting language, especially suitable for web development and can be embedded in HTML for use. The syntax of PHP draws on the characteristics of popular computer languages such as C language, Java, and Perl, and is easy for general programmers to learn. Based on the above advantages of PHP, the present application proposes to apply PHP to the smart contract engine, which not only improves the execution efficiency but also facilitates programmers to develop products using a general programming language.

[0047] Next, the smart contract execution engine provided by the embodiments of the present application will be introduced. Please refer to Figure 1 , the smart contract execution engine provided by the embodiments of the present application may include an interface call unit 21, a contract reading unit 22, an interpretive execution unit 23, and a data management unit 24.

[0048] Specifically, the interface call unit 21 is used to call a specified smart contract according to interface parameters. The interface parameters may include the address of the target smart contract, the function to be called, and the parameters of the function.

[0049] The contract reading unit 22 is used to obtain the target contract content according to the smart contract called by the interface call unit. For example, the target contract content can be obtained through a hash map.

[0050] The interpretive execution unit 23 is used to detect the target contract content, interpret the target contract content that passes the detection into machine code, and execute the machine code.

[0051] To avoid illegal operations, such as any user-defined persistence and system operations, compliance detection must be performed on the smart contract before execution. For example, by specifying multiple specific disabling conditions, the content of the target contract is screened. After the detection passes, the content of the target contract is then interpreted and executed. For example, the machine code can be executed through the system function eval() combined with specific parameters.

[0052] The data management unit 24 is used to perform database operations on the world state that needs to be persisted through a pre-encapsulated PHP constraint class during the execution of the machine code, and to operate on the runtime environment information through a pre-encapsulated PHP constraint class.

[0053] Among them, the PHP constraint class is a set of classes for reading and writing between PHP and the underlying blockchain world state. Its library functions encapsulate the operations of adding, deleting, querying, and modifying the underlying world state by the smart contract, and can be docked with a variety of popular underlying databases (such as MySQL, MongoDB, etc.), and the connected database is specifically determined according to business needs. During the process of calling the PHP constraint class, only the configuration method needs to be changed to change the database, without modifying the upper-layer contract code.

[0054] The process of operating on the runtime environment information includes a reading interface for block header information (such as packager, timestamp, etc.) and a reading interface for contract-related storage.

[0055] Existing smart contract storage generally can only adopt a non-relational key-value storage method, while the PHP constraint class can be relatively easily docked with existing production system databases, including relational databases and non-relational databases, with high technical ease of use.

[0056] The process of calling a smart contract is actually a process of initiating a transaction in the blockchain. Specifically, this process can include: sending a blockchain transaction with the target address set to null and the data field of the transaction set to the content of the target contract to any node of the blockchain. The content of the target contract is obtained through the interface call unit 21 and the contract reading unit 22. Then, the content of the target contract is detected by the interpretation and execution unit 23, and then the content of the target contract that passes the detection is interpreted and executed. The data persistence operations involved during the execution are processed through the pre-encapsulated PHP constraint class in the data management unit 24.

[0057] As can be seen from the above technical solution, the smart contract execution engine of the embodiment of the present application includes an interface call unit for calling a specified smart contract according to interface parameters, a contract reading unit for obtaining target contract content according to the smart contract called by the interface call unit, an interpretation execution unit for detecting the target contract content, interpreting the detected target contract content as machine code, and executing the machine code, and a data management unit for performing database operations on the world state to be persisted through a pre-encapsulated PHP constraint class during the execution of the machine code, and operating on the runtime environment information through a pre-encapsulated PHP constraint class. Among them, for the world state to be persisted, it is managed by a database, and the database is operated by a pre-encapsulated PHP constraint class. Since the PHP interpreter is an execution engine widely supported and optimized by the community, it has relatively stable execution capabilities; at the same time, since the PHP execution process reads and writes variables based on the register method, compared with the Ethereum virtual machine that reads and writes variables based on the stack, it can maintain higher execution performance and better support high-frequency blockchain business scenarios.

[0058] In some embodiments of the present application, the interface parameters in the interface call unit 21 include the address of the target contract, the target contract function, and the parameters of the target contract function.

[0059] The process by which the interface call unit 21 calls a specified smart contract according to the interface parameters may include:

[0060] Call the smart contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

[0061] In some embodiments of the present application, the process by which the contract reading unit 22 obtains the target contract content according to the smart contract called by the interface call unit 21 may include:

[0062] S1. Obtain the target contract address according to the smart contract called by the interface call unit 21.

[0063] S2. Obtain the target contract content from a preset blockchain state table according to the target contract address. Wherein, the blockchain state table contains the mapping relationship between the target contract content and the target contract address.

[0064] In some embodiments of the present application, the process by which the interpretation execution unit 23 detects the target contract content may include:

[0065] Detect whether the target contract content contains a preset prohibited function in the form of a regular expression.

[0066] Specifically, by writing regular expressions and formulating multiple specific disabling conditions, functions in PHP (such as "file_put_content", etc.) are screened. If a specified PHP function exists, it is considered that the detection fails. For a smart contract that fails the detection, the disabled function can be deleted. For a smart contract after all illegal functions have been deleted, it is considered that the detection passes; or, the smart contract is not processed, and the deployment operation of it is directly prohibited, thus ensuring the system security during the contract runtime.

[0067] In some embodiments of the present application, the process of the data storage unit 24 performing database operations on the world state to be persisted through a pre-packaged PHP constraint class may include:

[0068] Performing state addition, state deletion, state modification, and state query operations on the database through a pre-packaged PHP constraint class.

[0069] Among them, the PHP constraint class is a set of classes for reading and writing between PHP and the underlying blockchain world state, and its library functions encapsulate the operations of the smart contract for adding, deleting, querying, and modifying the underlying world state.

[0070] Specifically, state addition means adding a blockchain world state. For example, adding an account is manifested as adding a row in a relational data table or inserting a key in a non-relational database.

[0071] State deletion means deleting a blockchain world state. For example, deleting an account is manifested as deleting a row in a relational data table or deleting a key in a non-relational database.

[0072] State query means querying a blockchain world state. For example, querying the balance of a certain account is manifested as querying a specific column value in a row of a relational data table or obtaining the value corresponding to a key in a non-relational database.

[0073] State change means updating a blockchain world state. For example, modifying the balance of a certain account is manifested as updating a specific column value in a row of a relational data table or changing the value corresponding to a key in a non-relational database.

[0074] The PHP constraint class can be easily docked with existing production system databases, including relational databases and non-relational databases, and has high technical ease of use.

[0075] Before executing a smart contract, it is necessary to ensure that the smart contract has been developed and successfully deployed to the blockchain network. The development and deployment of the smart contract are described below.

[0076] Please refer to Figure 2, when writing a smart contract, first use the "require" keyword to reference a pre-encapsulated PHP constraint class to implement operations such as state addition, state deletion, state query, and state modification on the underlying persistent state. Since the memory after the execution of php will be completely recycled and there will be no persistent process, this reference is the only way for users to perform CRUD operations on the system state.

[0077] The function detector is disabled to detect the smart contracts written by users. Except for referencing the PHP constraint class, any user-defined persistent and system operations are prohibited. By writing regular expressions and formulating multiple specific disabling conditions, operations such as "file_put_content" in php are screened. If it exists, it is considered that the detection fails. The smart contracts that fail the detection will be deleted or unable to be deployed, thus ensuring the system security during the contract runtime.

[0078] To describe the development and deployment of smart contracts, the following provides a contract sample code named contract.php:

[0079]

[0080]

[0081] In the above contract, a contract contract.php is constructed. In its constructor, through the interface function CONSTRUCT(), a table is created. This table includes two columns, namely account and value. Through the interface function NEW_2(), a row <"xiaoming", 10000> is inserted into this table, indicating the creation of a new account "xiaoming" and initializing the amount to 10,000 yuan. The contract function Newacc() is for creating a new account and initializing the amount to 0. The contract function Transfer() is for transfer operations. First, it judges whether the sender has the permission of the from account through the two interface functions GET_VALUE() and SENDER(), and then respectively deducts and increases the values in the underlying database through the two interface functions SUB() and ADD() to complete the transfer operation.

[0082] According to the traditional transaction-based deployment method of blockchain smart contracts, contract.php is deployed to the blockchain state.

[0083] Specifically, the user sends a blockchain transaction to any blockchain node, sets the target address of the transaction to be empty, and sets the data field of the transaction to the content of contract.php.

[0084] After that, the blockchain system will calculate the 256-bit target contract address Address using the following equation:

[0085] Address = MD5(FMT(contract.php))

[0086] Where FMT is a preset formatting function, contract.php is the target contract content, and MD5 is the MD5 hash function.

[0087] Through the above process, the user writes the contract.php smart contract in PHP language and deploys it to the blockchain through a blockchain transaction.

[0088] Next, the smart contract execution method provided by the embodiments of this application will be described. The smart contract execution method described below can be mutually corresponding and referred to the smart contract execution engine described above.

[0089] Please refer to Figure 3 , the smart contract execution method provided by the embodiments of this application may include the following steps:

[0090] Step S101, call a specified smart contract according to the interface parameters;

[0091] Step S102, obtain the target contract content according to the called smart contract;

[0092] Step S103, detect the target contract content, interpret the target contract content that passes the detection as machine code, and execute the machine code;

[0093] Step S104, during the execution of the machine code, perform database operations on the world state that needs to be persisted through a pre-encapsulated PHP constraint class, and operate on the runtime environment information through a pre-encapsulated PHP constraint class.

[0094] Please refer to Figure 4 , during the execution of the smart contract, the following four modules are involved: blockchain transaction, blockchain state, PHP interpreter, and persistent data.

[0095] Among them, the blockchain transaction is the transaction that calls the blockchain smart contract, including the address of the target contract, the called function and parameters, etc.

[0096] The blockchain state contains the mapping from each blockchain smart contract address to the content.

[0097] The PHP interpreter is the actual executor of the PHP smart contract. It reads the user's contract and the PHP constraint class at the same time, and interprets the script language as machine code for running.

[0098] Persistent data is the actual data for the contract to run. Since the PHP language, which is widely used in production systems, is adopted, it can be docked with a variety of general databases and is relatively easy to be docked with the existing production system databases.

[0099] Based on the above modules, the execution process of the smart contract can be divided into the following steps:

[0100] 1. Initiate a transaction: That is, the user initiates a transaction to the blockchain through a blockchain light client or a business middle platform, including business information such as the contract address, function name, and function parameters to be called.

[0101] 2. Read the contract: The PHP interpreter reads the contract content corresponding to the address from the blockchain state and executes it in combination with the transaction parameters through the "eval()" system function.

[0102] 3. State operation: During the execution process of the smart contract, for the part that needs to persist data, it is modified through the database driver in the PHP constraint class, and the corresponding insert, delete, query, and modification operations are mapped and translated into database operation statements.

[0103] Through the above process, the PHP smart contract written by the user can be executed consistently and securely on multiple blockchain nodes. At the same time, the PHP interpreter is an execution engine that is widely supported and optimized by the community. According to relevant technical analysis, the performance of PHP7 has been superior to that of virtual machines such as JAVA and JavaScript in some scenarios, thus ensuring the high-performance execution of the user contract.

[0104] In some embodiments of the present application, the interface parameters mentioned in the above step S101 include the address of the target contract, the target contract function, and the parameters of the target contract function;

[0105] The process of calling the specified smart contract according to the interface parameters in the above step S101 may include:

[0106] Call the smart contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

[0107] In some embodiments of the present application, the process of obtaining the target contract content according to the smart contract called by the interface call unit in the above step S102 may include:

[0108] Obtain the target contract address according to the smart contract called by the interface call unit;

[0109] Obtain the target contract content from the preset blockchain state table according to the target contract address, where the blockchain state table contains the mapping relationship between the target contract content and the target contract address.

[0110] In some embodiments of the present application, the process of detecting the target contract content in step S103 includes:

[0111] Detecting whether the target contract content contains a preset prohibited function in the form of a regular expression.

[0112] In some embodiments of the present application, the process of performing database operations on the world state to be persisted in step S104 through a pre-encapsulated PHP constraint class may include:

[0113] Performing state addition, state deletion, state modification, and state query operations on the database through a pre-encapsulated PHP constraint class.

[0114] The intelligent contract execution engine provided by the embodiments of the present application can be applied to intelligent contract execution devices such as computers. Optionally, Figure 5 shows a hardware structure block diagram of the intelligent contract execution device. Referring to Figure 5 , the hardware structure of the intelligent contract execution device may include: at least one processor 31, at least one communication interface 32, at least one memory 33, and at least one communication bus 34.

[0115] In the embodiments of the present application, the number of the processor 31, the communication interface 32, the memory 33, and the communication bus 34 is at least one, and the processor 31, the communication interface 32, and the memory 33 complete mutual communication through the communication bus 34;

[0116] The processor 31 may be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiments of the present application, etc.;

[0117] The memory 32 may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory;

[0118] Among them, the memory 33 stores a program, and the processor 31 can call the program stored in the memory 33. The program is used for:

[0119] Calling a specified intelligent contract according to the interface parameters;

[0120] Obtaining the target contract content according to the called intelligent contract;

[0121] Detecting the target contract content, interpreting the detected target contract content as machine code, and executing the machine code;

[0122] During the execution of the machine code, database operations are performed on the world state to be persisted through a pre-packaged PHP constraint class, and operations are performed on the runtime environment information through a pre-packaged PHP constraint class.

[0123] Optionally, the refinement function and expansion function of the program can refer to the above description.

[0124] The embodiment of the present application also provides a storage medium, which can store a program suitable for execution by a processor. The program is used for:

[0125] Calling a specified smart contract according to the interface parameters;

[0126] Obtaining the target contract content according to the called smart contract;

[0127] Detecting the target contract content, interpreting the target contract content that passes the detection as machine code, and executing the machine code;

[0128] During the execution of the machine code, database operations are performed on the world state to be persisted through a pre-packaged PHP constraint class, and operations are performed on the runtime environment information through a pre-packaged PHP constraint class.

[0129] Optionally, the refinement function and expansion function of the program can refer to the above description.

[0130] In summary:

[0131] The smart contract execution engine of the present application includes an interface call unit for calling a specified smart contract according to interface parameters, a contract reading unit for obtaining target contract content according to the smart contract called by the interface call unit, an interpretation and execution unit for detecting the target contract content, interpreting the target contract content that passes the detection as machine code and executing the machine code, and a data management unit for performing database operations on the world state to be persisted through a pre-packaged PHP constraint class and performing operations on the runtime environment information through a pre-packaged PHP constraint class during the execution of the machine code. Among them, for the world state to be persisted, it is managed through a database, and the database is operated by a pre-packaged PHP constraint class. Since the PHP interpreter is an execution engine widely supported and optimized by the community, it has relatively stable execution capabilities; at the same time, since the PHP execution process reads and writes variables based on the register method, compared with the Ethereum virtual machine that reads and writes variables based on the stack, it can maintain high execution performance and better support high-frequency blockchain business scenarios.

[0132] Finally, it should also be noted that in this text, relational terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements, but also includes other elements not expressly listed, or further includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising an..." does not exclude the presence of additional identical elements in the process, method, article or device comprising said element.

[0133] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.

[0134] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be obvious to those skilled in the art, and the general principles defined herein can be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to these embodiments shown herein, but rather to the broadest scope consistent with the principles and novel features disclosed herein.

Claims

1. An intelligent contract execution engine, characterized in that Comprising: An interface call unit, configured to call a specified smart contract according to interface parameters; A contract reading unit, configured to obtain target contract content according to the smart contract called by the interface call unit; An interpretation and execution unit, configured to detect the target contract content, interpret the target contract content that passes the detection as machine code, and execute the machine code; A data management unit, configured to perform database operations on the world state to be persisted through a pre-packaged PHP constraint class during the execution of the machine code, and operate on the runtime environment information through the pre-packaged PHP constraint class; The interface parameters include the address of the target contract, the target contract function, and the parameters of the target contract function; The process by which the interface call unit calls a specified smart contract according to interface parameters includes: Calling the smart contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

2. The intelligent contract execution engine according to claim 1, wherein The process by which the data management unit performs database operations on the world state to be persisted through a pre-packaged PHP constraint class includes: Performing operations of state addition, state deletion, state modification, and state query on the database through the pre-packaged PHP constraint class.

3. The smart contract execution engine according to claim 1, wherein The process by which the interpretation and execution unit detects the target contract content includes: Detecting whether the target contract content contains a preset disabled function in the form of a regular expression.

4. The intelligent contract execution engine according to claim 1, characterized in that, The process by which the contract reading unit obtains the target contract content according to the smart contract called by the interface call unit includes: Obtaining the target contract address according to the smart contract called by the interface call unit; Obtaining the target contract content from a preset blockchain state table according to the target contract address, where the blockchain state table contains the mapping relationship between the target contract content and the target contract address.

5. An intelligent contract execution method, characterized in that, Comprising: Calling a specified smart contract according to interface parameters; Obtaining target contract content according to the called smart contract; Detecting the target contract content, interpreting the target contract content that passes the detection as machine code, and executing the machine code; During the execution of the machine code, performing database operations on the world state to be persisted through a pre-packaged PHP constraint class, and operating on the runtime environment information through the pre-packaged PHP constraint class; The interface parameters include the address of the target contract, the target contract function, and the parameters of the target contract function; The process of calling a specified smart contract according to interface parameters includes: Calling the smart contract of the blockchain according to the address of the target contract, the target contract function, and the parameters of the target contract function.

6. The method according to claim 5, characterized in that The process of performing database operations on the world state to be persisted through a pre-packaged PHP constraint class includes: Performing operations of state addition, state deletion, state modification, and state query on the database through the pre-packaged PHP constraint class; The process of detecting the target contract content includes: Detecting whether the target contract content contains a preset disabled function in the form of a regular expression.

7. An intelligent contract execution device, characterized in that, Comprising: A memory and a processor; The memory is used to store programs; The processor is configured to execute the program to implement each step of the intelligent contract execution method according to any one of claims 5 to 6.

8. A storage medium, on which a computer program is stored, characterized in that, When the computer program is executed by the processor, each step of the intelligent contract execution method according to any one of claims 5 to 6 is implemented.

Citation Information

Patent Citations

  • Management method and system of configuration file

    CN107506218A

  • Intelligent contract engine system based on block chain and contract execution method

    CN108765158A