A cross-chain transaction method, system, computer device and storage medium

By setting up transaction management contracts and timeout handling mechanisms in cross-chain transactions, the problem of data inconsistency caused by network anomalies in cross-chain transactions is solved, and data consistency and immutability are achieved in the absence of a trusted third party.

CN115578194BActive Publication Date: 2026-06-26HANGZHOU QULIAN TECHNOLOGY CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HANGZHOU QULIAN TECHNOLOGY CO LTD
Filing Date
2022-09-19
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

In cross-chain transactions, when there is a lack of trusted third-party coordination, network anomalies can cause cross-chain transaction data consistency to be compromised, leading to transaction consistency processing failure.

Method used

By setting up a transaction management contract in the source chain system and combining it with the timeout judgment of the cross-chain gateway, timeout notification information is sent to both the source chain system and the destination chain system to instruct data rollback. Based on the timeout processing receipts fed back by the system, the transaction status is updated to ensure data consistency.

Benefits of technology

Ensuring data consistency and immutability in cross-chain transactions under unstable network conditions improves the fault tolerance and processing efficiency of cross-chain transactions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115578194B_ABST
    Figure CN115578194B_ABST
Patent Text Reader

Abstract

The application is suitable for the field of blockchain technology, and provides a cross-chain transaction method, system, computer device and storage medium, wherein the method comprises the following steps: obtaining a target cross-chain transaction initiated by a source chain system; in a case where it is determined that the target cross-chain transaction has a transmission timeout, sending timeout notification information to the source chain system and a destination chain system; in a case where the timeout processing receipt fed back by the source chain system and the destination chain system based on the timeout notification information is obtained, sending state update notification information to the source chain system, wherein the state update notification information is used to instruct the source chain system to call a transaction management contract to change the transaction state of the target cross-chain transaction from a first state to a second state. The scheme can ensure the consistency and non-tamperability of data state in the case of unstable network.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application belongs to the field of blockchain technology, and in particular relates to a cross-chain transaction method, system, computer device and storage medium. Background Technology

[0002] Currently, various industries are building their own blockchain ecosystems according to their own needs. Different blockchain systems have different technical approaches in terms of communication protocols, identity management, etc., making these blockchains independent and uninterrupted. In order to enable communication between different blockchains, cross-chain technology has emerged.

[0003] During cross-chain transactions, it is crucial to ensure the consistency of these transactions, guaranteeing that both application chain systems either succeed or fail simultaneously. Failure to guarantee consistency can lead to inconsistencies in business data across application chains, resulting in transaction errors.

[0004] To ensure the immutability of transactions and avoid transaction errors, a trusted third party is usually involved to ensure the reliability of data consistency in cross-chain transactions.

[0005] However, in some application scenarios, such as when cross-chain participants have a foundation of trust or where security requirements are not high, P2P (Peer-to-peer) networks are used to establish direct network connections between the cross-chain gateways connected to the cross-chain participants. In these scenarios, due to the inherent instability of P2P networks, without a trusted third party to record data and handle anomalies in cross-chain transactions, data consistency in cross-chain transactions cannot be adequately guaranteed when network anomalies occur, leading to transaction consistency processing failures. Summary of the Invention

[0006] This application provides a cross-chain transaction method, system, computer device, and storage medium to solve the problem in the prior art that, without a trusted third party to record data and handle anomalies in cross-chain transactions, the data consistency of cross-chain transactions cannot be fully guaranteed when network anomalies occur, leading to transaction consistency processing failure.

[0007] A first aspect of this application provides a cross-chain transaction method applied to a cross-chain gateway, the method comprising:

[0008] The system obtains the target cross-chain transaction sent by the source chain system, which is equipped with a transaction management contract. The transaction management contract is used to record the transaction status of the cross-chain transaction.

[0009] If a timeout occurs in the target cross-chain transaction, a timeout notification is sent to the source chain system and the destination chain system. The timeout notification is used to instruct the source chain system and the destination chain system to perform data rollback.

[0010] Upon receiving timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information, a status update notification is sent to the source chain system.

[0011] The status update notification information is used to instruct the source chain system to call the transaction management contract to change the transaction status of the target cross-chain transaction from the first status to the second status. The first status indicates that the cross-chain transaction is in the processing state, and the second status indicates that the cross-chain transaction is in the processing completed state.

[0012] A second aspect of this application provides a cross-chain transaction method applied to a source chain system, wherein the source chain system is provided with a transaction management contract, the transaction management contract being used to record the transaction status of cross-chain transactions, the method comprising:

[0013] Send the target cross-chain transaction to the cross-chain gateway;

[0014] Obtain the timeout notification information sent by the cross-chain gateway, the timeout notification information being used to indicate that the target cross-chain transaction has timed out;

[0015] Based on the timeout notification information, data rollback is performed, and a timeout processing receipt is sent to the cross-chain gateway.

[0016] Upon receiving the status update notification information sent by the cross-chain gateway, the transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the first status to the second status. The first status indicates that the cross-chain transaction is in the processing state, and the second status indicates that the cross-chain transaction is in the processing completed state. The status update notification information is sent by the cross-chain gateway upon receiving the timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information.

[0017] A third aspect of this application provides a cross-chain transaction system, including:

[0018] Source chain system;

[0019] Destination chain system;

[0020] The first cross-chain gateway is connected to the source chain system network;

[0021] The second cross-chain gateway is connected to the destination chain system and the second cross-chain gateway network, respectively.

[0022] The source chain system is used to execute the cross-chain transaction method as described in the second aspect above;

[0023] Wherein, the first cross-chain gateway is used to execute the cross-chain transaction method as described in the first aspect above, or the second cross-chain gateway is used to execute the cross-chain transaction method as described in the first aspect above.

[0024] A fourth aspect of this application provides a computer device including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the steps of the method as described in the first or second aspect.

[0025] A fifth aspect of this application provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method as described in the first or second aspect.

[0026] The sixth aspect of this application provides a computer program product that, when run on a terminal, causes the terminal to perform the steps of the method described in the first or second aspect above.

[0027] As can be seen from the above, in this embodiment of the application, by setting a transaction management contract in the source chain system to record the transaction status of cross-chain transactions, and combining the timeout judgment of the cross-chain transactions sent by the source chain system during the information transmission process, timeout notification information is promptly sent to the source chain system and the destination chain system to instruct the two systems to roll back the data. Based on the timeout processing receipts of the two systems, it is ensured that the source chain system effectively updates the transaction status of the cross-chain transactions. In this process, the cross-chain gateway acts as the coordinator of data consistency and, in conjunction with the transaction management contract deployed on the source chain system to record the transaction status, ensures the data consistency processing of cross-chain transactions between the source chain system and the destination chain system after the cross-chain transaction is executed, and ensures the data status consistency and immutability under network instability. Attached Figure Description

[0028] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0029] Figure 1 This is a schematic diagram of the structure of a blockchain system provided in an embodiment of this application;

[0030] Figure 2 This is a schematic diagram of a cross-chain transaction system provided in an embodiment of this application;

[0031] Figure 3 This is a flowchart of a cross-chain transaction method provided in an embodiment of this application;

[0032] Figure 4 This is a flowchart of another cross-chain transaction method provided in the embodiments of this application;

[0033] Figure 5 This is a structural diagram of a computer device provided in an embodiment of this application;

[0034] Figure 6 This is a structural diagram of another computer device provided in an embodiment of this application. Detailed Implementation

[0035] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.

[0036] It should be understood that, when used in this specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0037] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.

[0038] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.

[0039] As used in this specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrases "if determined" or "if [described condition or event] is detected" may be interpreted, depending on the context, as "once determined," "in response to determination," "once [described condition or event] is detected," or "in response to detection of [described condition or event]."

[0040] It should be understood that the sequence number of each step in this embodiment does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of this application embodiment.

[0041] Before explaining the embodiments of this application, the relevant content of blockchain will be explained first.

[0042] Figure 1 This is a schematic diagram of the structure of a blockchain system provided in an embodiment of this application.

[0043] See Figure 1 Blockchain system 100 refers to a system used for data sharing between nodes. Blockchain system 100 may include multiple nodes 101. Each node 101, during normal operation, can receive input information and maintain shared data within the blockchain system 100 based on this input information. To ensure interoperability within the blockchain system 100, information connections can exist between each node 101, allowing information transmission between them. For example, when any node 101 in the blockchain system 100 receives input information, other nodes 101 in the blockchain system 100 obtain this input information according to a consensus algorithm and store it as part of the shared data, ensuring data consistency across all nodes 101 in the blockchain system 100. In other words, each node 101 in the blockchain system 100 stores the same blockchain.

[0044] Blockchain System 100 incorporates computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanisms, and encryption algorithms. As a distributed shared ledger and database, Blockchain System 100 features decentralization, immutability, full traceability, verifiability, collective maintenance, and transparency. These characteristics ensure the blockchain's shared openness, authenticity, integrity, security, and reliability.

[0045] Before providing a detailed explanation of the cross-chain transaction method provided in the embodiments of this application, the terms used in the embodiments of this application will be explained first.

[0046] Source Chain System: The source chain system is a blockchain system that initiates cross-chain transactions.

[0047] Destination Chain System: A destination chain system is a blockchain system that responds to cross-chain transactions initiated by the source chain system.

[0048] Cross-chain gateway: A cross-chain gateway is a connector between the source chain system and the destination chain system. A cross-chain gateway can capture cross-chain events generated in the source chain system and submit cross-chain transaction data to the destination chain system; alternatively, a cross-chain gateway can receive receipt information from the destination chain system and submit the receipt information to the source chain system.

[0049] Cross-chain transactions: Cross-chain transactions are transactions between two application chain systems, and may include information such as the source chain system identifier, the destination chain system identifier, the cross-chain transaction sequence number, and the call information.

[0050] The system architecture involved in the embodiments of this application will be described below.

[0051] The cross-chain transaction system in this application embodiment includes: a source chain system, a destination chain system, a first cross-chain gateway connected to the source chain system network, and a second cross-chain gateway connected to both the destination chain system and the first cross-chain gateway network.

[0052] In one implementation, see Figure 2 , Figure 2 This is a schematic diagram of a cross-chain transaction system provided in an embodiment of this application. Cross-chain gateways are connected to both the source chain system 201 and the destination chain system 202. A first cross-chain gateway 203 connected to the source chain system 201 is located in the same intranet as the source chain system 201. A second cross-chain gateway 204 connected to the destination chain system 202 is located in the same intranet as the destination chain system 202.

[0053] A direct network connection is established between the first cross-chain gateway 203 and the second cross-chain gateway 204. The first cross-chain gateway 203 can communicate with the second cross-chain gateway 204 via a wired network or a wireless network.

[0054] Both the source chain system 201 and the destination chain system 202 are blockchain systems, which can be as described above. Figure 1 The blockchain system 100 described in the embodiment.

[0055] In this embodiment of the application, there is a cross-chain transaction between the source chain system 201 and the destination chain system 202.

[0056] The first cross-chain gateway 203 or the second cross-chain gateway 204 can execute the following: Figure 3 The cross-chain transaction methods described in the various implementation processes of the embodiments are used to realize cross-chain transactions between the source chain system 201 and the destination chain system 202.

[0057] Source chain system 201 can execute the following: Figure 4 The cross-chain transaction methods described in the various implementation processes of the embodiments are used to realize cross-chain transactions between the first application chain system 204 and the second application chain system 205.

[0058] The cross-chain transaction method provided in the embodiments of this application will be explained in detail below.

[0059] Figure 3 This is a flowchart illustrating a cross-chain transaction method provided in an embodiment of this application. See also... Figure 3 This method is applied to a cross-chain gateway. The cross-chain gateway can be either the first cross-chain gateway 203 or the second cross-chain gateway 204 described above. That is, the cross-chain gateway can be either a source chain gateway or a destination chain gateway.

[0060] The cross-chain transaction method specifically includes the following steps.

[0061] Step 301: The cross-chain gateway obtains the target cross-chain transaction sent by the source chain system.

[0062] The source chain system includes a transaction management contract, which is used to record the transaction status of cross-chain transactions.

[0063] The transaction status can include a first status and a second status. The first status indicates that the cross-chain transaction is in the process of being processed, and the second status indicates that the cross-chain transaction is in the process of being completed.

[0064] Optionally, the second state can include different state values, such as a first state value, a second state value, and a third state value. The first state value indicates that the target cross-chain transaction timed out successfully (here, successful timeout processing means that the source chain system and the destination chain system successfully rolled back the data based on the timeout notification information). The second state value indicates that the target cross-chain transaction was executed successfully (here, successful transaction execution means that the target cross-chain transaction was successfully uploaded to the destination chain system). The third state value indicates that the target cross-chain transaction failed to execute (here, failed transaction execution means that the target cross-chain transaction failed to be uploaded to the destination chain system). Furthermore, the transaction state can also include a third state. The third state indicates that the cross-chain transaction is in an unprocessed state.

[0065] In a specific application that can be referenced, cross-chain transactions include different processing nodes such as BEGIN (starting node), SUCCESS (transaction executed successfully), FAIL (transaction executed unsuccessfully), BEGIN_ROLLBACK (transaction started rolling back), and ROLLBACK (transaction rolled back).

[0066] The state before the cross-chain transaction begins processing is the third state, corresponding to BEGIN, meaning the cross-chain transaction has been generated but has not yet officially started cross-chain processing. The first state of the cross-chain transaction corresponds to BEGIN_ROLLBACK, where the cross-chain transaction is in the process of processing. Specifically, a timeout occurs during processing, and both the source and destination chain systems need to perform data rollback operations. The second state of the cross-chain transaction is the completed transaction state, corresponding to ROLLBACK, SUCCESS, and FAIL, respectively. Each of these second states has a different value indicating the specific processing result: the first value corresponds to ROLLBACK (transaction rolled back), the second value corresponds to SUCCESS (transaction successfully executed), and the third value corresponds to FAIL (transaction failed). Step 302: If a timeout occurs in the target cross-chain transaction, a timeout notification is sent to both the source and destination chain systems.

[0067] The timeout notification is used to instruct the source chain system and the destination chain system to roll back the data.

[0068] In applications, when a timeout occurs during the transmission of information in a cross-chain transaction, the blockchain systems of both parties to the transaction need to be instructed to roll back the data to ensure the consistency of the transaction data.

[0069] The timeout during information transmission in a target cross-chain transaction can be caused by network anomalies between the source chain system and the cross-chain gateway, or by network anomalies between the cross-chain gateway and the target chain system.

[0070] Therefore, before executing step 302, it is necessary to determine whether the target cross-chain transaction has experienced a timeout during the information transmission process.

[0071] The determination of whether a timeout occurred during the information transmission of a target cross-chain transaction can include two scenarios. One is to determine whether the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway timed out, and the other is to determine whether the transmission of the target cross-chain transaction between the cross-chain gateway and the destination chain system timed out.

[0072] That is, a timeout in the transmission of a target cross-chain transaction can include a timeout in the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway, or it can include a timeout in the transmission of the target cross-chain transaction between the cross-chain gateway and the destination chain system.

[0073] In the first scenario, the determination of whether the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has timed out can be based on the time when the source chain system sends the target cross-chain transaction to the cross-chain gateway. If the cross-chain gateway does not receive the target cross-chain transaction within the set time after the source chain system sends it to the cross-chain gateway, it can be determined that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has timed out; otherwise, it has not timed out.

[0074] That is, in one implementation, the cross-chain transaction method further includes the following steps:

[0075] After receiving the target cross-chain transaction sent by the source chain system, the cross-chain gateway obtains a first time and a second time. Based on the first time and the second time, it determines a first duration for the target cross-chain transaction to be transmitted from the source chain system to the cross-chain gateway. If the first duration is greater than a first valid time threshold, it is determined that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has timed out. Alternatively, if the first duration is less than or equal to the first valid time threshold, it is determined that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has not timed out.

[0076] The first time is the time when the source chain system sends the target cross-chain transaction, and the second time is the time when the cross-chain gateway obtains the target cross-chain transaction.

[0077] The determination of the first time interval for the target cross-chain transaction to be transmitted from the source chain system to the cross-chain gateway can be obtained by subtracting the first time interval from the second time interval, or by adding or subtracting the information transmission time error based on the difference between the first time interval and the second time interval.

[0078] The first duration is then compared with a threshold to determine whether the transmission of the target cross-chain transaction has timed out.

[0079] When the cross-chain gateway is the destination chain gateway, it needs to apply for information access permissions from the source chain system.

[0080] After requesting information access permissions, it is possible to obtain the time or other information data of the target cross-chain transaction sent by the source chain system. Furthermore, if the first duration is less than or equal to the first valid time threshold, after determining that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has not timed out, the normal cross-chain transaction processing procedure can be executed to send the target cross-chain transaction to the destination chain system.

[0081] In one specific implementation, during the process of sending the target cross-chain transaction to the destination chain system, a first cross-chain gateway connected to the source chain system sends the target cross-chain transaction to a second cross-chain gateway connected to the destination chain system, and the second cross-chain gateway then sends the target cross-chain transaction to the destination chain system. In this process, the entity executing each step of the above cross-chain transaction method can be either the first cross-chain gateway or the second cross-chain gateway.

[0082] In the second scenario, the determination of whether the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has timed out can be based on the time when the cross-chain gateway sends the target cross-chain transaction to the target chain system. If the cross-chain gateway does not receive a cross-chain transaction receipt from the target chain system within the set time after sending the target cross-chain transaction to the target chain system, it can be determined that the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has timed out; otherwise, it has not timed out.

[0083] That is, in one implementation, the cross-chain transaction method further includes the following steps:

[0084] If no cross-chain transaction receipt is received from the target chain system within a preset time period after the target cross-chain transaction is sent to the target chain system, it is determined that the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has timed out; or, if a cross-chain transaction receipt is received from the target chain system within a preset time period after the target cross-chain transaction is sent to the target chain system, it is determined that the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has not timed out.

[0085] Cross-chain transaction receipts are used to indicate whether the target cross-chain transaction was successfully executed or failed.

[0086] Similarly, in this process, the entity executing each step of the cross-chain transaction method can be either the aforementioned first cross-chain gateway or the second cross-chain gateway.

[0087] Furthermore, in one specific implementation, upon determining that a target cross-chain transaction has timed out, after sending timeout notification information to both the source and destination chain systems, and upon receiving timeout processing acknowledgments from both systems based on the timeout notification information, a status update notification is sent to the source chain system. This status update notification instructs the source chain system to invoke the transaction management contract to change the transaction status of the target cross-chain transaction from a first state to a first state value in a second state. The first state value indicates that the timeout processing of the target cross-chain transaction was successful.

[0088] Correspondingly, after confirming that the transmission of the target cross-chain transaction between the cross-chain gateway and the destination chain system has not timed out, the normal cross-chain transaction processing procedure can be executed, and the cross-chain transaction receipt can be sent to the source chain system.

[0089] Among them, the cross-chain transaction receipt is used to instruct the source chain system to call the transaction management contract to set the transaction status of the target cross-chain transaction to the second or third state value in the second state.

[0090] The second state value indicates that the target cross-chain transaction was executed successfully, and the third state value indicates that the target cross-chain transaction failed to execute.

[0091] When the second state includes the above three state values, the target cross-chain transaction is executed normally if the transmission between the source chain system and the cross-chain gateway does not time out, and the transmission between the cross-chain gateway and the destination chain system does not time out. After the cross-chain gateway sends the cross-chain transaction receipt obtained from the destination chain system to the source chain system, the source chain system calls the transaction management contract to set the transaction status of the target cross-chain transaction to the second state value or the third state value in the second state, that is, to set the transaction status of the target cross-chain transaction to the completed state. At the same time, the second state value and the third state value in this state indicate whether the final processing result is successful or unsuccessful. By setting different state values ​​in the same state, different processing results corresponding to the completed cross-chain transaction state are indicated.

[0092] If a timeout occurs during the information transmission of the target cross-chain transaction, and both the source chain system and the destination chain system provide a timeout processing receipt based on the timeout notification information, the target cross-chain transaction rollback is completed. The source chain system calls the transaction management contract to set the transaction status of the target cross-chain transaction to the second status according to the first status value, that is, to set the final processing status of the target cross-chain transaction to transaction rollback completed, and the target cross-chain transaction is completed.

[0093] In the scenario where the blockchain system establishes a direct network connection through a cross-chain gateway, since there is no trusted third party as the transaction coordinator, the cross-chain gateway acts as the coordinator. At the same time, a cross-chain transaction management contract needs to be deployed on the source chain system to record the transaction status and ensure the data consistency processing between the source chain system and the destination chain system after the cross-chain transaction is executed, thus ensuring the data consistency and immutability under network instability.

[0094] In one specific implementation, step 302 above includes:

[0095] If a timeout occurs in the target cross-chain transaction, a first timeout notification is sent to the source chain system; if a timeout processing receipt indicating rollback completion is received from the source chain system based on the first timeout notification, a second timeout notification is sent to the destination chain system.

[0096] The second timeout notification is used to instruct the destination chain system to roll back the data.

[0097] The first timeout notification information is used to instruct the source chain system to perform data rollback based on the target cross-chain transaction and call the transaction management contract to change the transaction status of the target cross-chain transaction from the third state to the first state; the third state is used to indicate that the cross-chain transaction is in an unprocessed state.

[0098] Specifically, when the source chain system sends the target cross-chain transaction to the cross-chain gateway, the source chain system calls the transaction management contract to set the transaction status of the target cross-chain transaction to the third state. At this time, the target cross-chain transaction is in an unprocessed initial state.

[0099] In this embodiment, when the cross-chain gateway, which is the executing entity of the cross-chain transaction method, is a first cross-chain gateway connected to the source chain system, the source chain system can directly transmit data with the cross-chain gateway. When the cross-chain gateway, which is the executing entity of the cross-chain transaction method, is a second cross-chain gateway connected to the destination chain system, the data transmission between the source chain system and the cross-chain gateway needs to be achieved through forwarding by the first cross-chain gateway.

[0100] In the above implementation, the process of the cross-chain gateway sending timeout notification information to the source chain system and the destination chain system is executed sequentially. If a timeout occurs during the transmission of information in the target cross-chain transaction, a first timeout notification is sent to the source chain system. If a timeout processing receipt indicating rollback completion is received from the source chain system based on the first timeout notification, a second timeout notification is then sent to the destination chain system.

[0101] Furthermore, during this process, after the source chain system completes the data rollback based on the first timeout notification information, it needs to call the transaction management contract to change the transaction status of the target cross-chain transaction from the unprocessed state to the processing state, which specifically corresponds to the state of the BEGIN_ROLLBACK (transaction rollback in progress) node mentioned in the aforementioned embodiment.

[0102] This allows for timely identification of unprocessed cross-chain transactions before the outage, based on the transaction status of cross-chain transactions recorded in the source chain system after a subsequent gateway failure and restart. This enables timely anomaly handling, improves the fault tolerance of cross-chain transactions, and ensures data consistency between the blockchain systems of both parties in abnormal situations.

[0103] Therefore, in one implementation, the cross-chain transaction method further includes:

[0104] After the cross-chain gateway crashes and restarts, it identifies a specific cross-chain transaction whose transaction status is in the first state among the cross-chain transactions issued by the source chain system; and sends an exception notification message to the destination chain system corresponding to the specific cross-chain transaction.

[0105] The exception notification information is used to instruct the destination chain system corresponding to the specific cross-chain transaction to perform a data rollback.

[0106] The determination of a specific cross-chain transaction can also be achieved by combining the transaction status with the time the cross-chain transaction was sent to the cross-chain gateway. Specifically, cross-chain transactions whose transaction status is in the first state and whose sending time to the cross-chain gateway falls within a set time range can be identified as specific cross-chain transactions. This set time range can be a set duration before and after the cross-chain gateway crashes. This is merely an illustrative example and is not intended to be limiting.

[0107] Step 303: Upon receiving timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information, send a status update notification to the source chain system.

[0108] The status update notification information is used to instruct the source chain system to call the transaction management contract to change the transaction status of the target cross-chain transaction from the first status to the second status.

[0109] The first state is when the cross-chain transaction is not yet completed, and the second state is when the cross-chain transaction is completed.

[0110] In particular, regardless of whether the target cross-chain transaction times out during transmission between the source chain system and the cross-chain gateway, or between the cross-chain gateway and the destination chain system, the current target cross-chain transaction is considered invalid and a timeout notification needs to be sent to both the source chain system and the destination chain system.

[0111] The source chain system rolls back the target cross-chain transaction based on the timeout notification. At the same time, after receiving the timeout notification that instructs the destination chain system to roll back the data, the destination chain system needs to determine whether to roll back the data based on the timeout notification.

[0112] If the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway times out, and the destination chain system has not yet obtained the target cross-chain transaction, then no data rollback is required. However, if the transmission of the target cross-chain transaction between the cross-chain gateway and the destination chain system times out, and the destination chain system has not yet obtained the target cross-chain transaction, then no data rollback is required. If the destination chain system has obtained the target cross-chain transaction and performed on-chain processing, then a data rollback is required.

[0113] The destination blockchain system can compare the index of the target cross-chain transaction carried in the timeout notification with the total count of cross-chain transactions sent from the source blockchain system. If the index is greater than the total count, the destination blockchain system has not yet received the target cross-chain transaction, and no data rollback is required. In this case, the destination blockchain system increments the total count of cross-chain transactions that have occurred by 1 and sends a timeout processing receipt to the cross-chain gateway. If the index is less than or equal to the total count, it is determined that the destination blockchain system has already performed data on-chain processing for the target cross-chain transaction. In this case, the destination blockchain system needs to perform a data rollback operation corresponding to the target cross-chain transaction to ensure that the data in the destination blockchain system is consistent with the data in the source blockchain system.

[0114] During cross-chain transactions, it is essential to ensure consistency between the source and destination blockchain systems. An example illustrates the cross-chain transaction errors that can result from inconsistencies. For instance, a user wants to transfer assets from blockchain A to blockchain B. Blockchain A is the source blockchain, and blockchain B is the destination blockchain. If transaction consistency cannot be guaranteed, resulting in the asset transfer succeeding on the source blockchain but the user's account on the destination blockchain not having the corresponding asset data recorded, a cross-chain transaction error occurs, and the user loses the assets.

[0115] In the method provided in the embodiments of this application, combined with Figure 2 As shown, when the cross-chain gateway is the first cross-chain gateway, the processing flow is as follows:

[0116] The source chain system initiates a cross-chain transaction and specifies the timeout period at the business level. Simultaneously with the cross-chain event, the cross-chain contract records the transaction start time and the transaction state in the transaction management contract, setting the transaction state to BEGIN. The first cross-chain gateway detects this transaction. To prevent timeouts due to link anomalies between the source chain system and the first cross-chain gateway, the first cross-chain gateway first determines if the transaction has timed out. If it has, the first cross-chain gateway notifies the source chain system to roll back. After a successful rollback, the source chain system updates the corresponding transaction state in the transaction management contract to BEGIN_ROLLBACK and sends a rollback success receipt to the first cross-chain gateway. Subsequently, the first cross-chain gateway notifies the destination chain system to roll back via the second cross-chain gateway. The destination chain system determines whether to execute the rollback operation. The destination chain system sends a receipt to the first cross-chain gateway via the second cross-chain gateway. The first cross-chain gateway then sends a status update notification to the source chain system. Upon receiving this notification, the source chain system updates the corresponding transaction state in the transaction management contract to ROLLBACK. The cross-chain transaction has been terminated.

[0117] If no timeout occurs, the first cross-chain gateway sends the cross-chain transaction to the second cross-chain gateway via the direct connection network. Upon receiving the transaction, the second cross-chain gateway, without regard to its transaction status, directly submits it to the destination chain system for execution. The destination chain system then sends a receipt to the first cross-chain gateway based on the execution result. Simultaneously, a timer begins when the first cross-chain gateway sends the transaction to the second cross-chain gateway via the direct connection network to determine if the transmission of the cross-chain transaction between the first and destination chain systems has timed out. If the transaction execution result is not received from the destination chain system via the second cross-chain gateway within a set time after the start of the timer, the transmission of the cross-chain transaction between the first and destination chain systems is considered to have timed out. Alternatively, if the time between the start of the timer and the time when the transaction execution result is received from the destination chain system via the second cross-chain gateway exceeds a threshold, the transmission of the cross-chain transaction between the first and destination chain systems is also considered to have timed out.

[0118] In one implementation, if the cross-chain transaction times out during transmission between the first cross-chain gateway and the destination chain system, the first cross-chain gateway first notifies the source chain system to roll back. After a successful rollback, the source chain system updates the corresponding transaction status in its transaction management contract to BEGIN_ROLLBACK and sends a rollback success receipt to the first cross-chain gateway. The first cross-chain gateway then notifies the destination chain system to roll back via a second cross-chain gateway. The destination chain system determines whether to execute the rollback operation and sends a receipt to the first cross-chain gateway via the second cross-chain gateway. The first cross-chain gateway then sends a status update notification to the source chain system. Upon receiving this notification, the source chain system updates the corresponding transaction status in its transaction management contract to ROLLBACK. The cross-chain transaction is terminated.

[0119] If the cross-chain transaction transmission between the first cross-chain gateway and the destination chain system does not time out, after the destination chain system processes the cross-chain transaction on-chain, the second cross-chain gateway sends a cross-chain transaction receipt back to the first cross-chain gateway. The first cross-chain gateway then submits the cross-chain transaction receipt to the source chain system for execution. The source chain system updates the corresponding transaction status in the transaction management contract to SUCCESS or FAIL depending on whether the cross-chain transaction was successfully executed. If the cross-chain transaction fails in the destination chain system, the destination chain system must first perform a data revert to restore its state before the cross-chain transaction execution and send a cross-chain transaction receipt indicating the failure back to the first cross-chain gateway. After the first cross-chain gateway submits the cross-chain transaction receipt to the source chain system, the source chain system needs to perform a data rollback based on this receipt. Only after both the source and destination chain systems have successfully rolled back their data does the source chain system set the transaction status to FAIL, thus terminating the cross-chain transaction. If the cross-chain transaction receipt sent by the first cross-chain gateway to the source chain system indicates that the cross-chain transaction was successfully executed, the source chain system can directly set the transaction status of the cross-chain transaction to SUCCESS. The cross-chain transaction is terminated.

[0120] When the first cross-chain gateway crashes and restarts, during the abnormal recovery phase, it is necessary to check the transaction status of the cross-chain transactions issued by the source chain system. If the transaction status is BEGIN_ROLLBACK, a rollback notification needs to be sent to the second cross-chain gateway to notify the destination chain system to roll back. The destination chain system then determines whether to roll back and performs subsequent processing actions.

[0121] If the cross-chain transaction status is SUCCESS, FAIL, or ROLLBACK, it means that the cross-chain transaction has been completed.

[0122] In the example above, when the first cross-chain gateway notifies the source and destination chain systems to perform a rollback, the notifications can be executed in any order to improve system processing efficiency. However, performing rollback notifications in a specific order ensures the effective execution of the data rollback process and provides transaction status records for handling anomalies after a cross-chain gateway crashes and restarts, thus improving the fault tolerance of cross-chain transaction processing.

[0123] Unlike the method provided in the embodiments of this application, which combines Figure 2 As shown, when the cross-chain gateway is the second cross-chain gateway, the processing flow is as follows:

[0124] The source chain system initiates a cross-chain transaction and specifies the timeout period for the transaction at the business level. Simultaneously with triggering the cross-chain event, the cross-chain contract records the transaction start time and the transaction state in the transaction management contract, setting the transaction state to BEGIN. This cross-chain transaction is sent from the source chain system to the second cross-chain gateway via the first cross-chain gateway. Upon receiving the cross-chain transaction, the second cross-chain gateway, to prevent timeouts caused by link anomalies between the source chain system and the first cross-chain gateway, or between the first and second cross-chain gateways, firstly determines whether a timeout has occurred between the source chain system and the second cross-chain gateway. If a timeout occurs, the second cross-chain gateway first notifies the source chain system to roll back via the first cross-chain gateway. After a successful rollback, the source chain system updates the corresponding transaction status in its transaction management contract to BEGIN_ROLLBACK and sends a rollback success receipt to the second cross-chain gateway via the first cross-chain gateway. Subsequently, the second cross-chain gateway notifies the destination chain system to roll back. The destination chain system determines whether to execute the rollback operation and sends a receipt to the second cross-chain gateway. The second cross-chain gateway then sends a status update notification to the source chain system via the first cross-chain gateway. Upon receiving this notification, the source chain system updates the corresponding transaction status in its transaction management contract to ROLLBACK. The cross-chain transaction terminates.

[0125] If no timeout occurs, the second cross-chain gateway directly submits the cross-chain transaction to the destination chain system for execution. The destination chain system then sends a receipt to the second cross-chain gateway based on the execution result. Simultaneously, when the second cross-chain gateway sends the cross-chain transaction to the destination chain system via the direct connection network, a timer is also started to recalculate whether the transaction will time out due to link anomalies between the second cross-chain gateway and the destination chain system.

[0126] In one implementation, if the cross-chain transaction times out during transmission between the second cross-chain gateway and the destination chain system, the second cross-chain gateway first notifies the source chain system to roll back. After a successful rollback, the source chain system updates the corresponding transaction status in its transaction management contract to BEGIN_ROLLBACK and sends a rollback success receipt to the second cross-chain gateway via the first cross-chain gateway. The second cross-chain gateway then notifies the destination chain system to roll back. The destination chain system determines whether to execute the rollback operation and sends a receipt to the second cross-chain gateway. The second cross-chain gateway then sends a status update notification to the source chain system via the first cross-chain gateway. Upon receiving this notification, the source chain system updates the corresponding transaction status in its transaction management contract to ROLLBACK. The cross-chain transaction is terminated.

[0127] If the cross-chain transaction is transmitted between the second cross-chain gateway and the destination chain system without timeout, the destination chain system processes the cross-chain transaction on-chain and sends a cross-chain transaction receipt to the second cross-chain gateway. The second cross-chain gateway then submits the receipt to the source chain system for execution via the first cross-chain gateway. The source chain system updates the corresponding transaction status in the transaction management contract to SUCCESS or FAIL based on the cross-chain transaction receipt, depending on whether the cross-chain transaction was successfully executed. If the cross-chain transaction fails in the destination chain system, the destination chain system must first revert its data to the state before the cross-chain transaction execution and send a cross-chain transaction receipt indicating failure to the second cross-chain gateway. The second cross-chain gateway then submits the receipt to the source chain system via the first cross-chain gateway. The source chain system then performs a data rollback based on this receipt. Only after both the source and destination chains have successfully rolled back their data does the source chain system set the transaction status to FAIL, terminating the cross-chain transaction. If the second cross-chain gateway sends a cross-chain transaction receipt to the source chain system via the first cross-chain gateway, indicating that the cross-chain transaction was successfully executed, the source chain system can directly set the transaction status of the cross-chain transaction to SUCCESS. The cross-chain transaction is terminated.

[0128] When the second cross-chain gateway crashes and restarts, during the abnormal recovery phase, it is necessary to check the transaction status of the cross-chain transactions issued by the source chain system. If the transaction status is BEGIN_ROLLBACK, the destination chain system needs to be notified to roll back. The destination chain system then determines whether to roll back and performs subsequent processing actions.

[0129] If the cross-chain transaction status is SUCCESS, FAIL, or ROLLBACK, it means that the cross-chain transaction has been completed.

[0130] In the example above, when the second cross-chain gateway notifies the source and destination chain systems to perform a rollback, the notifications can be executed in any order to improve system processing efficiency. However, performing rollback notifications in a specific order ensures the effective execution of the data rollback process and provides transaction status records for handling anomalies after a cross-chain gateway crashes and restarts, thus improving the fault tolerance of cross-chain transaction processing.

[0131] In this embodiment, a transaction management contract is set up in the source chain system to record the transaction status of cross-chain transactions. Combined with the timeout judgment during the information transmission process of the cross-chain transactions sent by the source chain system, timeout notification information is sent to the source chain system and the destination chain system in a timely manner to instruct the two systems to roll back the data. Based on the timeout processing receipts of the two systems, it is ensured that the source chain system effectively updates the transaction status of the cross-chain transactions. In this process, the cross-chain gateway acts as the coordinator of data consistency and records the transaction status in conjunction with the transaction management contract deployed on the source chain system. This ensures the data consistency processing of cross-chain transactions between the source chain system and the destination chain system after the cross-chain transaction is executed, and ensures the data status consistency and immutability under network instability.

[0132] Figure 4 This is a flowchart of another cross-chain transaction method provided in an embodiment of this application. See also... Figure 4 This method is applied to a source chain system that includes a transaction management contract. This transaction management contract is used to record the transaction status of cross-chain transactions. The cross-chain transaction method includes the following steps.

[0133] Step 401: The source chain system sends the target cross-chain transaction to the cross-chain gateway.

[0134] Step 402: Obtain the timeout notification information sent by the cross-chain gateway.

[0135] This timeout notification is sent by the cross-chain gateway when it determines that a target cross-chain transaction has timed out. This timeout notification is used to indicate that a target cross-chain transaction has timed out.

[0136] Step 403: Roll back the data based on the timeout notification information and send a timeout processing receipt to the cross-chain gateway.

[0137] In one embodiment of this step, after obtaining the timeout notification information sent by the cross-chain gateway in step 402, the method further includes:

[0138] The transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the third state to the first state; the third state is used to indicate that the cross-chain transaction is in an unprocessed state.

[0139] More specifically, optionally, when the source chain system calls the transaction management contract to change the transaction status of the target cross-chain transaction from the third state to the first state, it is necessary to confirm that the data rollback was successful based on the timeout notification information.

[0140] Step 404: Upon receiving the status update notification information sent by the cross-chain gateway, the transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the first state to the second state.

[0141] The first state indicates that the cross-chain transaction is in the process of being processed, and the second state indicates that the cross-chain transaction is in the process of being completed. The status update notification information is sent by the cross-chain gateway when it receives the timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information.

[0142] Further, in an optional implementation, step 404, which invokes the transaction management contract to change the transaction state of the target cross-chain transaction from the first state to the second state, includes:

[0143] The source chain system calls the transaction management contract to change the transaction status of the target cross-chain transaction from the first status to the first status value in the second status. The first status value is used to indicate that the target cross-chain transaction timed out successfully.

[0144] Correspondingly, in an optional implementation, after sending the target cross-chain transaction to the cross-chain gateway in step 401, the method further includes:

[0145] Obtain the cross-chain transaction receipt sent by the cross-chain gateway, and based on the cross-chain transaction receipt, call the transaction management contract to set the transaction status of the target cross-chain transaction to the second state value or the third state value in the second state.

[0146] The cross-chain transaction receipt is sent from the target chain system to the cross-chain gateway after receiving the target cross-chain transaction. The cross-chain transaction receipt is used to indicate whether the target cross-chain transaction was executed successfully or failed. The second status value is used to indicate that the target cross-chain transaction was executed successfully, and the third status value is used to indicate that the target cross-chain transaction failed.

[0147] A cross-chain transaction receipt is sent by the cross-chain gateway to the source chain system when it is determined that the target cross-chain transaction has not experienced a delivery timeout.

[0148] The specific implementation process of each of the above steps has been described in the specific implementation process of steps 301 to 303 of the foregoing embodiments, and will not be repeated here.

[0149] The cross-chain gateway in each of the above steps can be... Figure 2The first cross-chain gateway 203 or the second cross-chain gateway 204. That is, the cross-chain gateway can be either the source chain gateway or the destination chain gateway.

[0150] Specifically, when the cross-chain gateway is the first cross-chain gateway connected to the source chain system, the source chain system can directly transmit data with the cross-chain gateway; when the cross-chain gateway is the second cross-chain gateway connected to the destination chain system, the data transmission between the source chain system and the cross-chain gateway needs to be forwarded through the first cross-chain gateway.

[0151] Furthermore, in an optional implementation, after receiving the cross-chain transaction receipt sent by the cross-chain gateway, if the cross-chain transaction receipt indicates that the target cross-chain transaction failed, the source chain system performs a data rollback based on the cross-chain transaction receipt. This data rollback operation restores the data changes in the source chain system based on the target cross-chain transaction.

[0152] In this embodiment, a transaction management contract is set up in the source chain system to record the transaction status of cross-chain transactions. Combined with the timeout judgment during the information transmission process of the cross-chain transactions sent by the source chain system, timeout notification information is sent to the source chain system and the destination chain system in a timely manner to instruct the two systems to roll back the data. Based on the timeout processing receipts of the two systems, it is ensured that the source chain system effectively updates the transaction status of the cross-chain transactions. In this process, the cross-chain gateway acts as the coordinator of data consistency and records the transaction status in conjunction with the transaction management contract deployed on the source chain system. This ensures the data consistency processing of cross-chain transactions between the source chain system and the destination chain system after the cross-chain transaction is executed, and ensures the data status consistency and immutability under network instability.

[0153] Figure 5 This is a structural diagram of a computer device provided in an embodiment of this application. As shown in the figure, the computer device 5 of this embodiment includes: at least one processor 50 ( Figure 5 Only one is shown in the diagram), memory 51, and computer program 52 stored in said memory 51 and executable on said at least one processor 50, wherein said processor 50 executes said computer program 52 to implement the foregoing. Figure 3 The steps in the cross-chain transaction method described in the embodiment.

[0154] The computer device 5 may be a gateway device.

[0155] The computer device 5 may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will understand that... Figure 5This is merely an example of computer device 5 and does not constitute a limitation on computer device 5. It may include more or fewer components than shown, or combine certain components, or different components. For example, the terminal may also include input / output devices, network access devices, buses, etc.

[0156] The processor 50 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0157] The memory 51 can be an internal storage unit of the computer device 5, such as a hard disk or memory of the computer device 5. The memory 51 can also be an external storage device of the computer device 5, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device 5. Furthermore, the memory 51 can include both internal and external storage units of the computer device 5. The memory 51 is used to store the computer program and other programs and data required by the terminal. The memory 51 can also be used to temporarily store data that has been output or will be output.

[0158] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0159] Figure 6 This is a structural diagram of another computer device provided in an embodiment of this application. As shown in the figure, the computer device 6 of this embodiment includes: at least one processor 60 ( Figure 6 Only one is shown in the diagram), memory 61, and computer program 62 stored in said memory 61 and executable on said at least one processor 60, wherein said processor 60 executes said computer program 62 to implement the foregoing. Figure 4 The steps in the cross-chain transaction method described in the embodiment.

[0160] The computer device 6 may be a server cluster including multiple servers, and specifically, the computer device 6 may be a blockchain system.

[0161] The computer device 6 may include, but is not limited to, a processor 60 and a memory 61. Those skilled in the art will understand that... Figure 6 This is merely an example of computer device 6 and does not constitute a limitation on computer device 6. It may include more or fewer components than shown, or combine certain components, or different components. For example, the terminal may also include input / output devices, network access devices, buses, etc.

[0162] The processor 60 can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0163] The memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. The memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, or Flash Card equipped on the computer device 6. Furthermore, the memory 61 can include both internal and external storage units of the computer device 6. The memory 61 is used to store the computer program and other programs and data required by the terminal. The memory 61 can also be used to temporarily store data that has been output or will be output.

[0164] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0165] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0166] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0167] In the embodiments provided in this application, it should be understood that the disclosed devices / terminals and methods can be implemented in other ways. For example, the device / terminal embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the displayed or discussed mutual coupling or direct coupling or communication connection may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0168] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0169] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0170] If the integrated module / unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments can also be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording media, USB flash drives, portable hard drives, magnetic disks, optical disks, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium can be appropriately added or removed according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electrical carrier signals and telecommunication signals.

[0171] The methods described in this application can be implemented in whole or in part by a computer program product. When the computer program product is run on a terminal, the terminal executes the steps in the various method embodiments described above.

[0172] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.

Claims

1. A cross-chain transaction method, characterized in that, It is applied to a cross-chain gateway, wherein the cross-chain gateway is a first cross-chain gateway or a second cross-chain gateway; the first cross-chain gateway is connected to the source chain system and is located in the same intranet as the source chain system; the second cross-chain gateway is connected to the destination chain system and is located in the same intranet as the destination chain system. A direct network connection is established between the first cross-chain gateway and the second cross-chain gateway; The method includes: The system obtains the target cross-chain transaction sent by the source chain system, which is equipped with a transaction management contract. The transaction management contract is used to record the transaction status of the cross-chain transaction. If a timeout occurs in the target cross-chain transaction, a timeout notification is sent to the source chain system and the destination chain system. The timeout notification is used to instruct the source chain system and the destination chain system to perform data rollback. Upon receiving timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information, a status update notification is sent to the source chain system. The status update notification information is used to instruct the source chain system to call the transaction management contract to change the transaction status of the target cross-chain transaction from the first status to the second status. The first status indicates that the cross-chain transaction is in the processing state, and the second status indicates that the cross-chain transaction is in the processing completed state.

2. The method according to claim 1, characterized in that, The method further includes: After obtaining the target cross-chain transaction sent by the source chain system, a first time and a second time are obtained. The first time is the time when the source chain system sends the target cross-chain transaction, and the second time is the time when the cross-chain gateway obtains the target cross-chain transaction. Based on the first time and the second time, a first duration is determined for which the target cross-chain transaction is transmitted from the source chain system to the cross-chain gateway. If the first duration is greater than the first valid time threshold, it is determined that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has timed out; or, if the first duration is less than or equal to the first valid time threshold, it is determined that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has not timed out.

3. The method according to claim 2, characterized in that, After determining that the transmission of the target cross-chain transaction between the source chain system and the cross-chain gateway has not timed out, the process further includes: Send the target cross-chain transaction to the target chain system.

4. The method according to claim 1, characterized in that, The method further includes: If no cross-chain transaction acknowledgment is received from the target chain system within a preset time period after the target cross-chain transaction is sent to the target chain system, it is determined that the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has timed out; or, If a cross-chain transaction receipt is received from the target chain system within a preset time period after the target cross-chain transaction is sent to the target chain system, it is determined that the transmission of the target cross-chain transaction between the cross-chain gateway and the target chain system has not timed out. The cross-chain transaction receipt is used to indicate whether the target cross-chain transaction was executed successfully or failed.

5. The method according to claim 4, characterized in that, The status update notification information is used to instruct the source chain system to call the transaction management contract to set the transaction status of the target cross-chain transaction from the first status to the first status value in the second status, and the first status value is used to indicate that the target cross-chain transaction timeout processing was successful; After determining that the transmission of the target cross-chain transaction between the cross-chain gateway and the destination chain system has not timed out, the process further includes: The cross-chain transaction receipt is sent to the source chain system. The cross-chain transaction receipt is used to instruct the source chain system to call the transaction management contract to set the transaction status of the target cross-chain transaction to the second status value or the third status value in the second status. The second status value is used to indicate that the target cross-chain transaction was executed successfully, and the third status value is used to indicate that the target cross-chain transaction failed to execute.

6. The method according to claim 1, characterized in that, The step of sending timeout notification information to both the source chain system and the destination chain system when it is determined that the target cross-chain transaction has timed out includes: If a timeout occurs in the target cross-chain transaction, a first timeout notification is sent to the source chain system. The first timeout notification is used to instruct the source chain system to roll back the data based on the target cross-chain transaction and call the transaction management contract to change the transaction status of the target cross-chain transaction from the third state to the first state. The third state is used to indicate that the cross-chain transaction is in an unprocessed state. If a timeout processing receipt indicating rollback completion is received from the source chain system based on the first timeout notification information, a second timeout notification information is sent to the destination chain system. The second timeout notification information is used to instruct the destination chain system to perform data rollback.

7. The method according to claim 6, characterized in that, The method further includes: After a system crash and restart, identify the specific cross-chain transactions whose transaction status is the first state among the cross-chain transactions issued by the source chain system; An anomaly notification is sent to the destination chain system corresponding to the specific cross-chain transaction; the anomaly notification is used to instruct the destination chain system corresponding to the specific cross-chain transaction to perform a data rollback.

8. A cross-chain transaction method, characterized in that, The system is applied to a source chain system, which is connected to a first cross-chain gateway. The first cross-chain gateway and the source chain system are in the same intranet. A direct network connection is established between the first cross-chain gateway and a second cross-chain gateway. The second cross-chain gateway is connected to a destination chain system, which is in the same intranet as the destination chain system. The source chain system includes a transaction management contract, which is used to record the transaction status of cross-chain transactions. The method includes: Send the target cross-chain transaction to the cross-chain gateway; the cross-chain gateway is either the first cross-chain gateway or the second cross-chain gateway; Obtain the timeout notification information sent by the cross-chain gateway, the timeout notification information being used to indicate that the target cross-chain transaction has timed out; Based on the timeout notification information, data rollback is performed, and a timeout processing receipt is sent to the cross-chain gateway. Upon receiving the status update notification information sent by the cross-chain gateway, the transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the first status to the second status. The first status indicates that the cross-chain transaction is in the processing state, and the second status indicates that the cross-chain transaction is in the processing completed state. The status update notification information is sent by the cross-chain gateway upon receiving the timeout processing receipts from the source chain system and the destination chain system based on the timeout notification information.

9. The method according to claim 8, characterized in that, The step of invoking the transaction management contract to change the transaction status of the target cross-chain transaction from the first state to the second state includes: The transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the first status to the first status value in the second status, whereby the first status value indicates that the target cross-chain transaction timed out successfully. After sending the target cross-chain transaction to the cross-chain gateway, the process also includes: Obtain the cross-chain transaction receipt sent by the cross-chain gateway. The cross-chain transaction receipt is fed back to the cross-chain gateway by the target chain system after receiving the target cross-chain transaction. The cross-chain transaction receipt is used to indicate whether the target cross-chain transaction was executed successfully or failed. Based on the cross-chain transaction receipt, the transaction management contract is invoked to set the transaction status of the target cross-chain transaction to either the second or third state value in the second state. The second state value indicates that the target cross-chain transaction was executed successfully, and the third state value indicates that the target cross-chain transaction failed to execute.

10. The method according to claim 8, characterized in that, After obtaining the timeout notification information sent by the cross-chain gateway, the process further includes: The transaction management contract is invoked to change the transaction status of the target cross-chain transaction from the third state to the first state; the third state is used to indicate that the cross-chain transaction is in an unprocessed state.

11. A cross-chain transaction system, characterized in that, include: Source chain system; Destination chain system; The first cross-chain gateway is connected to the source chain system network; The first cross-chain gateway and the source chain system are on the same intranet; The second cross-chain gateway is connected to both the destination chain system and the first cross-chain gateway network; the second cross-chain gateway and the destination chain system are located in the same intranet. The source chain system is used to execute the cross-chain transaction method as described in any one of claims 8 to 10; Wherein, the first cross-chain gateway is used to execute the cross-chain transaction method as described in any one of claims 1 to 7, or the second cross-chain gateway is used to execute the cross-chain transaction method as described in any one of claims 1 to 7.

12. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method as described in any one of claims 1 to 10.

13. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method as described in any one of claims 1 to 10.