Block chain contract call routing method, device and equipment and storage medium

By abstracting the smart contract lifecycle and integrating plug-in interfaces, the problem of single contract types in blockchain systems is solved, enabling support for multiple types of smart contracts and secure call routing, and dynamically expanding the contract virtual machine's capabilities.

CN120929182APending Publication Date: 2025-11-11CHENGDU PRIME STARK TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410558373.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-08
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing blockchain systems only support a single type of smart contract, which cannot meet the requirements for flexible scheduling of multiple types of smart contracts and on-chain contract call routing.

Method used

By abstracting the smart contract lifecycle, interfaces for multiple contract lifecycle stages are defined and integrated into the blockchain system as plugins. Contract metadata is calculated and encapsulated in the source code, establishing the association between contract types and virtual machines, and realizing contract call routing.

Benefits of technology

It enables the blockchain system to support and dynamically expand multiple types of smart contracts, shields the underlying execution logic, and ensures the security and flexibility of contract calls.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120929182A_ABST
    Figure CN120929182A_ABST
Patent Text Reader

Abstract

The invention provides a block chain contract calling routing method and device, equipment and a storage medium, and relates to the technical field of contract calling. The method comprises the following steps: abstracting a life cycle of an intelligent contract on a chain to obtain a plurality of continuous contract cycle stages; a contract interface of each contract period stage is defined, and the contract interface is integrated to a block chain system in a plug-in form; calculating contract metadata of the smart contract, and encapsulating the metadata on a source code of the smart contract to obtain a contract route; obtaining a contract calling request of a transaction, and matching a corresponding contract virtual machine through a contract route; and finally, starting the contract virtual machine to respond to the request, executing the transaction and returning an execution result. According to the method, the life cycle of the intelligent contract on the chain is abstracted into a plurality of stages, and the interface is integrated to the block chain in the form of the plug-in, so that the capability of dynamically expanding the contract virtual machine is realized, and meanwhile, the association binding relationship is established between the contract type and the virtual machine, so that intelligent routing of contract calling is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of contract invocation technology, and in particular to a blockchain contract invocation routing method, apparatus, device, and storage medium. Background Technology

[0002] A smart contract is an automatically executing computer program that runs in cyberspace. When the contract terms are met, the smart contract is executed automatically without third-party intervention. These contracts are typically stored on a blockchain to ensure transparency and security.

[0003] As blockchain technology is applied to more real-world business scenarios, the types of smart contracts involved are becoming increasingly diverse. This requires blockchain systems to support multiple types of smart contracts simultaneously and to flexibly schedule various smart contract virtual machines to route contract instructions to the corresponding type of virtual machine for execution. However, most traditional blockchain systems only support a single type of smart contract and lack the ability to route on-chain contract calls, making it difficult to meet the increasingly diverse smart contract application needs in real-world business. Summary of the Invention

[0004] The purpose of this invention is to provide a contract file deployment method, apparatus, device, and storage medium to solve the problem that existing blockchain systems have a relatively limited range of contract call types and lack on-chain contract call routing.

[0005] The specific technical solution of this invention is as follows: In a first aspect of the present invention, a blockchain contract call routing method is provided, comprising: The lifecycle of smart contracts on the blockchain is abstracted to obtain multiple consecutive contract cycle stages; Define the contract interfaces for each stage of the smart contract lifecycle, and integrate the contract interfaces into the blockchain system as plug-ins; The contract metadata of the smart contract is calculated and encapsulated in the source code of the smart contract to obtain the contract route; the contract metadata includes the contract type, and the contract type is associated with the contract virtual machine; Obtain the contract call request for the transaction and match the corresponding contract virtual machine through contract routing; Start the contract virtual machine in response to the contract call request, execute the transaction, and return the execution result of the transaction.

[0006] Furthermore, the definition of contract interfaces for each stage of the smart contract's lifecycle, and the integration of these contract interfaces into the blockchain system as plug-ins, includes: Interfaces are defined at each contract cycle stage to obtain the corresponding contract interfaces, and corresponding interface permissions are assigned to each contract interface; the contract cycle stages include contract creation, contract execution, and contract destruction. The contract interfaces for each stage of the contract lifecycle are integrated into the blockchain system in the form of plug-ins, and the contract interface permissions are uploaded to the blockchain system for storage.

[0007] Further, the step of calculating the contract metadata of the smart contract and encapsulating the contract metadata in the source code of the smart contract to obtain the contract route includes: Obtain the smart contract's contract file, calculate the first hash value of the contract file using a hash function, and generate the contract version number of the contract file according to a preset numbering rule; The first hash value and contract version number, along with the contract ID, contract name, and contract type configured in the contract file, are used as contract metadata. This contract metadata is then encapsulated in the source code of the contract file to form a metadata structure, thus obtaining the contract route.

[0008] Furthermore, the step of obtaining the contract call request for the transaction and matching the corresponding contract virtual machine through contract routing includes: It receives contract call requests for key transactions in the blockchain system, parses the contract call requests to obtain the contract information specified for the current transaction execution, including contract ID, contract name, and contract type; The contract route is invoked according to the contract type to match the contract virtual machine and determine the contract virtual machine to be executed for the transaction.

[0009] Furthermore, the process of parsing the contract call request also includes: The user's contract call permissions are obtained by parsing the contract call request. The user's contract call permissions are compared with the smart contract's interface permissions. If the user's contract call permissions are greater than or equal to the smart contract's interface permissions, a contract virtual machine matching operation is performed.

[0010] Secondly, the present invention provides a blockchain contract call routing device, comprising: The contract abstraction module is used to abstract the lifecycle of smart contracts on the chain, resulting in multiple consecutive contract cycle stages. The contract integration module is used to define the contract interfaces for each stage of the smart contract lifecycle and integrate the contract interfaces into the blockchain system as a plug-in. The contract encapsulation module is used to calculate the contract metadata of the smart contract and encapsulate the contract metadata on the source code of the smart contract to obtain the contract route; the contract metadata includes the contract type, and the contract type is associated with the contract virtual machine; The contract matching module is used to obtain the contract call request of the transaction and match the corresponding contract virtual machine through contract routing; The contract response module is used to start the contract virtual machine to respond to the contract call request, execute the transaction, and return the execution result of the transaction.

[0011] Thirdly, the present invention provides an electronic device, comprising: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the blockchain contract call routing method of the first aspect.

[0012] Fourthly, the present invention provides a computer-readable medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the blockchain contract call routing method provided in the first aspect.

[0013] The beneficial effects of this invention are as follows: By abstracting the on-chain lifecycle of smart contracts into multiple stages and providing them to external integration in the form of plug-in interfaces, this method shields the underlying execution logic and virtual machine architecture of different types of contracts from the blockchain system. Different types of contracts only need to implement the interfaces of each stage of the smart contract lifecycle to be integrated into the blockchain as plug-ins, thus achieving the ability to dynamically expand the contract virtual machine. This invention also establishes an association and binding relationship between contract types and virtual machines to achieve intelligent routing of contract calls. Attached Figure Description

[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention, and those skilled in the art can obtain other drawings based on these drawings without creative effort.

[0015] Figure 1 This is a flowchart of a blockchain contract call routing method proposed in one embodiment of the present invention; Figure 2 This is a schematic diagram of a blockchain contract call routing device module structure proposed in one embodiment of the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without creative effort are within the scope of protection of the present invention.

[0017] Example 1: Figure 1 This is a flowchart of a blockchain contract call routing method proposed in one embodiment of the present invention. (Reference) Figure 1 As shown, a blockchain contract call routing method according to an embodiment of the present invention mainly includes the following steps: S1: Abstract the lifecycle of smart contracts on the chain to obtain multiple consecutive contract cycle stages; S2: Define the contract interface for each stage of the smart contract lifecycle and integrate the contract interface into the blockchain system as a plug-in; S3: Calculate the contract metadata of the smart contract and encapsulate the contract metadata in the source code of the smart contract to obtain the contract route; the contract metadata includes the contract type, and the contract type is associated with the contract virtual machine; S4: Obtain the contract call request for the transaction and match the corresponding contract virtual machine through contract routing; S5: Start the contract virtual machine to respond to the contract call request, execute the transaction, and return the execution result of the transaction.

[0018] Furthermore, in this embodiment of the invention, step S2 defines the contract interface for each stage of the smart contract's lifecycle and integrates the contract interface into the blockchain system as a plug-in, including but not limited to the following sub-steps: S21: Define the interface at each contract lifecycle stage, obtain the corresponding contract interface, and assign corresponding interface permissions to each contract interface. The contract lifecycle stages include contract creation, contract execution, and contract destruction.

[0019] In practice, the lifecycle stages of a smart contract can be adjusted according to the actual situation. For example, the lifecycle can be divided into three stages: contract generation, contract deployment, and contract execution. The specific division method can be selected according to the actual management method of the smart contract.

[0020] S22: Integrate the contract interfaces of each contract cycle stage into the blockchain system in the form of plug-ins, support the dynamic expansion of smart contracts, and upload the contract interface permissions to the blockchain system for storage.

[0021] In this invention, the contract interface permissions are managed uniformly by the smart contract administrator in the blockchain. By setting contract interface permissions, external users can verify the contract call permissions when calling the contract, thereby ensuring the information security of the blockchain.

[0022] Existing blockchain systems often only support a single type of smart contract and cannot be dynamically expanded, failing to meet the increasingly diverse smart contract application needs in actual business. This invention solves the problem of single-type and non-scalable blockchain smart contracts by simultaneously supporting and being compatible with smart contracts of types including Java, Go, Python, and Solidity, and providing a plug-in integration method for dynamic expansion.

[0023] Furthermore, in this embodiment of the invention, step S3 calculates the contract metadata of the smart contract and encapsulates the contract metadata in the source code of the smart contract to obtain the contract route, including but not limited to the following sub-steps: S31: Obtain the smart contract's contract file, calculate the first hash value of the contract file using a hash function, and generate the contract version number of the contract file according to a preset numbering rule.

[0024] When calculating the first hash value of the contract file, the hash function used can be MD5, SHA, CRC32, BKDR, etc., depending on the data format of the contract file or the storage verification requirements.

[0025] In this embodiment of the invention, by calculating the first hash value of the contract file, the hash value of the contract file can be compared with the first hash value when the smart contract is called in a subsequent manner, thereby realizing hash verification of the contract file and improving the data security of contract calls.

[0026] S32: The first hash value and contract version number, along with the contract ID, contract name, and contract type configured in the contract file, are used as contract metadata. The contract metadata is then encapsulated in the source code of the contract file to form a metadata structure, thus obtaining the contract route.

[0027] In this embodiment of the invention, a metadata structure containing contract type, file hash and other basic information describing the contract is encapsulated on top of the source code of the smart contract. This allows the blockchain to match the corresponding virtual machine based on the contract type in the contract metadata during contract calls and nested contract calls, thereby switching to the corresponding context and completing the execution of the contract instructions.

[0028] Furthermore, in this embodiment of the invention, step S4 involves obtaining the contract call request for the transaction and matching the corresponding contract virtual machine through contract routing, including but not limited to the following sub-steps: S41: Receives contract call requests for key transactions in the blockchain system, parses the contract information in the request, and obtains the contract information specified for the current transaction execution. This contract information includes data such as contract ID, contract name, and contract type.

[0029] S42: Call the contract route according to the contract type to match the contract virtual machine and determine the contract virtual machine to be executed in the transaction.

[0030] Specifically, when the contract route is invoked to match the contract virtual machine according to the contract type, the contract route first locates the specific contract file address in the blockchain system based on the invoked contract ID. Then, the contract route performs virtual machine query matching according to the invoked contract type. Since the contract type is associated with the contract virtual machine in advance, the contract route can accurately match the corresponding contract virtual machine based on the association relationship.

[0031] In existing technologies, different types of smart contracts require different virtual machines for execution. If the blockchain cannot match the corresponding virtual machine according to the contract instruction type, it cannot satisfy the simultaneous execution of multiple types of smart contracts. The embodiments of the present invention support the establishment of a binding relationship between contract type and virtual machine to realize the intelligent routing function of contract calls.

[0032] Furthermore, in the process of parsing the contract call request, this embodiment of the invention also includes verifying the user's call permission, which specifically includes: First, the contract call request is parsed to obtain the user's contract call permissions. Then, the user's contract call permissions are compared with the interface permissions of the smart contract's interface. If the user's contract call permissions are greater than or equal to the interface permissions of the smart contract, a contract virtual machine matching operation is performed. This invention verifies the permissions of transaction contract call requests, ensuring the security of smart contract interface services can only be called after the permission verification is successful.

[0033] This invention abstracts the on-chain lifecycle of smart contracts into multiple stages and provides them to external integration via plug-in interfaces. For the blockchain system, this shields the underlying execution logic and virtual machine architecture of different contract types. Different contract types only need to implement the interfaces for each stage of the smart contract lifecycle to be integrated into the blockchain as plug-ins, achieving the ability to dynamically expand the contract virtual machine. This invention also establishes an association between contract types and virtual machines to achieve intelligent routing of contract calls.

[0034] Example 2: Refer to Figure 2 As shown, the present invention provides a blockchain contract call routing device, comprising: The contract abstraction module is used to abstract the lifecycle of smart contracts on the chain, resulting in multiple consecutive contract cycle stages. The contract integration module is used to define the contract interfaces for each stage of the smart contract lifecycle and integrate the contract interfaces into the blockchain system as a plug-in. The contract encapsulation module is used to calculate the contract metadata of the smart contract and encapsulate the contract metadata on the source code of the smart contract to obtain the contract route; the contract metadata includes the contract type, and the contract type is associated with the contract virtual machine; The contract matching module is used to obtain the contract call request of the transaction and match the corresponding contract virtual machine through contract routing; The contract response module is used to start the contract virtual machine to respond to the contract call request, execute the transaction, and return the execution result of the transaction.

[0035] Specifically, the working process of the device in this embodiment of the invention is as follows: 1. Assume that the current blockchain has integrated smart contract virtual machines in Java and Go languages: VM-JAVA and VM-GO; 2. Upload a Java contract and a Go contract to the blockchain respectively: CONTRACT-JAVA and CONTRACT-GO; 3. Initiate two separate transactions, tx1 and tx2, to execute the CONTRACT-JAVA contract and the CONTRACT-GO contract, respectively. 4. After receiving transactions tx1 and tx2, the blockchain locates the corresponding contract file address and starts the corresponding VM-JAVA and VM-GO virtual machines according to the contract type in the contract metadata; 5. Execute the CONTRACT-JAVA and CONTRACT-GO contract instructions respectively, and return the execution results of tx1 and tx2 transactions.

[0036] When responding to a contract call request, the device in this embodiment of the invention first extracts the contract type according to the specified contract information for the current transaction. Since the methods supported by each type of contract have been aggregated into the contract routing, the contract routing can directly route to the specific contract according to the contract type and start the corresponding contract virtual machine to execute the transaction. This allows the blockchain system to support a single type of smart contract while also meeting the increasingly rich smart contract application needs in actual business.

[0037] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of the present invention are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid state disk (SSD)).

[0038] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0039] The various embodiments in this specification are described in a related manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions of the method embodiments.

[0040] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention are included within the scope of protection of the present invention.

Claims

1. A blockchain contract call routing method, characterized in that, include: The lifecycle of smart contracts on the blockchain is abstracted to obtain multiple consecutive contract cycle stages; Define the contract interfaces for each stage of the smart contract lifecycle, and integrate the contract interfaces into the blockchain system as plug-ins; Calculate the contract metadata of the smart contract and encapsulate the contract metadata in the source code of the smart contract to obtain the contract route; The contract metadata includes the contract type, and the contract type is associated with a contract virtual machine; Obtain the contract call request for the transaction and match the corresponding contract virtual machine through contract routing; Start the contract virtual machine in response to the contract call request, execute the transaction, and return the execution result of the transaction.

2. The blockchain contract call routing method according to claim 1, characterized in that, The definition of the contract interface for each stage of the smart contract lifecycle, and the integration of the contract interface into the blockchain system as a plug-in, includes: Interfaces are defined at each contract cycle stage to obtain the corresponding contract interfaces, and corresponding interface permissions are assigned to each contract interface; the contract cycle stages include contract creation, contract execution, and contract destruction. The contract interfaces for each stage of the contract lifecycle are integrated into the blockchain system in the form of plug-ins, and the contract interface permissions are uploaded to the blockchain system for storage.

3. The blockchain contract call routing method according to claim 1, characterized in that, The process of calculating the contract metadata of the smart contract and encapsulating the contract metadata in the source code of the smart contract to obtain the contract route includes: Obtain the smart contract's contract file, calculate the first hash value of the contract file using a hash function, and generate the contract version number of the contract file according to a preset numbering rule; The first hash value and contract version number, along with the contract ID, contract name, and contract type configured in the contract file, are used as contract metadata. This contract metadata is then encapsulated in the source code of the contract file to form a metadata structure, thus obtaining the contract route.

4. The blockchain contract call routing method according to claim 1, characterized in that, The process of obtaining the contract call request for the transaction and matching the corresponding contract virtual machine through contract routing includes: It receives contract call requests for key transactions in the blockchain system, parses the contract call requests to obtain the contract information specified for the current transaction execution, including contract ID, contract name, and contract type; The contract route is invoked according to the contract type to match the contract virtual machine and determine the contract virtual machine to be executed for the transaction.

5. The blockchain contract call routing method according to claim 4, characterized in that, The process of parsing the contract call request also includes: The user's contract call permissions are obtained by parsing the contract call request. The user's contract call permissions are compared with the smart contract's interface permissions. If the user's contract call permissions are greater than or equal to the smart contract's interface permissions, a contract virtual machine matching operation is performed.

6. A blockchain contract call routing device, characterized in that, include: The contract abstraction module is used to abstract the lifecycle of smart contracts on the chain, resulting in multiple consecutive contract cycle stages. The contract integration module is used to define the contract interfaces for each stage of the smart contract lifecycle and integrate the contract interfaces into the blockchain system as a plug-in. The contract encapsulation module is used to calculate the contract metadata of the smart contract and encapsulate the contract metadata in the source code of the smart contract to obtain the contract route; The contract metadata includes the contract type, and the contract type is associated with a contract virtual machine; The contract matching module is used to obtain the contract call request of the transaction and match the corresponding contract virtual machine through contract routing; The contract response module is used to start the contract virtual machine to respond to the contract call request, execute the transaction, and return the execution result of the transaction.

7. An electronic device, characterized in that, include: One or more processors; A storage device for storing one or more programs, which, when executed by one or more processors, cause the one or more processors to implement the blockchain contract call routing method as described in any one of claims 1 to 5.

8. A computer-readable medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the blockchain contract call routing method as described in any one of claims 1 to 5.