Method, device, system and storage medium for improving blockchain smart contract performance

By defining high-performance and low-performance contracts in blockchain services and judging and executing appropriate contract functions through the pre-system call interface, the problems of high programming difficulty and poor service stability in the existing technology are solved, and high Efficient smart contract operation.

CN114331733BActive Publication Date: 2024-12-03BEIJING SHENYUAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110388838.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-04-12
Publication Date
2024-12-03
Estimated Expiration
2041-04-12

AI Technical Summary

Technical Problem

The programming of existing blockchain smart contracts is difficult, and the use of precompiled functions requires redeployment of services, which is not conducive to the stable operation of services.

Method used

Under the same blockchain service, high-performance contracts and low-performance contracts are defined, and the high-performance contract interface is called through the pre-system to determine whether the interface function calls the low-performance contract function. If it is called, it will be executed by the low-performance contract, otherwise it will be done by the high-performance contract. Performance contract execution, return execution data.

Benefits of technology

Improves the efficiency of smart contracts, reduces programming workload, and maintains the stability of services.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114331733B_ABST
    Figure CN114331733B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention discloses a method, device and system for improving the performance of blockchain smart contracts. The method includes: defining high-performance contracts and low-performance contracts under the same blockchain service; calling the high-performance contract calling interface through the front-end system; using the high-performance contract to execute the interface function corresponding to the high-performance contract calling interface; if the interface function calls the low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data; if the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data. By implementing the embodiment of the present invention, a low-performance smart contract can be called when a high-performance smart contract is used, thereby improving the efficiency of the smart contract. Moreover, while improving the efficiency of the smart contract, the code of the low-performance contract can still be partially used, reducing the workload of programming.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method, device and system for improving the performance of blockchain smart contracts. Background Art

[0002] Currently, some blockchains use high-performance virtual machines. However, it is difficult to program code using such virtual machines. In addition, some pre-compiled functions (such as cryptographic algorithms) can be called through contracts with lower performance to improve efficiency. However, this programming difficulty is also not low, and the blockchain service needs to be redeployed.

[0003] That is, the prior art generally has the following disadvantages: high programming difficulty, and the pre-compilation method requires redeployment of services, which is not conducive to the stable operation of services. Summary of the invention

[0004] In view of the technical defects existing in the prior art, the purpose of the embodiments of the present invention is to provide a method, device and system for improving the performance of blockchain smart contracts.

[0005] To achieve the above objectives, in a first aspect, an embodiment of the present invention provides a method for improving the performance of a blockchain smart contract, comprising:

[0006] Define high-performance contracts and low-performance contracts under the same blockchain service;

[0007] Call the high-performance contract calling interface through the front-end system;

[0008] The high-performance contract is used to execute the interface function corresponding to the high-performance contract calling interface;

[0009] If the interface function calls a low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data;

[0010] If the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data.

[0011] As a preferred implementation manner of the present application, the method further includes returning the execution data to the front-end system.

[0012] Among them, the above-mentioned high-performance contract functions include but are not limited to loop functions and recursive functions.

[0013] In a second aspect, an embodiment of the present invention provides a device for improving the performance of a blockchain smart contract, comprising:

[0014] Definition unit, used to define high-performance contracts and low-performance contracts under the same blockchain service;

[0015] The calling unit is used to call the high-performance contract calling interface through the front-end system;

[0016] Execution unit for:

[0017] The high-performance contract is used to execute the interface function corresponding to the high-performance contract calling interface;

[0018] If the interface function calls a low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data;

[0019] If the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data.

[0020] Furthermore, as a preferred implementation of the present application, the device further includes a returning unit for returning the execution data to the front-end system.

[0021] In a third aspect, an embodiment of the present invention further provides a system for improving the performance of blockchain smart contracts, including a front-end system and a device that communicate with each other. The device is as described in the second aspect above.

[0022] By implementing the embodiment of the present invention, a low-performance smart contract can be called when a high-performance smart contract is used, thereby improving the efficiency of the smart contract. Moreover, while improving the efficiency of the smart contract, the code of the low-performance contract can still be partially used, reducing the workload of programming. BRIEF DESCRIPTION OF THE DRAWINGS

[0023] In order to more clearly illustrate the specific implementation of the present invention or the technical solution in the prior art, the drawings required for use in the specific implementation or the description of the prior art are briefly introduced below.

[0024] Figure 1 It is a flowchart for writing smart contract code;

[0025] Figure 2 This is a main flow chart of a method for improving the performance of blockchain smart contracts provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0027] It should be understood that when used in this specification and the appended claims, the terms "include" and "comprises" indicate the presence of described features, integers, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or combinations thereof.

[0028] In order to better understand the solution described in the embodiment of the present invention, the technical solution is first described as follows:

[0029] 1. Define two different smart contract virtual machines under the same blockchain service, namely high-performance virtual machine and low-performance virtual machine.

[0030] 2. The code used by the high-performance virtual machine is called a high-performance contract. The front-end system calls the corresponding function through the contract call interface; the high-performance contract itself calls the corresponding function of the low-performance contract through the low-performance contract call interface, and can also directly execute the function of the high-performance contract itself.

[0031] 3. The code used by the low-performance virtual machine is called a low-performance contract, which is currently commonly used in blockchain projects. As a function library, the low-performance contract can be called through the high-performance contract.

[0032] 4. For parts of low-performance contracts with low execution efficiency, such as loops and recursive functions, they can be implemented in high-performance contract codes; for parts with little difference in execution efficiency, they can be implemented in low-performance contracts.

[0033] Among them, the writing process of smart contracts can be referred to Figure 1 .like Figure 1 As shown in the figure, the smart contract writing process mainly includes:

[0034] (1) Write a high-performance contract calling interface;

[0035] (2) Determine whether there is any loop, recursion or other logic in the contract. If so, execute step (3); otherwise, execute step (4);

[0036] (3) Write high-performance contract functions for logic with high performance requirements such as loops and recursion;

[0037] (4) For other functions, write a low-performance contract calling interface to call the corresponding functions of the low-performance contract;

[0038] (5) Test the written contract.

[0039] The method provided in the embodiment of the present invention mainly describes the calling process of the smart contract. Figure 2 The method for improving the performance of blockchain smart contracts in an embodiment of the present invention mainly includes:

[0040] S101, under the same blockchain service, define high-performance contracts and low-performance contracts.

[0041] S102, calling a high-performance contract calling interface through the front-end system.

[0042] S103, using the high-performance contract to execute the interface function corresponding to the high-performance contract calling interface.

[0043] S104, determine whether the low-performance contract function is called in the interface function, if so, execute step S105, otherwise, execute step S106.

[0044] S105, using the low-performance contract to execute the corresponding low-performance contract function to obtain execution data.

[0045] S106, using the high-performance contract to execute the corresponding high-performance contract function to obtain execution data.

[0046] S107, returning the execution result and execution data to the front-end system.

[0047] From the above description, it can be seen that the main features of the present invention can be summarized as follows:

[0048] (1) A blockchain system that combines a high-performance virtual machine with a low-performance virtual machine is provided;

[0049] (2) It provides a method that uses high-performance contracts as entry points and low-performance contracts as function libraries;

[0050] (3) Provides a mechanism to judge and call low-performance contract functions or its own contract functions through high-performance contract code.

[0051] Compared with the prior art, the above technical solution can call low-performance smart contracts when using high-performance smart contracts, thereby improving the efficiency of smart contracts. Moreover, while improving the efficiency of smart contracts, the code of low-performance contracts can still be partially used, reducing the workload of programming.

[0052] Based on the same inventive concept, an embodiment of the present invention provides a system for improving the performance of blockchain smart contracts, including a front-end system and a device that communicate with each other.

[0053] The device comprises:

[0054] Definition unit, used to define high-performance contracts and low-performance contracts under the same blockchain service;

[0055] The calling unit is used to call the high-performance contract calling interface through the front-end system;

[0056] Execution unit for:

[0057] The high-performance contract is used to execute the interface function corresponding to the high-performance contract calling interface;

[0058] If the interface function calls a low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data;

[0059] If the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data;

[0060] A returning unit is used to return the execution data to the front-end system.

[0061] It should be noted that, for more specific working procedures of the device in this embodiment, please refer to the aforementioned method embodiment part, which will not be repeated here.

[0062] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the mutual coupling or direct coupling or communication connection shown or discussed can be an indirect coupling or communication connection through some interfaces, devices or units, or it can be an electrical, mechanical or other form of connection.

[0063] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0064] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0065] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0066] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed by the present invention, and these modifications or replacements should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be based on the protection scope of the claims.

Claims

1. A method for improving the performance of blockchain smart contracts, characterized in that: include: Define high-performance contracts and low-performance contracts under the same blockchain service; Call the high-performance contract calling interface through the front-end system; The high-performance contract is used to execute the interface function corresponding to the high-performance contract calling interface; If the interface function calls a low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data; If the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data; and the execution data is returned to the front-end system; Among them, the definitions of high-performance contracts and low-performance contracts are as follows: Define two different smart contract virtual machines under the same blockchain service, namely high-performance virtual machine and low-performance virtual machine; the code used by the high-performance virtual machine is called high-performance contract; the code used by the low-performance virtual machine is called low-performance contract; The smart contract writing process includes: (1) Write a high-performance contract calling interface; (2) Determine whether there is a loop or recursive logic in the contract. If so, execute step (3); otherwise, execute step (4); (3) Write high-performance contract functions for logic with high performance requirements; (4) For other functions, write a low-performance contract calling interface to call the corresponding functions of the low-performance contract; (5) Test the written contract.

2. The method for improving the performance of blockchain smart contracts as claimed in claim 1, characterized in that: The high-performance contract function includes a loop function and a recursive function.

3. A device for improving the performance of blockchain smart contracts, characterized in that: include: Definition unit, used to define high-performance contracts and low-performance contracts under the same blockchain service; The calling unit is used to call the high-performance contract calling interface through the front-end system; Execution unit for: The high-performance contract is used to execute the interface function corresponding to the high-performance contract calling interface; If the interface function calls a low-performance contract function, the low-performance contract is used to execute the corresponding low-performance contract function to obtain execution data; If the interface function does not call the low-performance contract function, the high-performance contract is used to execute the corresponding high-performance contract function to obtain execution data; A returning unit, used for returning the execution data to the front-end system; Among them, the definitions of high-performance contracts and low-performance contracts are as follows: Define two different smart contract virtual machines under the same blockchain service, namely high-performance virtual machine and low-performance virtual machine; the code used by the high-performance virtual machine is called high-performance contract; the code used by the low-performance virtual machine is called low-performance contract; The smart contract writing process includes: (1) Write a high-performance contract calling interface; (2) Determine whether there is a loop or recursive logic in the contract. If so, execute step (3); otherwise, execute step (4); (3) Write high-performance contract functions for logic with high performance requirements; (4) For other functions, write a low-performance contract calling interface to call the corresponding functions of the low-performance contract; (5) Test the written contract.

4. The device for improving the performance of blockchain smart contracts as claimed in claim 3, characterized in that: The high-performance contract function includes a loop function and a recursive function.

5. A system for improving the performance of blockchain smart contracts, comprising a front-end system and a device that communicate with each other, characterized in that: The device is as described in claim 3.