Cross-chain transaction processing method and device, equipment and medium

By receiving and processing cross-chain transaction requests on the blockchain, determining relevant smart contracts and contract interfaces, and generating global transaction identifiers, the problem of complexity of cross-chain transactions is solved, and the atomicity and security of cross-chain transactions are realized.

CN119629250AActive Publication Date: 2025-03-14RENMIN UNIVERSITY OF CHINA
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202411818276.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-11
Publication Date
2025-03-14
Estimated Expiration
2044-12-11

AI Technical Summary

Technical Problem

The prior art cannot effectively implement the processing of cross-chain transaction requests, especially when it involves smart contract calls on different blockchains.

Method used

By receiving cross-chain transaction requests on the source blockchain, the relevant smart contracts, contract interfaces and target blockchains are determined, the global transaction identifier is generated, and transactions are processed according to the contract call relationship to ensure the atomicity of cross-chain transactions.

Benefits of technology

It realizes effective processing of cross-chain transaction requests, ensures the atomicity and security of cross-chain transactions, and supports complex call scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119629250A_ABST
    Figure CN119629250A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of block chains, and discloses a cross-chain transaction processing method and device, equipment and a medium, a source block chain can determine a target block chain, a smart contract, a contract interface, contract calling data and a smart contract calling relationship involved in a cross-chain transaction according to a cross-chain transaction request of a user; generating a global transaction identifier corresponding to the cross-chain transaction request, calling a smart contract to perform transaction processing to obtain a first processing result, correspondingly storing the global transaction identifier and the first processing result, and sending the global transaction identifier and the first processing result to a target block chain, and enabling the target block chain to execute cross-chain transaction processing to obtain a second processing result, and correspondingly storing the second processing result and the global transaction identifier. And when the source block chain determines that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the source block chain determines that the global processing result is successful, so that the processing of the cross-chain transaction request is effectively realized.
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 in particular to a cross-chain transaction processing method, device, equipment and medium. Background Art

[0002] Smart contracts are generally programs written in programming languages ​​such as Solidity, Vyper, and Go, and can be run on the blockchain. They can be applied in scenarios such as supply chain management, financial services, and healthcare.

[0003] Users can initiate transaction requests related to smart contracts on the blockchain. When the terms of the smart contract are met, the smart contract will be automatically executed without the intervention of a third party. Related technologies can call multiple smart contracts on the same blockchain to execute related transactions based on user transaction requests to meet user needs.

[0004] However, when the user's transaction request is a cross-chain transaction request, that is, it involves calling smart contracts on different blockchains to perform transaction processing, the operations involved are more complicated, and the relevant technology cannot effectively implement the processing of cross-chain transaction requests. Summary of the invention

[0005] The present invention provides a cross-chain transaction processing method, device, equipment and medium to solve the defect that the related technology cannot effectively implement the processing of cross-chain transaction requests, and effectively implement the processing of cross-chain transaction requests.

[0006] In a first aspect, the present invention provides a cross-chain transaction processing method, which is applied to a source blockchain; the method comprises: The source blockchain receives a cross-chain transaction request sent by a user, wherein the cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data; The source blockchain determines the first smart contract, the first contract interface, the target blockchain, the second smart contract, and the second contract interface related to the cross-chain transaction according to the blockchain identifier, the smart contract identifier, and the contract interface information in the cross-chain transaction request, and generates a corresponding global transaction identifier according to the cross-chain transaction request; wherein the first smart contract and the second smart contract are deployed on the source blockchain and the target blockchain, respectively, and the first contract interface and the second contract interface are the contract interfaces of the first smart contract and the second smart contract, respectively; The source blockchain determines that the global lock state of the first smart contract is unlocked, then changes the global lock state of the first smart contract from unlocked to locked, and calls the first smart contract to perform transaction processing according to the smart contract call relationship, the first contract interface and the contract call data to obtain a first processing result, and correspondingly saves the first processing result and the global transaction identifier; The source blockchain sends the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, saves the second processing result and the global transaction identifier accordingly, and returns the corresponding second processing result and the global transaction identifier to the source blockchain when it is determined that the second processing result is successful; If the source blockchain determines that the first processing result and the second processing result corresponding to the global transaction identifier are successful, then the global processing result is determined to be successful.

[0007] Optionally, the first contract interface includes a locking interface and a business interface; The calling the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data includes: The source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the locking interface in the first contract interface, and calls the first smart contract for transaction processing to obtain the first processing result according to the smart contract calling relationship, the business interface in the first contract interface and the contract calling data.

[0008] Optionally, the first contract interface also includes an unlocking interface; After determining that the global processing result is successful, the method further includes: The source blockchain adjusts the local lock state of the first smart contract from locked to unlocked through the unlocking interface, and adjusts the global lock state of the first smart contract from locked to unlocked.

[0009] Optionally, the first contract interface also includes a snapshot interface and a recovery interface; Before the source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the lock interface in the first contract interface, the method further includes: The source blockchain backs up the contract data of the first smart contract through the snapshot interface to obtain backup data, and saves the backup data; After obtaining the first processing result, the method further includes: If the source blockchain determines that the first processing result or the transaction processing result of the target blockchain is a failure, the global processing result is determined to be a failure, and the first smart contract is rolled back based on the recovery interface and the backup data, and the local lock state of the first smart contract is adjusted from locked to unlocked through the unlocking interface, and the global lock state of the first smart contract is adjusted from locked to unlocked.

[0010] Optionally, the source blockchain determines that the transaction processing result of the target blockchain is a failure, including: When the source blockchain determines that the transaction processing result sent by the target blockchain is a failure, the transaction processing result of the target blockchain is determined to be a failure; or, When the source blockchain sends the cross-chain transaction request to the target blockchain, it starts timing and records the timing duration; if the transaction processing result sent by the target blockchain is not received before the timing duration exceeds the preset duration threshold, it is determined that the transaction processing of the target blockchain has timed out, and the transaction processing result of the target blockchain is determined to be a failure.

[0011] Optionally, after obtaining the first processing result, the method further includes: When the source blockchain determines that the first processing result is successful, the corresponding first processing result and the global transaction identifier are sent to the target blockchain, so that the target blockchain: when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result is determined to be successful.

[0012] Optionally, the blockchain identifier includes a chain identifier of the source blockchain and a chain identifier of the target blockchain; The first smart contract and the second smart contract each include at least one smart contract; The first contract interface includes the contract interface of each smart contract in the first smart contract, and the second contract interface includes the contract interface of each smart contract in the second smart contract; The smart contract identifier includes the contract address of each smart contract in the first smart contract and the contract address of each smart contract in the second smart contract; The smart contract calling relationship is the calling relationship between all the smart contracts.

[0013] In a second aspect, the present invention provides a cross-chain transaction processing device, which is applied to a source blockchain; the device comprises: A receiving unit, configured to receive a cross-chain transaction request sent by a user, wherein the cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data; A first determination unit is configured to determine, according to the blockchain identifier, the smart contract identifier, and the contract interface information in the cross-chain transaction request, a first smart contract, a first contract interface, a target blockchain, a second smart contract, and a second contract interface related to the cross-chain transaction; and generate a corresponding global transaction identifier according to the cross-chain transaction request; A generating unit, configured to generate a corresponding global transaction identifier according to the cross-chain transaction request; a modification unit, configured to determine that the global lock state of the first smart contract is unlocked, and then modify the global lock state of the first smart contract from unlocked to locked; A calling unit, configured to call the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data; A storage unit, used for correspondingly storing the first processing result and the global transaction identifier; A sending unit, configured to send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, correspondingly saves the second processing result and the global transaction identifier, and when it is determined that the second processing result is successful, returns the corresponding second processing result and the global transaction identifier to the source blockchain; The second determining unit is configured to determine that if the first processing result and the second processing result corresponding to the global transaction identifier are successful, then determine that the global processing result is successful.

[0014] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to enable a computer to execute the cross-chain transaction processing method of the first aspect or any corresponding embodiment thereof.

[0015] The cross-chain transaction processing method, device, equipment and medium provided by the present invention, the source blockchain can receive a cross-chain transaction request sent by a user, determine the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction according to the cross-chain transaction request, generate a global transaction identifier corresponding to the cross-chain transaction request, perform cross-chain transaction processing according to the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction to obtain a first processing result, save the global transaction identifier and the first processing result accordingly, send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain executes the cross-chain transaction processing to obtain a second processing result and saves the second processing result and the global transaction identifier accordingly, when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result of the cross-chain transaction request is determined to be successful, and the processing of the cross-chain transaction request is effectively realized. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0017] Figure 1 A flowchart of a cross-chain transaction processing method provided by an embodiment of the present invention; Figure 2 A schematic diagram of the structure of a cross-chain transaction processing device provided by an embodiment of the present invention; Figure 3 A schematic diagram of the structure of a computer device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0018] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0019] Combine the following Figure 1 The cross-chain transaction processing method of the present invention is described.

[0020] like Figure 1 As shown, this embodiment proposes a first cross-chain transaction processing method, which is applied to the source blockchain. The method may include the following steps: S101. The source blockchain receives a cross-chain transaction request sent by a user. The cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data.

[0021] The source blockchain is the blockchain that directly receives the cross-chain transaction request sent by the user. It is understandable that the user can upload the cross-chain transaction request to the source blockchain, and the source blockchain processes the relevant cross-chain transaction based on the cross-chain transaction request to meet the user's business processing needs.

[0022] Specifically, the blockchain identifier may include the chain identifiers of each blockchain involved in this cross-chain transaction.

[0023] Among them, the smart contract identifier may include the contract address of each smart contract involved in this cross-chain transaction.

[0024] Specifically, the smart contract call relationship can be the call relationship between the smart contracts involved in this cross-chain transaction. The smart contract call relationship can record the cascade call of the smart contracts involved in this cross-chain transaction in a tree structure. Each node on the tree represents a cross-chain business smart contract involved in the cross-chain transaction, and its child nodes represent the cross-chain business smart contracts it calls. The nodes record specific cross-chain business smart contract call information.

[0025] The contract interface information may include relevant information of the contract interface of each smart contract involved in this cross-chain transaction. The source blockchain may determine the contract interface of the relevant smart contract based on the contract interface information.

[0026] Specifically, the contract call data may be the call data of the smart contract, which may specifically include relevant parameter information required for calling the smart contract interface. In this embodiment, the contract interface of the smart contract may be called based on the contract call data, so that the contract interface of the smart contract performs corresponding transaction processing.

[0027] Optionally, the blockchain identifier includes a chain identifier of a source blockchain and a chain identifier of a target blockchain; The first smart contract and the second smart contract each include at least one smart contract; The first contract interface includes the contract interface of each smart contract in the first smart contract, and the second contract interface includes the contract interface of each smart contract in the second smart contract; The smart contract identifier includes the contract address of each smart contract in the first smart contract and the contract address of each smart contract in the second smart contract; The smart contract calling relationship is the calling relationship between all smart contracts.

[0028] Optionally, the cross-chain transaction request may also include timestamp and routing information.

[0029] Optionally, a transaction registration interface may be provided in the source blockchain, in which case the user may upload the cross-chain transaction request to the transaction registration interface in the source blockchain, triggering the transaction registration interface to start transaction processing.

[0030] In actual applications, users on the source blockchain and the target blockchain can exchange chain identification information, contract information, and their own routing information of the chain they belong to through the communication method provided by the cross-chain architecture, such as the blockchain identification, smart contract identification, smart contract call relationship, contract interface information, and contract call data required in the cross-chain transaction request, and prepare to start the cross-chain transaction. For example, users on the two chains exchange information such as blockchain identification and smart contract identification through peer-to-peer (P2P) communication. For another example, there is a relay chain in the cross-chain architecture that records information such as blockchain identification and smart contract identification on both chains, allowing users on both sides to query on the relay chain.

[0031] S102. The source blockchain determines the first smart contract, the first contract interface, the target blockchain, the second smart contract, and the second contract interface related to the cross-chain transaction according to the blockchain identifier, the smart contract identifier, and the contract interface information in the cross-chain transaction request. The first smart contract and the second smart contract are deployed on the source blockchain and the target blockchain, respectively, and the first contract interface and the second contract interface are the contract interfaces of the first smart contract and the second smart contract, respectively.

[0032] Specifically, after receiving the cross-chain transaction request, the source blockchain can parse the cross-chain transaction request to obtain the blockchain identifier, smart contract identifier, smart contract call relationship, contract interface information and contract call data carried in the cross-chain transaction request. Afterwards, the source blockchain can determine all blockchains and smart contracts involved in the cross-chain transaction based on the blockchain identifier and smart contract identifier, including the target blockchain, the first smart contract and the second smart contract.

[0033] Among them, the target blockchain is the blockchain that the source blockchain needs to interact with to execute cross-chain transactions.

[0034] Specifically, the source blockchain can also determine the contract interface of the first smart contract, i.e., the first contract interface, and determine the contract interface of the second smart contract, i.e., the second contract interface, according to the contract interface information. The source blockchain can also determine the calling relationship between the smart contracts on the source blockchain and the target blockchain, i.e., the calling relationship between the first smart contract and the second smart contract, according to the calling relationship of the smart contracts.

[0035] Optionally, when a transaction registration interface is set in the source blockchain, the transaction registration interface can receive and parse the cross-chain transaction request, determine and record the first smart contract, first contract interface, target blockchain, second smart contract and second contract interface related to the cross-chain transaction.

[0036] S103. The source blockchain generates a corresponding global transaction identifier according to the cross-chain transaction request.

[0037] Specifically, the source blockchain can generate a globally unique cross-chain transaction identifier, i.e., a global transaction identifier, based on the cross-chain transaction request and the related information it carries. The global transaction identifier can be used as the identifier of this cross-chain transaction on the source blockchain and the target blockchain, and can be used for indexing when querying cross-chain transaction data and execution results.

[0038] Specifically, the source blockchain can generate a global transaction identifier corresponding to the cross-chain transaction request based on a universally unique identifier (UUID).

[0039] S104. If the source blockchain determines that the global lock state of the first smart contract is unlocked, the global lock state of the first smart contract is changed from unlocked to locked.

[0040] Specifically, for smart contracts that need to participate in cross-chain transaction processing, this embodiment can set a global lock for it, and set a variable for identifying the global lock state, and identify the global lock state through the parameter value of the variable. It should be noted that the global lock state of the smart contract can include locked and unlocked.

[0041] Specifically, after determining the first smart contract, the source blockchain can obtain the global lock status of each smart contract in the first smart contract. If the global lock status of each smart contract in the first smart contract is unlocked, it can be determined that the cross-chain resources of each smart contract in the first smart contract are not occupied, and the global lock status of each smart contract in the first smart contract is adjusted to locked, so that this cross-chain transaction can occupy the cross-chain resources of each smart contract in the first smart contract separately, and perform subsequent cross-chain transaction processing on the first smart contract, avoiding other cross-chain transactions from calling any smart contract in the first smart contract for cross-chain transaction processing during this cross-chain transaction processing.

[0042] It can be understood that after the source blockchain obtains the global lock status of the first smart contract, if it is determined that the global lock status of any smart contract in the first smart contract is locked, it can be determined that the cross-chain resources of the first smart contract are occupied and the first smart contract cannot participate in this cross-chain transaction. At this time, the source blockchain can stop executing this cross-chain transaction and can directly determine that the execution result of the cross-chain transaction is a failure.

[0043] S105. The source blockchain calls the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data.

[0044] Specifically, after changing the global lock status of each smart contract in the first smart contract from unlocked to locked, the source blockchain can call each smart contract in the first smart contract to perform business processing according to the smart contract call relationship, the first contract interface and the contract call data to obtain a first processing result.

[0045] It should be noted that the first processing result can be success or failure. It is understandable that when the processing result of each smart contract in the first smart contract is success, the first processing result is success. When the processing result of any smart contract in the first smart contract is failure, the first processing result is failure.

[0046] S106. Correspondingly save the first processing result and the global transaction identifier.

[0047] Specifically, the source blockchain can save the first processing result and the global transaction identifier in correspondence.

[0048] S107. The source blockchain sends the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, saves the second processing result and the global transaction identifier accordingly, and when it is determined that the second processing result is successful, returns the corresponding second processing result and the global transaction identifier to the source blockchain.

[0049] It should be noted that, in the process where the target blockchain performs transaction processing according to the cross-chain transaction request to obtain the second processing result, except that a new global transaction identifier is no longer generated according to the cross-chain transaction request, the other steps can refer to the process where the source blockchain performs transaction processing according to the cross-chain transaction request to obtain the first processing result.

[0050] Among them, after receiving the cross-chain transaction request and the global transaction identifier, the target blockchain can parse the cross-chain transaction request to obtain the blockchain identifier, smart contract identifier, smart contract call relationship, contract interface information and contract call data carried in the cross-chain transaction request. Afterwards, the target blockchain can determine the first smart contract, the first contract interface, the target blockchain, the second smart contract and the second contract interface related to the cross-chain transaction according to the blockchain identifier, the smart contract identifier and the contract interface information, and obtain the global lock state of each smart contract in the second smart contract. When it is determined that the global lock state of each smart contract in the second smart contract is unlocked, the global lock state of each smart contract in the second smart contract is changed from unlocked to locked, and according to the smart contract call relationship, the second contract interface and the contract call data, each smart contract in the second smart contract is called to perform transaction processing to obtain the second processing result, and the second processing result and the global transaction identifier are correspondingly saved.

[0051] It can be understood that after the target blockchain obtains the global lock status of each smart contract in the second smart contract, if it is determined that the global lock status of any smart contract in the second smart contract is locked, it can be determined that the cross-chain resources of the second smart contract are occupied and the second smart contract cannot participate in this cross-chain transaction. At this time, the target blockchain can stop executing this cross-chain transaction and can directly determine that the execution result of the cross-chain transaction is a failure.

[0052] S108. If the source blockchain determines that the first processing result and the second processing result corresponding to the global transaction identifier are successful, then the global processing result is determined to be successful.

[0053] Specifically, the source blockchain can determine that the global processing result is successful when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are both successful.

[0054] Optionally, when the source blockchain determines that the first processing result or the second processing result corresponding to the global transaction identifier is a failure, the global processing result is determined to be a failure.

[0055] The cross-chain transaction processing method proposed in this embodiment is that the source blockchain can receive a cross-chain transaction request sent by a user, determine the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction according to the cross-chain transaction request, generate a global transaction identifier corresponding to the cross-chain transaction request, perform cross-chain transaction processing according to the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction to obtain a first processing result, save the global transaction identifier and the first processing result accordingly, send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain executes the cross-chain transaction processing to obtain a second processing result and saves the second processing result and the global transaction identifier accordingly. When it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result of the cross-chain transaction request is determined to be successful, and the processing of the cross-chain transaction request is effectively realized.

[0056] based on Figure 1 This embodiment proposes a second cross-chain transaction processing method, in which the first contract interface includes a locking interface and a business interface. At this time, step S105 includes: The source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the locking interface in the first contract interface, and calls the first smart contract for transaction processing to obtain a first processing result according to the smart contract calling relationship, the business interface in the first contract interface and the contract calling data.

[0057] Specifically, this embodiment can set a local lock for the smart contract on the blockchain, and set a variable for identifying the local lock state, and identify the local lock state by the parameter value of the variable. It should be noted that the local lock state of the smart contract can include locked and unlocked. When the local lock state of the smart contract is locked, it means that the blockchain is processing transactions on the smart contract. When the local lock state of the smart contract is unlocked, it means that the blockchain is not processing transactions on the smart contract.

[0058] Specifically, the source blockchain can first obtain the local lock status of each smart contract in the first smart contract. When it is determined that the local lock status of each smart contract in the first smart contract is unlocked, it means that each smart contract in the first smart contract is not currently involved in other transaction processing. The source blockchain can currently perform transaction processing on each smart contract in the first smart contract. At this time, the source blockchain can adjust the local lock status of each smart contract in the first smart contract from unlocked to locked. This cross-chain transaction can occupy the chain resources of each smart contract in the first smart contract separately, and perform subsequent transaction processing on each smart contract in the first smart contract, so as to avoid other transactions calling any smart contract in the first smart contract for transaction processing during this transaction processing.

[0059] Specifically, the source blockchain can call each smart contract in the first smart contract to perform transaction processing based on the smart contract calling relationship, the business interface in the first contract interface, and the contract calling data.

[0060] Optionally, the first contract interface also includes an unlocking interface. After step S108, the above method may further include: The source blockchain adjusts the local lock state of the first smart contract from locked to unlocked through the unlocking interface, and adjusts the global lock state of the first smart contract from locked to unlocked.

[0061] It should be noted that after completing the cross-chain transaction processing, the source blockchain can adjust the local lock state and the global lock state of each smart contract in the first smart contract to unlock, so as to release the occupation of the chain resources of each smart contract in the first smart contract, so that each smart contract in the first smart contract can participate in other transaction processing normally.

[0062] It is understandable that the second contract interface of the second smart contract on the target blockchain may also include a locking interface, a business interface, and an unlocking interface. During the execution of this cross-chain transaction, the target blockchain may also perform resource locking, contract calling, and resource release for each smart contract in the second smart contract.

[0063] The cross-chain transaction processing method proposed in this embodiment locks the resources in the cross-chain transaction at the contract granularity, designs a double-layer locking mechanism of local lock and global lock, and can quickly determine whether the cross-chain business smart contract involved meets the execution conditions before the cross-chain transaction is executed, flexibly lock and release resources, improve processing efficiency, and effectively reduce the impact of cross-chain transactions on non-cross-chain transactions.

[0064] based on Figure 1 This embodiment proposes a third cross-chain transaction processing method, in which the first contract interface also includes a snapshot interface and a recovery interface.

[0065] At this time, the method further includes: before the source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the locking interface in the first contract interface: The source blockchain backs up the contract data of the first smart contract through the snapshot interface, obtains the backup data, and saves the backup data.

[0066] At this time, after obtaining the first processing result, the method further includes: If the source blockchain determines that the first processing result or the transaction processing result of the target blockchain is a failure, the global processing result is determined to be a failure, and the data of the first smart contract is rolled back based on the recovery interface and the backup data, and the local lock state of the first smart contract is adjusted from locked to unlocked through the unlocking interface, and the global lock state of the first smart contract is adjusted from locked to unlocked.

[0067] Specifically, this embodiment can set up a snapshot interface and a recovery interface for smart contracts that need to participate in cross-chain transactions. When the source blockchain performs cross-chain transaction processing on the first smart contract, it can first call the snapshot interface to back up the contract data of each smart contract in the first smart contract to obtain the corresponding backup data. When the cross-chain transaction processing result is a failure, the recovery interface can be called to roll back the data based on the backup data, and restore the contract data of each smart contract in the first smart contract to the state saved by the snapshot.

[0068] It should be noted that after the source blockchain obtains the first processing result, regardless of whether the first processing result is successful or failed, the local lock and global lock of each smart contract in the first smart contract can be set to unlock to avoid affecting the calls of other chain transactions or cross-chain transactions to these smart contracts.

[0069] It is understandable that the second contract interface of the second smart contract on the target blockchain may also include a snapshot interface and a recovery interface. The target blockchain may also back up and restore data of each smart contract in the second smart contract during the execution of this cross-chain transaction. Similarly, after obtaining the second processing result, the target blockchain may set the local lock and global lock of each smart contract in the second smart contract to unlock, regardless of whether the second processing result is successful or failed, to avoid affecting the calls of these smart contracts by other chain transactions or cross-chain transactions.

[0070] Optionally, the source blockchain determines that the transaction processing result of the target blockchain is a failure, including: When the source blockchain determines that the transaction processing result sent by the target blockchain is a failure, the transaction processing result of the target blockchain is determined to be a failure; or, When the source blockchain sends a cross-chain transaction request to the target blockchain, it starts timing and records the timing duration; if the transaction processing result sent by the target blockchain is not received before the timing duration exceeds the preset duration threshold, the transaction processing of the target blockchain is determined to have timed out, and the transaction processing result of the target blockchain is determined to have failed.

[0071] Among them, the preset time threshold can be set by technical personnel according to actual conditions, and this embodiment does not limit it.

[0072] It is understandable that, in the process of determining whether the transaction processing result of the target blockchain is a failure by referring to the source blockchain, the target blockchain can also use the same method to determine whether the transaction processing result of the source blockchain is a failure.

[0073] The cross-chain transaction processing method proposed in this embodiment can call the recovery interface to roll back data based on backup data when the cross-chain transaction processing result is a failure, and restore the contract data of the first smart contract to the state saved by the snapshot.

[0074] based on Figure 1 This embodiment proposes a fourth cross-chain transaction processing method. In this method, after step S108, the method further includes: When the source blockchain determines that the first processing result is successful, the corresponding first processing result and the global transaction identifier are sent to the target blockchain, so that the target blockchain: when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result is determined to be successful.

[0075] Specifically, the transaction processing results can be synchronized between the source blockchain and the target blockchain, so that the source blockchain and the target blockchain can synchronize the global processing results of the cross-chain transaction request and complete the cross-chain transaction.

[0076] It should be noted that the target blockchain can determine that the global processing result is a failure when it is determined that the second processing result is a failure or the transaction processing result of the source blockchain is a failure.

[0077] The cross-chain transaction processing method proposed in this embodiment can synchronize transaction processing results between the source blockchain and the target blockchain, and then synchronize the global processing results of the cross-chain transaction request, further effectively realizing the processing of cross-chain transactions.

[0078] In the blockchain cross-chain solution of the related technology, the two-phase commit solution in the distributed database is basically used as a prototype for cross-chain transaction processing, and a single function in the smart contract is processed as the smallest unit of cross-chain transaction resources. This type of solution locks resources at the function granularity, requiring the business smart contract on the blockchain to provide a reverse operation interface for each cross-chain function interface, which is used to roll back the transaction when an exception occurs, to ensure the atomicity of the cross-chain transaction. For existing non-cross-chain business smart contracts, if they want to adapt the above solution to participate in cross-chain transactions, their code modification is relatively cumbersome and the required transformation cost is high; at the same time, the above solution does not take into account complex calling situations such as cascade calls of smart contracts that may occur during the cross-chain process, and cannot effectively support cross-chain transactions in more scenarios.

[0079] Currently, there is an urgent need for a smart contract adaptation method that is simple to use, has strong atomicity, and can support complex calling situations such as cascade calls. It can modify existing non-cross-chain business smart contracts at a low transformation cost so that they can be used for cross-chain transactions between blockchains involving complex calls, and can be widely used in various cross-chain architectures.

[0080] This embodiment can enable the smart contract to adapt to cross-chain transaction requirements and effectively implement cross-chain transaction processing by executing the following process.

[0081] 1) Write and deploy the respective cross-chain management smart contracts on the two blockchains that need to conduct cross-chain transactions. The contract sets a global lock, abstracts the cross-chain standard function interface of the cross-chain business smart contract, can manage cross-chain transactions on the blockchain, call related cross-chain business smart contracts, and ensure the atomicity of cross-chain transactions. Specifically: 1.1) Abstract cross-chain standard function interface of cross-chain business smart contracts.

[0082] Specifically, the cross-chain standard function interfaces of the cross-chain business smart contract include four, namely, locking interface, unlocking interface, snapshot interface and recovery interface.

[0083] Among them, the locking interface can lock the cross-chain business smart contract and record the information of the locker. During the period when the cross-chain business smart contract is locked, only the locker can call other business function interfaces on the cross-chain business smart contract; correspondingly, the unlocking interface can unlock the locked cross-chain business smart contract and can only be called by the current locker.

[0084] The snapshot interface can encode the data saved by the cross-chain business smart contract and return it in binary format, which is used to save the data of the cross-chain business smart contract before the cross-chain transaction starts; accordingly, the recovery interface is used to recover the data when the cross-chain transaction fails. The locker calls the recovery interface and inputs the snapshot data in binary format to restore the data of the cross-chain business smart contract to the state saved by the snapshot. For example, when using the Solidity language to write a cross-chain management smart contract on the Ethereum blockchain, the interface keyword can be used to abstract the cross-chain standard function interface of the business smart contract, specify the input and output data types, and enable it to be called after the cross-chain business smart contract is instantiated.

[0085] 1.2) Write the calling interface of the cross-chain standard interface of the cross-chain business smart contract.

[0086] Specifically, for the lock, unlock, snapshot, and restore interfaces of the cross-chain business smart contract in step 1.1), write their corresponding call interfaces. The call interface receives the address of the cross-chain business smart contract as an input parameter and actually calls the cross-chain business smart contract corresponding to the address. For example, when using the Solidity language to write a cross-chain management smart contract on the Ethereum blockchain, the interface keyword can be used to abstract the business smart contract into a businessContract class, including the lock interface lock(), and the call interface can be written as businessContract.lock().

[0087] 1.3) Write a unified calling interface for other business function interfaces of cross-chain business smart contracts.

[0088] Specifically, in addition to the four cross-chain standard function interfaces of lock, unlock, snapshot, and restore mentioned in step 1.1), the cross-chain business smart contract also includes its specific business function interface. The cross-chain management smart contract calls these business function interfaces through a unified calling interface, which inputs the address of the called cross-chain business smart contract and the binary format data required for the call, and outputs the result of calling the cross-chain business smart contract. For example, when using the Solidity language to write a cross-chain management smart contract on the Ethereum blockchain, the encoded binary format data can be obtained through the abi.encodeWithSignature() method, and the call() method can be used to complete the call to the cross-chain business smart contract.

[0089] 1.4) Write cross-chain transaction registration interface and result return interface.

[0090] Specifically, the transaction registration interface is responsible for receiving cross-chain transaction requests sent by users on the blockchain, parsing the parameters contained in the request and calling the cross-chain standard interface and business function interface of the business smart contract accordingly. In this process, the cross-chain management smart contract will identify the cascade call situation in the cross-chain transaction request and save the call relationship between contracts in a tree structure. The result return interface is used to save the results generated by the execution of the cross-chain transaction for user query and final cross-chain transaction result determination.

[0091] 1.5) Set a global lock.

[0092] Specifically, the global lock is a variable in the cross-chain management smart contract. The global lock establishes a mapping between the address of a cross-chain business smart contract and its lock status. When registering a cross-chain transaction, this variable can be used to quickly determine whether the cross-chain business smart contract involved in the current cross-chain transaction is locked. For example, use the mapping type in Solidity to establish a mapping between address and bool type to save the business smart contract address and whether it is locked.

[0093] 1.6) Compile and deploy the cross-chain management smart contract.

[0094] For example: compile the cross-chain management smart contract written in Solidity through solc, obtain the binary bytecode corresponding to the cross-chain management smart contract, and deploy it on the chain.

[0095] 2) On the two blockchains that need to conduct cross-chain transactions, write and deploy the required cross-chain business smart contracts, provide specific cross-chain services, and provide atomicity guarantees for cross-chain transactions by setting local locks and writing cross-chain standard function interfaces. If there is a non-cross-chain business smart contract, you can add a standard cross-chain function interface on its basis for adaptation, specifically: 2.1) Set the local lock. The local lock is a variable in the cross-chain business smart contract. The local lock records the lock status of the corresponding cross-chain business smart contract. For example, when using Solidity to write a cross-chain business smart contract, a bool type variable can be used to record the lock status of the current business smart contract.

[0096] 2.2) Write a locking interface that can modify the locking status recorded by the local lock to "locked".

[0097] 2.3) Write an unlocking interface that can modify the lock status recorded by the local lock to "unlocked".

[0098] 2.4) Write the lock status verification logic. For business functions, it is necessary to determine the lock status recorded by the local lock before calling. If it is "locked", the call is rejected. For example, when using Solidity to write a cross-chain business smart contract, you can declare a function modifier through the modifier keyword, write the lock status judgment logic, and apply it to other existing business functions.

[0099] 2.5) Write the snapshot interface.

[0100] Specifically, the snapshot interface extracts all different types of data saved by the cross-chain business smart contract, encodes them in sequence, saves them in the form of a binary byte stream and returns them. For example, when using Solidity to write a cross-chain business smart contract, all data variables can be encoded through the abi.encode method, and a bytes type of data can be uniformly returned.

[0101] 2.6) Write the recovery interface.

[0102] Specifically, the recovery interface is used to recover data when a cross-chain transaction fails. The interface receives snapshot data in binary format and uses the decoding method corresponding to the snapshot interface to restore the data of the cross-chain business smart contract in sequence and in different types to the state saved by the snapshot. For example, when using Solidity to write a cross-chain business smart contract, the abi.decode method can be used to parse the input bytes type snapshot data and restore it to the corresponding data type.

[0103] 2.7) Compile and deploy cross-chain business smart contracts. For example, compile the cross-chain business smart contract written in Solidity through solc, obtain the binary bytecode corresponding to the cross-chain business smart contract, and deploy it on the chain.

[0104] 3) Users on the source blockchain and the destination blockchain exchange the chain identification information, contract information and their own routing information of the chain they belong to through the communication method provided by the cross-chain architecture, and prepare to start cross-chain transactions. The contract information includes the address of the cross-chain business smart contract, the cross-chain function interface and parameter information. For example, users on the two chains exchange contract information, chain ID, their own IP address and port through P2P communication, or there is a relay chain in the cross-chain architecture to record the contract information, chain ID, user IP address and port on both chains, allowing users on both sides to query on the relay chain.

[0105] 4) The user on the source blockchain initiates a cross-chain transaction request, including the timestamp, call tree information on the source blockchain and the destination blockchain, starts the cross-chain transaction and applies for the global lock of the source blockchain and the destination blockchain, specifically: 4.1) The user constructs the call tree information of this cross-chain transaction on the source and destination blockchains, and records the cascade call of the current cross-chain transaction in a tree structure. Each node on the tree represents a cross-chain business smart contract involved in the cross-chain transaction, and its child nodes represent the cross-chain business smart contracts it calls. The nodes record specific cross-chain business smart contract call information. For example, the source blockchain has deployed two cross-chain business smart contracts A and B. The cross-chain transaction calls function A1 in A, and A1 calls function B2 in B. Then A will be the parent node of B, and B will be the child node of A. The node records information including contract address, call interface, call parameters, etc.

[0106] 4.2) The user initiates a transaction and calls the transaction registration interface of the cross-chain management smart contract to register the cross-chain transaction. The cross-chain management smart contract generates a globally unique cross-chain transaction ID corresponding to the cross-chain transaction. The ID will be used as the identifier of this cross-chain transaction on the source blockchain and the destination blockchain, and used for indexing when querying cross-chain transaction data and execution results. For example, the cross-chain management smart contract uses UUID and other methods to generate a globally unique cross-chain transaction ID.

[0107] 4.3) The cross-chain management smart contract applies for a global lock based on the call tree information on both chains recorded by this cross-chain transaction. For all smart contracts involved in the cross-chain transaction request, it is necessary to ensure that their global locks are in the "unlocked" state, that is, the cross-chain resources are not occupied. If the global lock of any of the smart contracts is in the "locked" state, the cross-chain transaction request will be rejected and the cross-chain transaction failure will be reported; otherwise, their global locks will be changed to the "locked" state and the cross-chain transaction will continue to execute. For example, use the bool type to identify whether the contract is locked. Assuming that a cross-chain transaction calls the cross-chain business smart contract A on the source blockchain and calls the cross-chain business smart contract B on the destination blockchain at the same time, the cross-chain management smart contract will modify the bool type lock variables corresponding to the A and B contract addresses to true according to the chain identification information.

[0108] 4.4) The user forwards the cross-chain transaction request to the destination blockchain according to the destination blockchain routing. The destination blockchain initiates the transaction to register the cross-chain transaction and executes step 4.3) to apply for the global lock on the destination blockchain, and then executes the cross-chain transaction operation after step 5).

[0109] 5) The cross-chain management smart contract applies for a local lock and takes a snapshot, preparing to execute cross-chain transactions.

[0110] Specifically, according to the smart contract call relationship recorded by the cross-chain transaction request, the lock and snapshot interfaces in the cross-chain standard interface of the cross-chain business smart contract are called successively, the local lock state of the cross-chain business smart contract is modified to "locked", and the smart contract snapshot list corresponding to the current cross-chain transaction is obtained.

[0111] 6) The cross-chain management smart contract uniformly calls the interface through the business function of the business smart contract, executes the specific cross-chain transaction request, and uploads the result returned by the corresponding cross-chain transaction ID through the result return interface, and synchronizes the result to other participants of the cross-chain transaction through the communication method provided by the cross-chain architecture.

[0112] 7) The cross-chain management smart contract confirms the final execution result of the cross-chain transaction, specifically: 7.1) When the cross-chain management smart contracts of the two blockchains have returned and synchronized the results, or the execution time of the cross-chain transaction has reached the specified timeout, the final execution result of this cross-chain transaction will be confirmed; 7.2) If the results returned by both parties involved in the cross-chain transaction are successful, the cross-chain transaction is recorded as successful and only the unlocking operation is performed; otherwise, the cross-chain transaction fails and snapshot recovery and unlocking are required. If the execution time of the cross-chain transaction reaches the timeout, it means that at least one party has not fed back the execution result of the cross-chain transaction, and the cross-chain transaction fails and snapshot recovery and unlocking are required.

[0113] 8) The cross-chain management smart contract performs snapshot recovery based on the final execution results.

[0114] Specifically, if the cross-chain transaction in step 7) ultimately fails, the cross-chain management smart contract calls the recovery interface in the cross-chain standard interface of the cross-chain business smart contract based on the smart contract snapshot list obtained in step 5), and uses the corresponding snapshot data in the snapshot list for recovery to complete the data rollback.

[0115] 9) The cross-chain management smart contract unlocks the local lock and the global lock to complete this cross-chain transaction.

[0116] Specifically, according to the smart contract call relationship obtained in step 5), the unlocking interface in the cross-chain standard interface of the cross-chain business smart contract is called to modify the local lock of the cross-chain business smart contract to "unlock"; and modify the global lock of the cross-chain management smart contract to modify the global lock of the business smart contract to "unlock".

[0117] Specifically, this embodiment can write and deploy respective cross-chain management smart contracts on the two blockchains that need to conduct cross-chain transactions. The contract sets a global lock, abstracts the cross-chain standard function interface of the cross-chain business smart contract, can manage cross-chain transactions on the blockchain, call related cross-chain business smart contracts, and ensure the atomicity of cross-chain transactions. On the two blockchains that need to conduct cross-chain transactions, write and deploy the required cross-chain business smart contracts, provide specific cross-chain services, and provide atomicity guarantees for cross-chain transactions by setting local locks and writing cross-chain standard function interfaces. If there is a non-cross-chain business smart contract, a standard cross-chain function interface can be added on its basis for adaptation. Based on the above-mentioned smart contract adaptation method, the corresponding cross-chain transaction process is as follows: the user on the source blockchain initiates a cross-chain transaction request to start the cross-chain transaction; the cross-chain management smart contract applies for a local lock and takes a snapshot to prepare for the execution of the cross-chain transaction; the cross-chain management smart contract uniformly calls the interface through the business function of the business smart contract, executes the specific cross-chain transaction request, and uploads the result returned by the call through the result return interface, and synchronizes the result to other participants in the cross-chain transaction; the cross-chain management smart contract confirms the final execution result of the cross-chain transaction, performs snapshot recovery based on the final execution result, unlocks the local lock and the global lock, and completes this cross-chain transaction.

[0118] This embodiment can transform existing non-cross-chain business smart contracts into cross-chain business smart contracts that support cross-chain features at a relatively low cost, and additionally provide a cross-chain management smart contract to manage cross-chain transactions. This embodiment can provide support for complex call situations such as cascade calls on the basis of ensuring the atomicity and security of cross-chain transactions. This embodiment has high scalability in design and can be migrated to any blockchain that supports smart contracts or chain codes for cross-chain transaction processing of the blockchain.

[0119] This embodiment can adapt to mainstream smart contract development by designing a set of standard cross-chain function interfaces, reduce the cost of migrating and transforming non-cross-chain business smart contracts to cross-chain business smart contracts, avoid the disadvantages of related technologies that modify each business function separately, reduce invasiveness, and better adapt to non-cross-chain smart contracts that are currently in use.

[0120] This embodiment introduces a cross-chain management smart contract to record the specific calling conditions of cross-chain transactions, and can handle complex cascade calling conditions formed by calling between smart contracts. It also combines snapshot and recovery mechanisms to ensure the atomicity of cross-chain transactions and the correctness of data of each business smart contract in complex cascade calling scenarios, and can be applied to various cross-chain architectures.

[0121] like Figure 2 As shown, this embodiment proposes a cross-chain transaction processing device, which is applied to the source blockchain. The device includes: The receiving unit 201 is used to receive a cross-chain transaction request sent by a user, wherein the cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data; The first determination unit 202 is used to determine the first smart contract, the first contract interface, the target blockchain, the second smart contract and the second contract interface related to the cross-chain transaction according to the blockchain identifier, the smart contract identifier and the contract interface information in the cross-chain transaction request; and generate a corresponding global transaction identifier according to the cross-chain transaction request; A generating unit 203 is used to generate a corresponding global transaction identifier according to the cross-chain transaction request; A modification unit 204 is used to determine that the global lock state of the first smart contract is unlocked, and then modify the global lock state of the first smart contract from unlocked to locked; The calling unit 205 is used to call the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data; A storage unit 206, used to store the first processing result and the global transaction identifier accordingly; The sending unit 207 is used to send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, and correspondingly saves the second processing result and the global transaction identifier, and when it is determined that the second processing result is successful, returns the corresponding second processing result and the global transaction identifier to the source blockchain; The second determining unit 208 is configured to determine that the first processing result and the second processing result corresponding to the global transaction identifier are successful, and then determine that the global processing result is successful.

[0122] It should be noted that the processing of the receiving unit 201, the first determining unit 202, the generating unit 203, the modifying unit 204, the calling unit 205, the saving unit 206, the sending unit 207 and the second determining unit 208 and the beneficial effects thereof can be respectively referred to in Figure 1 Steps S101 to S108 in the above are not described in detail.

[0123] Optionally, the first contract interface includes a locking interface and a business interface.

[0124] The calling unit 205 is further used for: Through the locking interface in the first contract interface, the local lock state of the first smart contract is adjusted from unlocked to locked, and according to the smart contract calling relationship, the business interface in the first contract interface and the contract calling data, the first smart contract is called to perform transaction processing to obtain a first processing result.

[0125] Optionally, the first contract interface also includes an unlocking interface. The above device also includes: An adjustment unit is used to adjust the local lock state of the first smart contract from locked to unlocked through an unlocking interface after determining that the global processing result is successful, and adjust the global lock state of the first smart contract from locked to unlocked.

[0126] Optionally, the first contract interface also includes a snapshot interface and a recovery interface. The above device also includes: The snapshot unit is used to back up the contract data of the first smart contract through the snapshot interface before the source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the locking interface in the first contract interface, obtain the backup data, and save the backup data.

[0127] A recovery unit is used to determine that the first processing result or the transaction processing result of the target blockchain is a failure after obtaining the first processing result, then determine that the global processing result is a failure, roll back the data of the first smart contract based on the recovery interface and the backup data, and adjust the local lock state of the first smart contract from locked to unlocked through the unlocking interface, and adjust the global lock state of the first smart contract from locked to unlocked.

[0128] Optionally, the recovery unit is also used to: When it is determined that the transaction processing result sent by the target blockchain is a failure, the transaction processing result of the target blockchain is determined to be a failure; or, When a cross-chain transaction request is sent to the target blockchain, the timing is started and the timing duration is recorded; if the transaction processing result sent by the target blockchain is not received before the timing duration exceeds the preset duration threshold, the transaction processing of the target blockchain is determined to have timed out, and the transaction processing result of the target blockchain is determined to have failed.

[0129] Optionally, the above device further includes: The third determining unit is used to, after obtaining the first processing result, send the corresponding first processing result and the global transaction identifier to the target blockchain when the first processing result is determined to be successful, so that the target blockchain: when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result is determined to be successful.

[0130] Optionally, the blockchain identifier includes a chain identifier of a source blockchain and a chain identifier of a target blockchain; The first smart contract and the second smart contract each include at least one smart contract; The first contract interface includes the contract interface of each smart contract in the first smart contract, and the second contract interface includes the contract interface of each smart contract in the second smart contract; The smart contract identifier includes the contract address of each smart contract in the first smart contract and the contract address of each smart contract in the second smart contract; The smart contract calling relationship is the calling relationship between all smart contracts.

[0131] The cross-chain transaction processing device proposed in this embodiment can receive a cross-chain transaction request sent by a user from a source blockchain, determine the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction according to the cross-chain transaction request, generate a global transaction identifier corresponding to the cross-chain transaction request, perform cross-chain transaction processing according to the target blockchain, smart contract, contract interface, contract call data and smart contract call relationship involved in the cross-chain transaction to obtain a first processing result, save the global transaction identifier and the first processing result accordingly, send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain performs the cross-chain transaction processing to obtain a second processing result and save the second processing result and the global transaction identifier accordingly, and when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result of the cross-chain transaction request is determined to be successful, thereby effectively processing the cross-chain transaction request.

[0132] The cross-chain transaction processing device in this embodiment is presented in the form of a functional unit, where the unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.

[0133] The embodiment of the present invention also provides a computer device having the above Figure 2 The cross-chain transaction processing device shown.

[0134] See also Figure 3, a schematic diagram of the structure of a computer device provided by an optional embodiment of the present invention, the computer device includes: one or more processors 10, a memory 20, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common motherboard or installed in other ways as needed. The processor can process instructions executed in the computer device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple computer devices can be connected, and each device provides part of the necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Figure 3 A processor 10 is taken as an example.

[0135] The processor 10 may be a central processing unit, a network processor or a combination thereof. The processor 10 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.

[0136] The memory 20 stores instructions executable by at least one processor 10, so that at least one processor 10 executes the method shown in the above embodiment.

[0137] The memory 20 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function. The data storage area may store data created according to the use of the computer device, etc. In addition, the memory 20 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage devices. In some optional embodiments, the memory 20 may optionally include a memory remotely arranged relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0138] The memory 20 may include a volatile memory, such as a random access memory. The memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive. The memory 20 may also include a combination of the above types of memory.

[0139] The computer device further comprises a communication interface 30 for the computer device to communicate with other devices or a communication network.

[0140] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A cross-chain transaction processing method, characterized in that: Applied to a source blockchain; the method comprises: The source blockchain receives a cross-chain transaction request sent by a user, wherein the cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data; The source blockchain determines the first smart contract, the first contract interface, the target blockchain, the second smart contract, and the second contract interface related to the cross-chain transaction according to the blockchain identifier, the smart contract identifier, and the contract interface information in the cross-chain transaction request, and generates a corresponding global transaction identifier according to the cross-chain transaction request; wherein the first smart contract and the second smart contract are deployed on the source blockchain and the target blockchain, respectively, and the first contract interface and the second contract interface are the contract interfaces of the first smart contract and the second smart contract, respectively; The source blockchain determines that the global lock state of the first smart contract is unlocked, then changes the global lock state of the first smart contract from unlocked to locked, and calls the first smart contract to perform transaction processing according to the smart contract call relationship, the first contract interface and the contract call data to obtain a first processing result, and correspondingly saves the first processing result and the global transaction identifier; The source blockchain sends the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, saves the second processing result and the global transaction identifier accordingly, and returns the corresponding second processing result and the global transaction identifier to the source blockchain when it is determined that the second processing result is successful; If the source blockchain determines that the first processing result and the second processing result corresponding to the global transaction identifier are successful, then the global processing result is determined to be successful.

2. The method according to claim 1, characterized in that The first contract interface includes a locking interface and a business interface; The calling the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data includes: The source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the locking interface in the first contract interface, and calls the first smart contract for transaction processing to obtain the first processing result according to the smart contract calling relationship, the business interface in the first contract interface and the contract calling data.

3. The method according to claim 2, characterized in that The first contract interface also includes an unlocking interface; After determining that the global processing result is successful, the method further includes: The source blockchain adjusts the local lock state of the first smart contract from locked to unlocked through the unlocking interface, and adjusts the global lock state of the first smart contract from locked to unlocked.

4. The method according to claim 3, characterized in that: The first contract interface also includes a snapshot interface and a recovery interface; Before the source blockchain adjusts the local lock state of the first smart contract from unlocked to locked through the lock interface in the first contract interface, the method further includes: The source blockchain backs up the contract data of the first smart contract through the snapshot interface to obtain backup data, and saves the backup data; After obtaining the first processing result, the method further includes: If the source blockchain determines that the first processing result or the transaction processing result of the target blockchain is a failure, the global processing result is determined to be a failure, and the first smart contract is rolled back based on the recovery interface and the backup data, and the local lock state of the first smart contract is adjusted from locked to unlocked through the unlocking interface, and the global lock state of the first smart contract is adjusted from locked to unlocked.

5. The method according to claim 4, characterized in that The source blockchain determines that the transaction processing result of the target blockchain is a failure, including: When the source blockchain determines that the transaction processing result sent by the target blockchain is a failure, the transaction processing result of the target blockchain is determined to be a failure; or, When the source blockchain sends the cross-chain transaction request to the target blockchain, it starts timing and records the timing duration; if the transaction processing result sent by the target blockchain is not received before the timing duration exceeds the preset duration threshold, it is determined that the transaction processing of the target blockchain has timed out, and the transaction processing result of the target blockchain is determined to be a failure.

6. The method according to claim 1, characterized in that After obtaining the first processing result, the method further includes: When the source blockchain determines that the first processing result is successful, the corresponding first processing result and the global transaction identifier are sent to the target blockchain, so that the target blockchain: when it is determined that the first processing result and the second processing result corresponding to the global transaction identifier are successful, the global processing result is determined to be successful.

7. The method according to any one of claims 1 to 6, characterized in that The blockchain identifier includes the chain identifier of the source blockchain and the chain identifier of the target blockchain; The first smart contract and the second smart contract each include at least one smart contract; The first contract interface includes the contract interface of each smart contract in the first smart contract, and the second contract interface includes the contract interface of each smart contract in the second smart contract; The smart contract identifier includes the contract address of each smart contract in the first smart contract and the contract address of each smart contract in the second smart contract; The smart contract calling relationship is the calling relationship between all the smart contracts.

8. A cross-chain transaction processing device, characterized in that: Applied to the source blockchain; the device comprises: A receiving unit, configured to receive a cross-chain transaction request sent by a user, wherein the cross-chain transaction request includes a blockchain identifier, a smart contract identifier, a smart contract call relationship, contract interface information, and contract call data; A first determination unit is configured to determine, according to the blockchain identifier, the smart contract identifier, and the contract interface information in the cross-chain transaction request, a first smart contract, a first contract interface, a target blockchain, a second smart contract, and a second contract interface related to the cross-chain transaction; and generate a corresponding global transaction identifier according to the cross-chain transaction request; A generating unit, configured to generate a corresponding global transaction identifier according to the cross-chain transaction request; a modification unit, configured to determine that the global lock state of the first smart contract is unlocked, and then modify the global lock state of the first smart contract from unlocked to locked; A calling unit, configured to call the first smart contract to perform transaction processing to obtain a first processing result according to the smart contract calling relationship, the first contract interface and the contract calling data; A storage unit, used for correspondingly storing the first processing result and the global transaction identifier; A sending unit, configured to send the cross-chain transaction request and the global transaction identifier to the target blockchain, so that the target blockchain: determines that the global state of the second smart contract is unlocked according to the cross-chain transaction request, then changes the global lock state of the second smart contract from unlocked to locked, and calls the second smart contract to perform transaction processing according to the smart contract call relationship, the second contract interface and the contract call data to obtain a second processing result, correspondingly saves the second processing result and the global transaction identifier, and when it is determined that the second processing result is successful, returns the corresponding second processing result and the global transaction identifier to the source blockchain; The second determining unit is configured to determine that if the first processing result and the second processing result corresponding to the global transaction identifier are successful, then determine that the global processing result is successful.

9. A computer device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the cross-chain transaction processing method according to any one of claims 1 to 7 by executing the computer instructions.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the cross-chain transaction processing method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Blockchain multi-chain cross-chain system and implementation mechanism thereof

    CN112287029A

  • Cross-chain transaction processing method and device

    CN114185996A

  • Method and device for generating resource identifier in block chain network

    CN115203332A