Intelligent contract execution path optimization method and system based on cross-chain interaction

By introducing scene coding library and time lock mechanism into smart contracts, decoupling and optimizing the execution path of smart contracts, the problems of low efficiency and insufficient security of execution paths in cross-chain interactions are solved, and more efficient and reliable cross-chain interactions are achieved.

CN120216144APending Publication Date: 2025-06-27LINGSHU TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510349157.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-03-24
Publication Date
2025-06-27

AI Technical Summary

Technical Problem

Existing smart contracts have low execution path efficiency and insufficient security in cross-chain interactions, cannot complete cross-chain tasks quickly and accurately, and lack effective risk prevention and control mechanisms.

Method used

By introducing a scene encoding library, the scene compliance coding of cross-chain interactive scenarios are matched, the smart contract is decoupled and the scene compliance coding is injected, and the scene smart contract is determined. Then, based on the scene smart contract, the pre-execution path driven by intent is determined, and a time lock is introduced to perform interactive consensus locking on the pre-execution path in the path risk window.

Benefits of technology

It improves the execution path optimization level of smart contracts in cross-chain interactive scenarios, and enhances the security and reliability of execution.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120216144A_ABST
    Figure CN120216144A_ABST
Patent Text Reader

Abstract

The invention discloses an intelligent contract execution path optimization method and system based on cross-chain interaction, and relates to the technical field of blockchains, and the method comprises the steps: determining a cross-chain interaction scene through an interaction chain and an interaction task, and reading an intelligent contract; a scene code library is introduced, a scene compliance code based on the cross-chain interaction scene is matched, the smart contract is decoupled, the scene compliance code is injected into a coding logic block, and a scene smart contract is determined; and determining a pre-execution path driven by an intention according to the scene smart contract, and introducing a time lock to perform interactive consensus locking of a path risk window on the pre-execution path. According to the method and the device, the technical problems of low execution path efficiency and insufficient safety of the existing smart contract in cross-chain interaction are solved, and the technical effects of improving the optimization level of the execution path of the smart contract in a cross-chain interaction scene and enhancing the execution safety and reliability are achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and particularly to a method and system for optimizing the execution path of smart contracts based on cross-chain interaction. Background Art

[0002] With the development of blockchain technology, the demand for cross-chain interaction is increasing day by day, and the collaborative operation between different blockchains has become increasingly important. In the cross-chain interaction scenario, the execution of smart contracts faces many challenges. On the one hand, the traditional execution path of smart contracts does not fully consider the complexity of cross-chain interaction. In a multi-chain environment, there are differences in the structures, consensus mechanisms, and data formats of different blockchains, resulting in low execution efficiency of smart contracts and inability to complete cross-chain tasks quickly and accurately. For example, when it comes to cross-chain transfer of assets, problems such as long execution paths and poor data interaction may occur, increasing transaction costs and time costs. On the other hand, the security of cross-chain interaction is difficult to guarantee. Due to different trust mechanisms between different blockchains, risks such as data leakage and malicious attacks are likely to occur during the execution of smart contracts. For example, during cross-chain data interaction, data may be tampered with or stolen due to insufficient mutual trust, affecting the reliability of cross-chain interaction. In addition, the existing execution paths of smart contracts lack effective risk prevention and control mechanisms and cannot detect and handle potential risks in a timely manner, further restricting the development of cross-chain interaction.

[0003] There are technical problems of low execution path efficiency and insufficient security of existing smart contracts in cross-chain interaction. Summary of the Invention

[0004] The present application provides a method and system for optimizing the execution path of smart contracts based on cross-chain interaction, which are used to solve the technical problems of low execution path efficiency and insufficient security of existing smart contracts in cross-chain interaction.

[0005] In view of the above problems, the present application provides a method and system for optimizing the execution path of smart contracts based on cross-chain interaction.

[0006] In the first aspect of the present application, there is provided a method for optimizing the execution path of smart contracts based on cross-chain interaction, and the method includes:

[0007] Determine the cross-chain interaction scenario with the interactive chain and the interactive task, and read the smart contract, wherein the interactive chain is at least a dual chain; introduce the scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the codable logic block, and determine the scenario smart contract, wherein the decoupling is to determine the solidified logic block and the codable logic block; determine the intent-driven pre-execution path with the scenario smart contract, and introduce a time lock to perform interactive consensus locking of the path risk window on the pre-execution path, wherein the pre-execution path is determined based on the coupling of the composite intent analysis of the interactive task and the single-intent path optimization.

[0008] The second aspect of the present application provides a smart contract execution path optimization system based on cross-chain interaction, the system comprising:

[0009] A cross-chain interaction scenario determination module is used to determine the cross-chain interaction scenario with the interaction chain and the interaction task, and read the smart contract, wherein the interaction chain is at least a dual chain; a scenario smart contract determination module is used to introduce a scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the encodable logic block, and determine the scenario smart contract, wherein the decoupling is to determine the solidified logic block and the encodable logic block; an interactive consensus locking module is used to determine the intent-driven pre-execution path with the scenario smart contract, and introduce a time lock to perform interactive consensus locking of the path risk window on the pre-execution path, wherein the pre-execution path is determined based on the coupling of the composite intent analysis of the interactive task and the single-intent path optimization.

[0010] One or more technical solutions provided in this application have at least the following technical effects or advantages:

[0011] Determine the cross-chain interaction scenario with the interactive chain and interactive tasks, and read the smart contract; introduce the scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the encodable logic block to determine the scenario smart contract; determine the intent-driven pre-execution path with the scenario smart contract, and introduce a time lock to lock the pre-execution path with an interactive consensus of the path risk window. The technical effect of improving the optimization level of the execution path of the smart contract in the cross-chain interaction scenario and enhancing the security and reliability of the execution is achieved. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0013] Figure 1 Schematic flow chart of the intelligent contract execution path optimization method based on cross-chain interaction provided by the embodiments of the present application;

[0014] Figure 2 Schematic structural diagram of the intelligent contract execution path optimization system based on cross-chain interaction provided by the embodiments of the present application.

[0015] Explanation of reference numerals: Cross-chain interaction scenario determination module 10, scenario intelligent contract determination module 20, interaction consensus locking module 30. Detailed implementation manners

[0016] The present application provides an intelligent contract execution path optimization method and system based on cross-chain interaction, which are used to solve the technical problems of low execution path efficiency and insufficient security of existing intelligent contracts in cross-chain interaction.

[0017] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts shall fall within the protection scope of the present application.

[0018] Embodiment 1, as Figure 1 shown, the present application provides an intelligent contract execution path optimization method based on cross-chain interaction, and the method includes:

[0019] Step S100: Determine the cross-chain interaction scenario based on the interaction chain and the interaction task, and read the intelligent contract, where the interaction chain is at least a double chain.

[0020] Specifically, first, the cross-chain interaction scenario is determined through the interaction chain and the interaction task, and at the same time, the intelligent contract is read. Here, the interaction chain is at least a double chain. Then, a scenario coding library is introduced. First, the cross-chain interaction scenario set is counted, the personalized interaction characteristics are traversed and determined, and combined with the intelligent contract coding rules, it is converted into personalized coding, and mapped and integrated to construct a scenario coding library. Then, the intelligent contract is decoupled into a solidified logic block and a codable logic block, and the scenario compliance coding is injected into the codable logic block and coupled according to the set rules to obtain a scenario intelligent contract. After that, based on the scenario intelligent contract, the composite intention of the interaction task is parsed to obtain a single intention, the single intention path is determined and coupled, the pre-execution path is determined through concurrent coupling game and sequential game, and then a time lock is introduced to perform interaction consensus locking on the risk window of the pre-execution path. If the path risk window is empty, direct cross-chain management is performed, and if it is non-empty, locking trigger and unlocking management are performed according to the window boundary, so as to optimize the execution path of the intelligent contract in cross-chain interaction.

[0021] Step S200: Introduce a scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the encodable logic block, and determine the scenario smart contract, wherein the decoupling is to determine the solidified logic block and the encodable logic block.

[0022] Specifically, we first build a scenario coding library. By counting various cross-chain interaction scenario sets, we traverse each scenario to determine its personalized interaction characteristics, which reflect the unique needs of different scenarios in the interaction process, such as specific interaction rules, data format requirements, etc. Then, according to the coding regulations of the smart contract, we convert the personalized interaction characteristics into corresponding personalized codes. We map and integrate the scenario set, personalized interaction characteristics, and personalized codes to build a scenario coding library. Next, we process the smart contract, decouple the smart contract according to its adjustability, and divide it into solidified logic blocks and codable logic blocks. For the codable logic block, we accurately locate its adjustable logic interface and schedulable part, identify the adjustable conditions, and set strict injection rules. According to the injection rules, we use the adjustable conditions to match the scene and find the injection logic interface suitable for the scene compliance coding. Before injection, we calibrate the scene compliance coding to ensure its accuracy and adaptability, and then inject it into the codable logic block. Finally, we couple the solidified logic block with the codable logic block injected with the scenario compliance coding, thereby generating a scenario smart contract that meets the current cross-chain interaction scenario requirements, laying the foundation for determining a more optimized execution path in the future.

[0023] Step S300: Determine the intent-driven pre-execution path using the scenario smart contract, and introduce a time lock to perform interactive consensus locking of the path risk window on the pre-execution path, wherein the pre-execution path is determined based on the coupling of composite intent analysis of interactive tasks and single intent path optimization.

[0024] Specifically, the interaction intention is determined according to the interaction chain and interaction tasks. If the interaction intention is a composite intention, it is parsed according to the standard of the minimum intention unit to obtain N single intentions. Then, for these N single intentions, their respective execution paths are determined within the framework of the scenario smart contract and coupled processing is performed. In this process, first, the N single intention paths are determined, and these paths are first marked according to the intention concurrency. Then, through concurrent coupling game, with the coupling integration and being integrated as the game goal, a first-order coupling path containing M (M is a positive integer less than or equal to N) coupling paths is determined. Then, sequential game and integration are performed on the first-order coupling path to determine the pre-execution path. To ensure the safe and reliable execution of the pre-execution path, a time lock is introduced. Traverse the pre-execution path, and locate the path risk window according to the mutual trust of the interaction execution. If the path risk window is empty, it means that the pre-execution path is relatively safe, and cross-chain management will be directly performed on it based on the interaction task. If the path risk window is not empty, then an interaction regret-free locking time lock based on the consensus mechanism is introduced, and according to the window boundaries of each path risk window, locking trigger and unlocking management are performed on the path execution process of the pre-execution path to ensure that the execution path of the smart contract in cross-chain interaction is optimized and the execution risk is reduced.

[0025] In a possible implementation manner, step S200 further includes:

[0026] Step S210: Statistically analyze the scenario set based on cross-chain interaction.

[0027] Step S220: Traverse the scenario set to determine personalized interaction characteristics, where the scenario set corresponds to the personalized interaction characteristics.

[0028] Step S230: Interact with the coding rules of the smart contract to convert the personalized interaction characteristics and determine personalized coding.

[0029] Step S240: Map and integrate the scenario set - personalized interaction characteristics - personalized coding to construct the scenario coding library.

[0030] Specifically, in the process of constructing the scenario coding library, first, various scenarios based on cross-chain interaction are comprehensively sorted out and statistically analyzed, and cross-chain interaction scenarios of different types and uses are collected to form a scenario set. These scenarios cover various situations that may occur during cross-chain interaction, such as asset transfer and information sharing between different blockchains.

[0031] Perform a traversal operation on the statistically obtained scenario set based on cross-chain interactions. During the traversal process, deeply analyze each scenario. Since different cross-chain interaction scenarios have their own unique business logics, interaction rules, and data requirements. For example, in the cross-chain asset trading scenario, it involves special requirements such as the asset formats of different blockchains and the transaction confirmation mechanism; while in the cross-chain identity verification scenario, it focuses on the encrypted transmission and verification rules of identity information. By analyzing these differences, accurately identify the personalized interaction characteristics unique to each scenario. These characteristics are the key to differentiating this scenario from other scenarios, and each scenario uniquely corresponds to a set of personalized interaction characteristics, providing the core basis for generating personalized codes and constructing a scenario coding library according to these characteristics later.

[0032] After completing the traversal of the scenario set and determining the personalized interaction characteristics corresponding to each scenario, start processing these characteristics. Invoke the coding rules of the smart contract. These coding rules are the guidelines for writing and executing smart contracts, defining data formats, operation logics, syntax specifications, etc. Compare, adapt, and transform each personalized interaction characteristic with the coding rules. For example, for the specific data interaction rules in certain scenarios, according to the coding rules, transform this rule into a specific code snippet or data structure to form the corresponding personalized code. This process is to concretize the abstract interaction characteristics into those that meet the coding requirements of the smart contract, ensuring that the subsequent scenario coding library can interact smoothly with the smart contract, and thus providing strong support for optimizing the execution path of the smart contract in the cross-chain interaction scenario.

[0033] Map and integrate the scenario set, the corresponding personalized interaction characteristics, and the personalized codes to construct a scenario coding library. Create a data structure in memory or storage media, such as a hash table, a database table, etc., to store these mapping relationships. For each scenario in the scenario set, use it as the main index to associate the corresponding personalized interaction characteristics and personalized codes. Each scenario can quickly find its corresponding personalized interaction characteristics through this index. These characteristics detail the unique interaction requirements of this scenario, and the associated personalized codes are the results of transforming these characteristics according to the smart contract coding rules, providing coding-level support for the execution of the smart contract in this scenario. Through this mapping and integration method, integrate the key information of different cross-chain interaction scenarios together to form an orderly and efficient scenario coding library, laying a solid foundation for subsequent matching of scenario compliance codes based on cross-chain interaction scenarios, decoupling, and optimizing the smart contract execution path, enabling the smart contract to quickly obtain the required coding information in different cross-chain interaction scenarios and improving the efficiency and accuracy of cross-chain interactions.

[0034] In a possible implementation manner, step S200 further includes:

[0035] Step S250: Decouple the smart contract according to adjustability to determine the solidified logic block and the codable logic block.

[0036] Step S260: for the encodable logic block, locate the adjustable logic interface and the schedulability, identify the adjustable conditions, and set the injection rules.

[0037] Step S270: According to the injection rule, scene matching is performed through the adjustable condition to determine the injection logic interface of the scene compliance coding.

[0038] Step S280: Based on the schedulability, correct the scene compliance coding and inject the encodable logic block.

[0039] Step S290: coupling the solidified logic block with the injected encodable logic block to determine the scenario smart contract.

[0040] Specifically, the adjustability of smart contracts is evaluated first. This evaluation involves an in-depth analysis of the smart contract code logic, execution process, and the relationship between different functional modules. Based on the evaluation results, the smart contract is decoupled into two key parts: the solidified logic block and the codable logic block. The solidified logic block contains the basic logic of the smart contract that is universal and stable. These logics usually do not change in different cross-chain interaction scenarios and are the basis for ensuring the stable operation of the core functions of the smart contract. For example, the basic algorithms for data encryption and identity authentication in the smart contract will be divided into the solidified logic block. The codable logic block is responsible for carrying those functions that need to be flexibly adjusted and customized according to the specific cross-chain interaction scenarios. For example, for specific transaction rules and data processing processes in different cross-chain interaction scenarios, these logics will vary from scenario to scenario, so they are classified into the codable logic block. Through this decoupling method, not only the adaptability of smart contracts in different scenarios is improved, but also the foundation for optimizing the contract execution path according to scenario requirements in the future.

[0041] Operate on the encodable logic blocks decoupled from the smart contracts. Through in-depth code parsing and logical analysis, accurately locate the adjustable logic interfaces and schedulable content therein. The adjustable logic interface is the key channel for the encodable logic block to interact with the external environment, determining how external information and instructions enter and affect the operation of the logic block; the schedulable content is the part within the encodable logic block that can be flexibly called and operated according to different scenarios and requirements, providing support for the adaptability of the smart contract. At the same time, clearly identify the adjustable conditions on which the effectiveness of the encodable logic block depends. These conditions define under what circumstances the logic block can operate normally and how to adjust its behavior under different conditions. In order to accurately inject the scenario-compliant coding into the encodable logic block, injection rules are set, covering specifications such as the timing, sequence, and method of coding injection, ensuring that the scenario-compliant coding can be effectively integrated with the encodable logic block, so that the smart contract can better adapt to different cross-chain interaction scenarios, and make full preparations for subsequent determination of scenario smart contracts and optimization of the execution path.

[0042] Carry out scenario matching work according to the previously set injection rules and in combination with the identified adjustable conditions. At this time, obtain the scenario-compliant coding corresponding to the current cross-chain interaction scenario from the scenario coding library, and at the same time analyze the adjustable conditions of the encodable logic block. These adjustable conditions are like filters, comparing the scenario-compliant coding with them to judge how the scenario-compliant coding should be adapted to the encodable logic block under different conditions. For example, if the adjustable conditions stipulate specific transaction types or data format requirements, it will be checked whether the scenario-compliant coding meets these conditions. Once the matching is successful, the injection logic interface suitable for this scenario-compliant coding can be determined. This injection logic interface is a specific location in the encodable logic block dedicated to receiving and processing the scenario-compliant coding, which determines how the scenario-compliant coding is integrated into the encodable logic block, and thus affects the function and execution path of the entire smart contract in the current cross-chain interaction scenario, ensuring that the smart contract can accurately integrate and utilize relevant coding information according to specific scenario requirements.

[0043] Based on the schedulable content in the encodable logic block, the scene compliance encoding obtained from the scene encoding library is corrected. The schedulable content provides an operation basis for the adjustment of the scene compliance encoding. According to the allowed operation scope and method of the schedulable, the adaptation of the scene compliance encoding to the current cross-chain interaction scene and the encodable logic block is checked. For example, if the schedulable content stipulates a specific order of data processing, and the data processing order in the scene compliance encoding does not match it, the encoding will be reordered according to the schedulable requirements. After correction, it is ensured that the scene compliance encoding can be seamlessly connected and work collaboratively with the encodable logic block. Subsequently, the corrected scene compliance encoding is accurately injected into the encodable logic block, making it a part of the encodable logic block and participating in the logical operation and function realization of the smart contract in the current cross-chain interaction scene, providing key support for generating the scene smart contract that meets the specific scene requirements.

[0044] In order to couple and solidify the logic block with the injected encodable logic block to determine the scene smart contract, first, with the help of a code parsing tool, the solidified logic block and the injected encodable logic block are deeply parsed respectively to clarify their respective functions, variables, and the dependencies between them. Using the characteristics of object-oriented programming, if the smart contract is written in the Solidity language, the solidified logic block and the encodable logic block are regarded as different class modules. Through ways such as class inheritance and composition, the new functions brought by the scene compliance encoding injected in the encodable logic block are organically integrated with the basic functions of the solidified logic block. For the function call relationship, the call stack is reorganized and a new call stack is established to ensure that starting from the entry function of the solidified logic block, the relevant functions in the injected encodable logic block can be smoothly called. At the same time, the scope of variables is reasonably adjusted to avoid conflicts and incorrect access. After the integration is completed, the coupled code is compiled using a smart contract compiler to generate bytecode and deployed to the corresponding blockchain test environment for testing. By simulating various cross-chain interaction scenes, the functional integrity, logical correctness, and compatibility with other blockchain components of the scene smart contract are checked. If problems are found, it is returned for modification until the scene smart contract that meets the requirements of the current cross-chain interaction scene is determined.

[0045] In a possible implementation manner, step S290 further includes:

[0046] Step S291: The scene smart contract is a temporary contract.

[0047] Step S292: When the cross-chain interaction scene execution ends, the scene smart contract is restored to the smart contract.

[0048] Specifically, in the process of optimizing the execution path of smart contracts based on cross-chain interactions, the temporary attributes of scenario smart contracts are clarified. It is a contract generated for a specific cross-chain interaction scenario, not a permanent smart contract architecture. Defining it as a temporary contract means that it only works during the operation of the current cross-chain interaction scenario. This temporary design enhances the flexibility and pertinence of smart contracts, and can quickly build and deploy corresponding scenario smart contracts based on different scenarios.

[0049] When all tasks of the cross-chain interaction scenario are completed, the scenario smart contract restoration mechanism is triggered. Based on the information recorded when the smart contract was previously decoupled, the scenario compliance code injected into the encodable logic block is removed to restore the encodable logic block to its initial state. Then, the solidified logic block and the restored encodable logic block are reintegrated to return the smart contract to the state when it was first read. Smart contracts can be ready to respond to the next different cross-chain interaction scenario at any time. Without changing its core architecture, they can efficiently realize the functional requirements in different scenarios by temporarily building and restoring scenario smart contracts, while ensuring the stability and versatility of smart contracts.

[0050] In a possible implementation, step S300 further includes:

[0051] Step S310: Determine the interaction intention based on the interaction chain and the interaction task.

[0052] Step S320: If the interaction intention is a complex intention, the interaction intention is parsed to determine N single intentions, wherein the minimum intention unit is used as a parsing standard.

[0053] Step S330: For the N single intentions, perform execution path determination and coupling processing based on the scenario smart contract to determine the pre-execution path.

[0054] Specifically, the interaction intention is determined based on the interaction chain and the interaction task. From the perspective of time and space, most of the actual interaction intentions are composite intentions, which means that they are composed of multiple complex sub-intentions intertwined with each other. In order to understand and process these intentions more clearly, they are divided into the smallest units. When determining the interaction intention, various types of information on the interaction chain are comprehensively considered, such as the status of different blockchains, data transmission records, and the specific operations and goals involved in the interaction task. For example, in an interaction task involving cross-chain asset transfer and identity authentication, from the spatial dimension, it is necessary to consider the impact of the geographical location and node distribution of different blockchains on the interaction; from the temporal dimension, it is necessary to consider factors such as the time limit for asset transfer and the timeliness of identity authentication, so as to determine the overall interaction intention.

[0055] If the determined interaction intention is a composite intention, it is deeply analyzed based on the smallest intention unit. This analysis process is similar to decomposing a complex task into a series of basic and indivisible subtasks. For example, in the above composite intention of cross-chain asset transfer and identity verification, the smallest intention units may include obtaining identity information, verifying the authenticity of identity, querying asset balances, initiating asset transfer requests, etc. Through this analysis method, N single intentions can be determined. These single intentions are more clear and specific, providing a clearer guidance for determining the subsequent execution path.

[0056] For these N single intentions, the execution path is determined and coupled based on the scenario smart contract. For each single intention, according to the rules and logics specified by the scenario smart contract, the corresponding execution path is determined. Then, considering the possible mutual relationships and influences among the single intentions, these execution paths are coupled. For example, in the scenario of asset transfer and identity verification, the execution path of identity verification needs to be completed before asset transfer, and the asset transfer operation can only be carried out after successful verification. Through this coupling process, the execution order and methods of each single intention can be comprehensively coordinated, and finally the pre-execution path is determined, laying a solid foundation for the efficient execution of the smart contract.

[0057] In a possible implementation manner, step S330 further includes:

[0058] Step S331: Determine N single intention paths and perform a first identification on the N single intention paths based on intention concurrency.

[0059] Step S332: According to the first identification, conduct a concurrent coupling game to determine the first-order coupling path, where the coupling integration and being integrated are used as the game goals, and the first-order coupling path includes M coupling paths, and M is a positive integer less than or equal to N.

[0060] Step S333: For the first-order coupling path, determine the pre-execution path through sequential game and integration.

[0061] Specifically, according to the rules and logics set by the scenario smart contract and the actual situation of cross-chain interaction, the execution paths for these N single-intentions are respectively determined. When determining the single-intention paths, factors such as the topological structure of the blockchain network, data transmission speed, and node processing capacity are comprehensively considered to ensure the rationality and feasibility of path planning. After the determination of the single-intention paths, the N single-intention paths are given a first identification based on intention concurrency. Intention concurrency mainly refers to whether there is a possibility of overlap or parallel execution in the execution time of different single-intentions. By deeply analyzing elements such as the execution conditions, required resources, and execution duration of each single-intention path, their concurrency is judged. For those single-intention paths that can be executed simultaneously without interference, they are marked as having high concurrency; for those single-intention paths that need to be executed sequentially in a specific order, they are marked as sequential execution. This first identification is recorded in a data structure using a specific coding or marking method, which facilitates further processing and optimization of the paths based on this in subsequent steps, laying a foundation for determining a more efficient execution path.

[0062] To achieve concurrent coupling game according to the first identification and determine the first-order coupling paths, first, a path relationship analysis model is established. Using this model, the N single-intention paths marked by the first identification are classified according to their concurrency characteristics, distinguishing the sets of paths that can be executed concurrently and those that need to be executed sequentially. For the set of paths that can be executed concurrently, the strategy of the greedy algorithm is adopted to find coupling opportunities. Taking coupling incorporation and being incorporated as the game goals, each path is traversed, and the benefits of its coupling with other paths are calculated. Here, the benefits can be indicators such as reducing execution time and resource consumption. For example, if the execution result of path A can directly be used as the input of path B, and this coupling can reduce the overall execution steps, then it is considered that there is a positive benefit in the coupling of these two paths. After calculating the coupling benefits among all concurrent paths, the coupling combination with the largest benefit is selected, and these mutually coupled paths are formed into a coupling path unit. This process is repeated until no coupling combination with positive benefits can be found. These coupling path units together constitute the first-order coupling paths. In this process, the number M of the formed coupling paths is strictly recorded to ensure that M is a positive integer less than or equal to N, and finally, the first-order coupling paths containing M coupling paths are determined.

[0063] After determining the first-order coupling paths, analyze the execution order and mutual dependencies among the coupling paths in the first-order coupling paths to carry out a sequential game. In this process, simulate different execution orders and evaluate the execution efficiency, resource consumption of the smart contract, and its impact on the overall interaction task under each order. For example, the execution results of some coupling paths are necessary conditions for the execution of subsequent other paths, or although concurrent execution of some paths can speed up part of the process, it may lead to resource competition and affect the overall efficiency. According to the simulation evaluation results, select the optimal execution order and combination method for integration. During the integration process, factors such as the state of the blockchain network, data transmission delay, and the resource requirements of each path will be comprehensively considered. For closely related coupling paths, they will be merged or the connection between them will be optimized to reduce the loss in the intermediate links. Through such sequential game and integration operations, finally determine a pre-execution path that is most suitable for the current cross-chain interaction scenario and smart contract, ensuring that the smart contract can operate efficiently and stably during subsequent execution and meet the requirements of the interaction task.

[0064] In a possible implementation manner, step S300 further includes:

[0065] Step S340: Traverse the pre-execution path to locate the path risk window based on the mutual trust of interactive execution.

[0066] Step S350: If the risk window is empty, perform cross-chain management based on the interactive task using the pre-execution path.

[0067] Specifically, start traversing and checking each link of the pre-execution path, and judge whether there are risks in the path based on the mutual trust during the interactive execution. This mutual trust involves multiple aspects such as the trust level among the parties involved in the blockchain interaction, the security of data transmission, and the reliability of the execution logic of the smart contract. For example, in some segments of the path execution, if it involves data interaction between different blockchains, due to unreliable nodes or interference during data transmission, the mutual trust level may not be sufficient. At this time, these segments need to be locked to ensure the non-regretfulness of their execution, that is, strictly execute according to the established rules and logic of the smart contract to prevent unexpected situations from causing execution errors or transaction failures. In this way, accurately locate the risk windows in the pre-execution path, and these risk windows represent the parts of the path with potential risks.

[0068] If it is found that the risk window is empty after traversing the pre-execution path, it means that the pre-execution path is relatively safe and reliable under the current interaction environment and smart contract logic. At this time, the cross-chain management work based on the interaction task will be directly carried out based on this pre-execution path. According to the specific requirements of the interaction task, coordinate the interaction operations between each blockchain to ensure the smooth progress of tasks such as accurate data transmission and secure asset transfer, and achieve an efficient cross-chain interaction process.

[0069] In a possible implementation manner, step S350 further includes:

[0070] Step S351: If the risk window is non-empty, introduce a time lock, where the time lock is an interaction without regret lock based on the consensus mechanism.

[0071] Step S352: Perform locking trigger and unlocking management of the path execution process for the pre-execution path based on the window boundaries of each path risk window.

[0072] Specifically, when performing a risk assessment on the pre-execution path and finding that the risk window is non-empty, a time lock mechanism is introduced to ensure the safety and stability of cross-chain interactions. This mechanism is based on the consensus mechanism, which ensures that each node in the blockchain network reaches a consensus on the interaction operation. The time lock utilizes this consensus to achieve an interaction without regret lock. During the cross-chain interaction process, there may be risks such as data inconsistency and malicious tampering among different nodes, and the interaction without regret lock feature of the time lock can effectively address these issues. Once an interaction operation involving the risk window is locked by the time lock, it means that the operation is fixed after consensus confirmation and cannot be changed or revoked at will. For example, in the scenario of cross-chain asset transfer, if there is a risk in a certain link of the pre-execution path, the time lock will lock the relevant asset transfer operation to ensure that the assets are not transferred incorrectly or repeatedly, protecting the rights and interests of all parties in the interaction and laying a foundation for the subsequent safe execution of the pre-execution path.

[0073] After determining the pre-execution path and locating the risk window, if the path risk window is non-empty and a time lock has been introduced, based on the window boundaries of each path risk window, fine control is exercised over the execution process of the pre-execution path. The window boundaries clearly define the start and end ranges of the risk area. Based on this, when the pre-execution path reaches the start boundary of the risk window, a locking operation is triggered. This locking, relying on the interactive no-regret locking feature of the time lock under the consensus mechanism, pauses the advancement of the pre-execution path in the risk area, preventing potential risks from affecting the accuracy and security of the overall interaction. For example, if the path risk window involves an area where data transmission may be tampered with, the locking operation can prevent the data from being mishandled during this risk period. When the execution process reaches the end boundary of the risk window, the pre-execution path is unlocked according to the settings of the time lock and the confirmation of the consensus mechanism, allowing it to continue with the subsequent part. Through this precise locking trigger and unlocking management, it is ensured that the pre-execution path advances smoothly on the premise of controllable risks, effectively avoiding the adverse effects of risks on cross-chain interaction and smart contract execution, and ensuring the stability and reliability of the entire cross-chain interaction process.

[0074] In a possible implementation manner, step S300 further includes:

[0075] Step S360: Trace the interactive flow data of the path execution, where the interactive flow data identifies the source block.

[0076] Step S370: Perform on-chain storage and association of the interactive flow data based on the source block.

[0077] Specifically, trace the interactive flow data during the path execution. When a smart contract conducts cross-chain interaction operations based on the pre-execution path, a series of data interaction activities will occur in the blockchain network. With the help of the listening mechanism of blockchain nodes and the event tracking function built into the smart contract, these interactive data are captured in real time. During the capture process, by embedding specific identification fields in the data structure, each piece of interactive flow data is marked with source block information. For example, in the cross-chain interaction scenario between Ethereum and Bitcoin, when it comes to asset transfer, the interactive data of each asset transfer will be recorded, and at the same time, key information such as the hash value and block height of the source block where the data is generated will be embedded as an identifier into the interactive flow data. This can ensure the traceability of the source of the interactive flow data throughout the cross-chain interaction process, providing accurate basic data support for subsequent data analysis, supervision, and troubleshooting of abnormal situations.

[0078] After the smart contract completes the interaction operation according to the pre-execution path and generates interaction flow data, these data are stored on the corresponding blockchain according to the source block information identified by each interaction flow data. For example, if the interaction flow data comes from a specific block on the Ethereum blockchain, using the storage interface and data writing mechanism of the blockchain, the interaction flow data is stored in the relevant storage location of the Ethereum blockchain according to the established format and rules. At the same time, in order to achieve effective management and traceability of the data, an association relationship between the interaction flow data and the source block is established during the storage process. This association is achieved by adding a pointer to the source block in the data storage structure, or marking the storage location of the corresponding interaction flow data in the relevant records of the source block. Through this method of on-chain storage and association based on the source block, it is convenient to comprehensively analyze, audit, and supervise the cross-chain interaction process in the future, providing a strong guarantee for the stable operation of the smart contract and the reliability of cross-chain interaction.

[0079] Embodiment 2, based on the same inventive concept as the method for optimizing the execution path of a smart contract based on cross-chain interaction in the foregoing embodiment, as Figure 2 shown, the present application provides a system for optimizing the execution path of a smart contract based on cross-chain interaction. The system in the embodiments of the present application and the method embodiments are based on the same inventive concept. Among them, the system includes:

[0080] A cross-chain interaction scenario determination module 10, configured to determine a cross-chain interaction scenario based on an interaction chain and an interaction task, and read a smart contract, where the interaction chain is at least a double chain.

[0081] A scenario smart contract determination module 20, configured to introduce a scenario coding library, match a scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract, and inject the scenario compliance coding into a codable logic block to determine a scenario smart contract, where decoupling is to determine a fixed logic block and a codable logic block.

[0082] An interaction consensus locking module 30, configured to use the scenario smart contract to determine a pre-execution path under the intention drive, and introduce a time lock to perform interaction consensus locking on the path risk window of the pre-execution path, where the pre-execution path is determined by coupling the composite intention parsing and single intention path optimization of the interaction task.

[0083] Further, the system is also used to implement the following functions:

[0084] Statistical scenario sets based on cross-chain interaction; traverse the scenario sets to determine personalized interaction characteristics, where the scenario sets correspond to the personalized interaction characteristics; interact with the coding rules of the smart contract to convert the personalized interaction characteristics to determine personalized coding; map and integrate the scenario set-personalized interaction characteristic-personalized coding to construct the scenario coding library.

[0085] Furthermore, the system is also used to implement the following functions:

[0086] According to the adjustability, the smart contract is decoupled to determine the solidified logic block and the codable logic block; for the codable logic block, the adjustable logic interface and the schedulability are located, and the adjustable conditions are identified and the injection rules are set; according to the injection rules, the scene is matched through the adjustable conditions to determine the injection logic interface of the scene compliance coding; based on the schedulability, the scene compliance coding is corrected and injected into the codable logic block; the solidified logic block and the injected codable logic block are coupled to determine the scene smart contract.

[0087] Furthermore, the system is also used to implement the following functions:

[0088] The scenario smart contract is a temporary contract; when the cross-chain interaction scenario is executed, the scenario smart contract is restored to the smart contract.

[0089] Furthermore, the system is also used to implement the following functions:

[0090] Based on the interaction chain and the interaction task, the interaction intention is determined; if the interaction intention is a composite intention, the interaction intention is parsed to determine N single intentions, wherein the minimum intention unit is used as the parsing standard; for the N single intentions, the execution path determination and coupling processing based on the scenario smart contract are performed to determine the pre-execution path.

[0091] Furthermore, the system is also used to implement the following functions:

[0092] Determine N single-intention paths, and perform a first identification on the N single-intention paths based on intent concurrency; based on the first identification, perform a concurrent coupling game to determine a first-order coupling path, wherein coupling integration and being integrated are used as game goals, and the first-order coupling path includes M coupling paths, where M is a positive integer less than or equal to N; for the first-order coupling path, determine the pre-execution path by performing a sequential game and integration.

[0093] Furthermore, the system is also used to implement the following functions:

[0094] The pre-execution path is traversed to locate the path risk window based on the mutual trust of interactive execution; if the risk window is empty, the pre-execution path is used to perform cross-chain management based on the interactive task.

[0095] Furthermore, the system is also used to implement the following functions:

[0096] If the risk window is non-empty, introduce a time lock, where the time lock is an interactive regret-free lock based on the consensus mechanism; perform locking trigger and unlocking management of the path execution process for the pre-execution path based on the window boundaries of each path risk window.

[0097] Further, the system is also used to implement the following functions:

[0098] Track the interactive flow data of path execution, where the interactive flow data identifies the source block; perform on-chain storage and association of the interactive flow data based on the source block.

[0099] It should be noted that the above order of the embodiments of the present application is only for description and does not represent the superiority or inferiority of the embodiments. And the above specific embodiments of this specification have been described. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0100] The above are only the preferred embodiments of the present application and are not intended to limit the present application. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

[0101] This specification and the drawings are only exemplary descriptions of the present application and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of the present application. Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the present application and its equivalent technologies, the present application is intended to include these changes and modifications.

Claims

1. A smart contract execution path optimization method based on cross-chain interaction, characterized in that: The method comprises: Determine the cross-chain interaction scenario with the interactive chain and the interactive task, and read the smart contract, wherein the interactive chain is at least a dual chain; Introduce a scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the codable logic block, and determine the scenario smart contract, wherein the decoupling is to determine the solidified logic block and the codable logic block; The scenario smart contract is used to determine the intent-driven pre-execution path, and a time lock is introduced to perform interactive consensus locking of the path risk window on the pre-execution path, wherein the pre-execution path is determined based on the coupling of composite intent analysis of interactive tasks and single intent path optimization.

2. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 1, characterized in that: Introduced the scene coding library, including: Statistics of scenarios based on cross-chain interactions; Traversing the scene set to determine a personalized interaction characteristic, wherein the scene set corresponds to the personalized interaction characteristic; Interact with the coding rules of the smart contract, convert the personalized interaction characteristics, and determine the personalized coding; The scene set-personalized interaction characteristics-personalized coding are mapped and integrated to construct the scene coding library.

3. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 1, characterized in that: Decoupling the smart contract and injecting the scenario compliance code into the encodable logic block to determine the scenario smart contract, including: According to adjustability, the smart contract is decoupled to determine the solidified logic block and the codable logic block; For the encodable logic block, locate the adjustable logic interface and the schedulability, identify the adjustable conditions, and set the injection rules; According to the injection rule, scene matching is performed through the adjustable condition to determine the injection logic interface of the scene compliance coding; Based on the schedulability, the scene compliance coding is corrected and injected into the encodable logic block; The solidified logic block is coupled with the injected codable logic block to determine the scenario smart contract.

4. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 3, characterized in that: The scenario smart contract is a temporary contract; When the cross-chain interaction scenario is executed, the scenario smart contract is restored to the smart contract.

5. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 1, characterized in that: Determine the intent-driven pre-execution path, including: Determining interaction intention based on the interaction chain and the interaction task; If the interaction intention is a composite intention, the interaction intention is parsed to determine N single intentions, wherein the minimum intention unit is used as a parsing standard; For the N single intentions, execution path determination and coupling processing are performed based on the scenario smart contract to determine the pre-execution path.

6. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 5, characterized in that: Performing execution path determination and coupling processing based on the scenario smart contract, including: Determine N single-intent paths, and first identify the N single-intent paths based on intent concurrency; According to the first identifier, a concurrent coupling game is performed to determine a first-order coupling path, wherein coupling integration and being integrated are used as game objectives, and the first-order coupling path includes M coupling paths, where M is a positive integer less than or equal to N; For the first-order coupling path, the pre-execution path is determined by performing sequential game and integration.

7. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 1, characterized in that: Interactive consensus locking of the path risk window is performed on the pre-execution path, including: Traversing the pre-execution path to locate the path risk window with mutual trust of interactive execution; If the path risk window is empty, the pre-execution path is used to perform cross-chain management based on the interactive task.

8. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 7, characterized in that: If the path risk window is not empty, a time lock is introduced, wherein the time lock is an interactive no-regret lock based on a consensus mechanism; Based on the window boundary of each path risk window, the locking triggering and unlocking management of the path execution process is performed on the pre-execution path.

9. The method for optimizing the execution path of a smart contract based on cross-chain interaction according to claim 1, characterized in that: After determining the intent-driven pre-execution path, it includes: Interaction flow data of the trace path execution, wherein the interaction flow data identifies active blocks; The interactive stream data is stored and associated on-chain based on the source block.

10. Smart contract execution path optimization system based on cross-chain interaction, characterized by: The system is used to implement the smart contract execution path optimization method based on cross-chain interaction according to any one of claims 1 to 9, and the system includes: A cross-chain interaction scenario determination module, used to determine the cross-chain interaction scenario based on the interaction chain and the interaction task, and read the smart contract, wherein the interaction chain is at least a dual chain; A scenario smart contract determination module is used to introduce a scenario coding library, match the scenario compliance coding based on the cross-chain interaction scenario, decouple the smart contract and inject the scenario compliance coding into the codable logic block, and determine the scenario smart contract, wherein the decoupling is to determine the solidified logic block and the codable logic block; The interactive consensus locking module is used to determine the intent-driven pre-execution path with the scenario smart contract, and introduce a time lock to perform interactive consensus locking of the path risk window on the pre-execution path, wherein the pre-execution path is determined based on the coupling of composite intent analysis and single intent path optimization of interactive tasks.