Cross-chain transaction method and device
By obtaining and considering the status of all related transactions in cross-chain transactions, the problem of inconsistent execution of cross-chain transactions on multiple blockchains is solved, and atomic execution is realized, ensuring that all transactions are successfully executed on multiple blockchains.
Patent Information
- Application Number
- CN202411981713.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Priority Date
- 2019-07-26
- Filing Date
- 2019-11-18
- Publication Date
- 2025-07-01
AI Technical Summary
In the prior art, when interrelated cross-chain transactions are executed on multiple blockchains, problems are prone to occur where only one of them is successful while the other is not successfully executed, resulting in transaction inconsistency.
After determining the first transaction state at the first node, obtain the second transaction state, and modify the state machine of the first node when the second transaction state is successful, ensure that the execution of cross-chain transactions depends on the consensus verification results of all related transactions, and achieve atomic execution.
It realizes the consistent execution of cross-chain transactions on multiple blockchains, avoiding the success of some transactions while the failure of the other part, ensuring the atomicity and integrity of the transactions.
Smart Images

Figure CN120235699A_ABST
Abstract
Description
[0001] This application is a divisional application. The application number of the original application is 201911129391.6, and the filing date of the original application is November 18, 2019. The entire content of the original application is incorporated herein by reference. Technical Field
[0002] This application relates to the field of Internet technologies, and in particular, to a cross-chain transaction method and apparatus. Background Art
[0003] In a blockchain system, data is stored in blocks. Newly written data forms a new block and is added to the end of the current blockchain. While each block stores data, it also stores a number (usually the hash value of all the data records) that uniquely corresponds to all the data records in the previous block, thus forming a chain. Therefore, a blockchain system can be regarded as a system in which computers on a distributed network that do not fully trust each other jointly maintain a set of traceable and immutable chain data through consensus rules.
[0004] In one scenario, cross-chain transactions between blockchains can refer to user A using their assets in blockchain 1 to pay user B in blockchain 2 a certain amount of assets in blockchain 2. At this time, the cross-chain transaction can include two interrelated cross-chain transactions (the first transaction and the second transaction). Among them, the first transaction refers to user A deducting a certain amount of assets, and the second transaction refers to user B increasing a certain amount of assets.
[0005] The implementation solution in the prior art is as follows: Determine an intermediate chain to act as an intermediary. User A initiates a transaction in blockchain 1. When the intermediate chain determines that the first transaction is successfully executed on blockchain 1, it initiates a transaction to blockchain 2 to execute the second transaction on blockchain 2. If the second transaction fails for some reason, the already successful transaction (the first transaction) needs to be revoked. However, the already successful transaction may not be able to be revoked, and thus only part of the interrelated cross-chain transactions are successfully executed, while the other part is not.
[0006] In summary, there is an urgent need for a cross-chain transaction method to solve the problem of atomic execution of interrelated cross-chain transactions on multiple blockchains. Summary of the Invention
[0007] An embodiment of this application provides a cross-chain transaction method, which can enable cross-chain transactions to be atomically executed on multiple blockchains.
[0008] In a first aspect, the present application provides a cross-chain transaction method, which is applied to a first node. The first node maintains a first blockchain. A first transaction belongs to the first blockchain. The first transaction and a second transaction are associated cross-chain transactions. The second transaction belongs to a second blockchain, and a second node maintains the second blockchain. The method includes: the first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes the consensus verification; the first node obtains the transaction status of the second transaction; when the transaction status of the second transaction is the first status, the first node modifies target data according to the transaction data of the first transaction, and the target data is data in the state machine of the first node related to the first transaction. In this embodiment, if a transaction belongs to a blockchain, the node that maintains the blockchain participates in the construction of the blockchain. For example, it can perform at least one of the following actions: generation of a transaction, consensus on transaction data, execution of a smart contract related to the transaction, generation of a block related to the transaction, and modification of target data in the state machine related to the transaction. The node can obtain transaction data from the maintained blockchain, where the transaction data can indicate the specific content of the transaction or describe the details of the transaction. For example, data that only indicates the transaction status, such as whether the transaction is successful, should not be understood as transaction data in the present application. The first transaction and the second transaction can be associated. For example, the first transaction and the second transaction are different sub-transactions of the same transaction. Specifically, in the transaction data of the first transaction and the second transaction, there is an identifier indicating their association. For example, they can have the same or associated identifier ID. In this embodiment, the first node can actively initiate the modification of the target data in the state machine of the first node based on the transaction status of the second transaction. The target data can be a field in the state machine of the first node related to the transaction status of the first transaction. For example, the target data may include one or several types of the transaction data described above. In the scenario of financial transfer, the target data can be the account balance. For example: A transfers X units of currency to B. The first transaction is that A's account balance decreases by X units of currency, and the second transaction is that B's account balance increases by X units of currency. Then the target data is A's account balance; in the scenario of issuing an invoice, the target data can be the invoice amount. For example: A issues an invoice with an amount of X units to B. The first transaction is that A issues an invoice with an amount of X units to B, and the second transaction is that B receives the invoice issued by A with an amount of X units. Then the target data is the amount of the invoice issued by A to B; in the scenario of currency exchange for goods, the target data can be the account balance or the quantity of goods. For example: A transfers X units of currency to B, and B transfers Y units of goods to A. Then the first transaction is that A's account balance decreases by X units of currency, and the second transaction is that B decreases Y units of goods. Then the target data is A's account balance.
[0009] In a possible design of the first aspect, the first node obtaining the transaction status of the second transaction includes: the first node obtaining a first block including the transaction status of the second transaction, where the first block is from a third node that does not maintain the first blockchain and the second blockchain. In this embodiment, the third node not maintaining the first blockchain and the second blockchain can be understood as the third node being unable to obtain data from the first blockchain and the second blockchain; it should be noted that the third node not maintaining the first blockchain and the second blockchain can be understood as the third node being unable to obtain the transaction data of the first transaction and the second transaction from the first blockchain and the second blockchain. From another perspective, the third node does not provide hardware resources for the calculation of the first transaction and the calculation of the second transaction. It should be noted that the third node not maintaining the first blockchain and the second blockchain can be understood as the third node not performing the following actions: generation of the first transaction, generation of the second transaction, consensus on the transaction data of the first transaction and the second transaction, execution of the smart contract related to the first transaction and the second transaction, and modification of the target data in the state machine related to the first transaction and the second transaction.
[0010] In a possible design of the first aspect, the method further includes:
[0011] The first node sending the transaction status of the first transaction to a third node that does not maintain the first blockchain and the second blockchain.
[0012] In a possible design of the first aspect, the first node sending the transaction status of the first transaction to a third node includes:
[0013] The first node sending a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
[0014] In a possible design of the first aspect, the method further includes:
[0015] The first node sending a fifth transaction to the third node, where the fifth transaction includes timeout information for indicating that the third node has not received the transaction status of the second transaction from the second node;
[0016] When the first node fails to obtain the transaction status of the second transaction and obtains the second block including the timeout information on the third blockchain, the first node does not modify the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction. In this embodiment, the first node may not modify the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, may modify the target data related to the first transaction in the state machine of the first node according to other information, or may not modify the target data related to the first transaction in the state machine of the first node.
[0017] In a possible design of the first aspect, the method further includes:
[0018] The first node calculates the first hash of the second transaction or receives the first hash of the second transaction sent by the first client, where the first client is the initiator of the first transaction;
[0019] The first node receives the second hash of the second transaction sent by the third node;
[0020] Wherein, the equality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is correct; the inequality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is incorrect.
[0021] In a possible design of the first aspect, the method further includes:
[0022] The first node calculates the first hash of the first transaction or receives the first hash of the first transaction sent by the first client;
[0023] The first node sends the first hash of the first transaction to the third node.
[0024] In a possible design of the first aspect, after the first node modifies the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, the method further includes:
[0025] The first node broadcasts synchronization information to the fourth node, where the synchronization information is used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, and the first node and the fourth node belong to the same node cluster.
[0026] In a second aspect, the present application provides a cross-chain transaction method, and the method includes:
[0027] The third node receives the transaction status of the second transaction sent by the second node, where the second node maintains a second blockchain, and the second transaction belongs to the second blockchain;
[0028] The third node sends the transaction status of the second transaction to the first node, so that the first node processes target data based on the transaction status of the second transaction and the transaction status of the first transaction, where the target data is the data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are associated cross-chain transactions, the first transaction belongs to a first blockchain, the first node maintains the first blockchain, and the third node does not maintain the first blockchain and the second blockchain.
[0029] In a possible design of the second aspect, the method further includes:
[0030] The third node generates a first block including the transaction status of the second transaction.
[0031] In a possible design of the second aspect, the method further includes:
[0032] The third node receives transactions sent by at least one fifth node;
[0033] The third node generates a first block including the transaction status of the second transaction, including:
[0034] The third node sorts the transactions sent by the at least one fifth node and the transaction status of the second transaction based on the time of receiving the transactions sent by the at least one fifth node and the time of receiving the transaction status of the second transaction, and generates at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
[0035] In a possible design of the second aspect, the third node sending the transaction status of the second transaction to the first node includes:
[0036] The third node sends the first block to the first node.
[0037] In a possible design of the second aspect, the third node receiving the transaction status of the second transaction sent by the second node includes:
[0038] The third node receives a fourth transaction sent by the second node, and the fourth transaction includes the transaction status of the second transaction.
[0039] In a possible design of the second aspect, the method further includes:
[0040] The third node receives the second hash of the second transaction sent by the second node;
[0041] The third node sends the second hash of the second transaction to the first node, so that the first node determines the correctness of the transaction data of the second transaction based on the second hash and the first hash of the second transaction, where the first hash of the second transaction is calculated by the first node or comes from a first client, and the first client is the initiator of the first transaction.
[0042] In a third aspect, the present application provides a cross-chain transaction method, which is applied to a cross-chain transaction system. The cross-chain transaction system includes a first node, a second node, and a third node. The first node maintains a first blockchain, and the first transaction belongs to the first blockchain. The first transaction and the second transaction are associated cross-chain transactions. The second transaction belongs to a second blockchain, and the second node maintains the second blockchain. The third node does not maintain the first blockchain and the second blockchain. The method includes:
[0043] The first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes the consensus check;
[0044] The second node sends the transaction status of the second transaction to the third node;
[0045] The third node sends the transaction status of the second transaction to the first node;
[0046] When the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node.
[0047] In a possible design of the third aspect, the method further includes:
[0048] The third node generates a first block including the transaction status of the second transaction.
[0049] In a possible design of the third aspect, the method further includes:
[0050] The third node receives transactions sent by at least one fourth node;
[0051] The third node generates a first block including the transaction status of the second transaction, including:
[0052] The third node sorts the transactions sent by the at least one fifth node and the transaction status of the second transaction based on the time of receiving the transactions sent by the at least one fifth node and the time of receiving the transaction status of the second transaction, and generates at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
[0053] In a possible design of the third aspect, the third node sending the transaction status of the second transaction to the first node includes:
[0054] The third node sends the first block to the first node.
[0055] In a possible design of the third aspect, the second node sending the transaction status of the second transaction to the third node includes:
[0056] The second node sends a fourth transaction to the third node, and the fourth transaction includes the transaction status of the second transaction.
[0057] In a possible design of the third aspect, the first node sending the transaction status of the first transaction to the third node includes:
[0058] The first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
[0059] In a possible design of the third aspect, the method further includes:
[0060] The first node calculates the first hash of the second transaction, or receives the first hash of the second transaction sent by the first client, where the first client is the initiator of the first transaction;
[0061] The third node receives the second hash of the second transaction sent by the second node;
[0062] The first node receives the second hash of the second transaction sent by the third node;
[0063] Wherein, the equality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is correct; the inequality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is incorrect.
[0064] In a possible design of the third aspect, the cross-chain transaction system further includes a fourth node. The first node and the fourth node belong to the same node cluster. After the first node modifies the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, the method further includes:
[0065] The first node broadcasts synchronization information to the fourth node, and the synchronization information is used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction.
[0066] In a fourth aspect, the present application provides a first node. The first node maintains a first blockchain, and a first transaction belongs to the first blockchain. The first transaction and a second transaction are associated cross-chain transactions. The second transaction belongs to a second blockchain, and a second node maintains the second blockchain. The first node includes:
[0067] A processing module, configured to determine that the transaction state of the first transaction is a first state, and the first state indicates that the transaction passes consensus verification;
[0068] An acquisition module, configured to acquire the transaction state of the second transaction;
[0069] The processing module is further configured to, when the transaction state of the second transaction is the first state, the first node modifies the target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node.
[0070] In a possible design of the fourth aspect, the acquisition module is specifically configured to:
[0071] Receive the transaction state of the second transaction sent by a third node, where the third node does not maintain the first blockchain and the second blockchain.
[0072] In a possible design of the fourth aspect, the first node further includes:
[0073] A sending module, configured to send the transaction state of the first transaction to the third node, where the third node does not maintain the first blockchain and the second blockchain.
[0074] In a possible design of the fourth aspect, the sending module is specifically configured to:
[0075] The first node sends a third transaction to the third node, and the third transaction includes the transaction state of the first transaction.
[0076] In a possible design of the fourth aspect, the processing module is further configured to:
[0077] Calculate the first hash of the second transaction, or the receiving module is specifically configured to receive the first hash of the second transaction sent by the first client, where the first client is the initiator of the first transaction;
[0078] The receiving module is specifically configured to receive the second hash of the second transaction sent by the third node;
[0079] Wherein, the equality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is correct; the inequality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is incorrect.
[0080] In a possible design of the fourth aspect, the processing module is further configured to:
[0081] Calculate the first hash of the first transaction, or the receiving module is specifically configured to receive the first hash of the first transaction sent by the first client;
[0082] The sending module is further configured to send the first hash of the first transaction to the third node.
[0083] In a possible design of the fourth aspect, the sending module is further configured to:
[0084] Broadcast synchronization information to the fourth node, where the synchronization information is used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, and the first node and the fourth node belong to the same node cluster.
[0085] In a fifth aspect, the present application provides a third node, where the third node includes:
[0086] A receiving module, configured to receive the transaction status of the second transaction sent by the second node, where the second node maintains a second blockchain, and the second transaction belongs to the second blockchain;
[0087] A sending module, configured to send the transaction status of the second transaction to the first node, so that the first node processes the target data based on the transaction status of the second transaction and the transaction status of the first transaction, where the target data is the data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are associated cross-chain transactions, the first transaction belongs to a first blockchain, the first node maintains the first blockchain, and the third node does not maintain the first blockchain and the second blockchain.
[0088] In a possible design of the fifth aspect, the third node further includes:
[0089] A processing module, configured to generate a first block including the transaction status of the second transaction.
[0090] In a possible design of the fifth aspect, the receiving module is further configured to:
[0091] Receive a transaction sent by at least one fifth node;
[0092] The processing module is specifically configured to:
[0093] Based on the time of the transaction sent by the at least one fifth node and the transaction status of the second transaction received, sort the transaction sent by the at least one fifth node and the transaction status of the second transaction, and generate at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
[0094] In a possible design of the fifth aspect, the sending module is specifically configured to:
[0095] Send the first block to the first node.
[0096] In a possible design of the fifth aspect, the receiving module is specifically configured to:
[0097] Receive a fourth transaction sent by the second node, where the fourth transaction includes the transaction status of the second transaction.
[0098] In a possible design of the fifth aspect, the receiving module is further configured to:
[0099] Receive the second hash of the second transaction sent by the second node;
[0100] The sending module is further configured to:
[0101] Send the second hash of the second transaction to the first node, so that the first node determines the correctness of the transaction data of the second transaction based on the second hash and the first hash of the second transaction, where the first hash of the second transaction is calculated by the first node or comes from a first client, and the first client is the initiator of the first transaction.
[0102] Sixth aspect, an embodiment of the present application provides a cross-chain transaction device, including: a memory, a transceiver, a processor, and a bus system; wherein, the memory is used to store programs and instructions; the transceiver is used to receive or send information under the control of the processor; the processor is used to execute the programs in the memory; the bus system is used to connect the memory, the transceiver, and the processor to enable communication between the memory, the transceiver, and the processor; the processor is used to call the program instructions in the memory and execute the methods described in the first aspect and the second aspect above.
[0103] Seventh aspect, an embodiment of the present application provides a computer-readable storage medium, in which instructions are stored. When it runs on a computer, it causes the computer to execute the methods described in the first aspect and the second aspect above.
[0104] The present application provides a cross-chain transaction method, which is applied to a first node. The first node maintains a first blockchain. A first transaction belongs to the first blockchain, and a second transaction belongs to a second blockchain. A second node maintains the second blockchain. The method includes: the first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes the consensus verification; the first node obtains the transaction status of the second transaction; when the transaction status of the second transaction is the first status, the first node modifies target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node. By the above method, after the first node determines that the transaction status of the first transaction is the first status, it does not directly determine whether to modify the state machine of the first node according to the first status, but receives the transaction status of the second transaction, and when the transaction status of the second transaction is the first status, modifies the state machine of the first node, so that the execution of cross-chain sub-transactions does not only depend on the consensus verification result of the first transaction, but also needs to consider the consensus verification results of other related cross-chain transactions, and there will be no situation where only part of the mutually related cross-chain transactions are successfully executed while the other part is not successfully executed, realizing the atomic execution of cross-chain transactions on multiple blockchains. BRIEF DESCRIPTION OF THE DRAWINGS
[0105] Figure 1 It is a schematic diagram of an embodiment of a cross-chain transaction method;
[0106] Figure 2 It is a schematic diagram of the architecture of a blockchain network provided by the present application;
[0107] Figure 3 It is a schematic diagram of a cross-chain transaction method provided by an embodiment of the present application;
[0108] Figure 4aSchematic diagram of an application example of a cross-chain transaction method;
[0109] Figure 4b Schematic diagram of an application example of a cross-chain transaction method;
[0110] Figure 5 Schematic diagram of the architecture of a blockchain network according to an embodiment of the present application;
[0111] Figure 6 Schematic diagram of a cross-chain transaction method provided by an embodiment of the present application;
[0112] Figure 7a Schematic diagram of the dependency relationship of a cross-chain transaction;
[0113] Figure 7b Schematic diagram of a cross-chain transaction method provided by an embodiment of the present application;
[0114] Figure 8 Schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the present application;
[0115] Figure 9 Schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the present application;
[0116] Figure 10 Schematic diagram of a structure of a cross-chain transaction device in an embodiment of the present application;
[0117] Figure 11 Schematic diagram of a server structure provided by an embodiment of the present application. Detailed implementation manners
[0118] Embodiments of the present application provide a cross-chain transaction method and device, which can enable atomic execution of cross-chain transactions on multiple blockchains.
[0119] Terms such as "first", "second", "third", "fourth", etc. (if any) in the specification, claims and drawings of the present application are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that such data may be interchanged under appropriate circumstances so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "comprising" and "having" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product or device including a series of steps or units does not necessarily limit to those steps or units clearly listed, but may include other steps or units not clearly listed or inherent to these processes, methods, products or devices.
[0120] "Blockchain" specifically refers to a P2P network system with a distributed data storage structure that is reached by each node through a consensus mechanism. The data in the blockchain is distributed in "blocks" that are connected in time. The latter block contains the data summary of the previous block, and according to the specific consensus mechanism (such as POW, POS, DPOS or PBFT, etc.), the data of all or part of the nodes are fully backed up. Blockchains can include public chains, alliance chains, private chains, etc. according to the distribution form of their network nodes. In actual applications, especially in the actual application of alliance chains, separate blockchains are usually set up for different scenarios, such as blockchains for handling house rental business scenarios, blockchains for handling music works copyright use business scenarios, etc.; and for blockchains set up in a larger application scenario, related business refinement sub-chains will also be developed for it. For example, the blockchain main chain used to handle house rental business scenarios can be linked to multiple blockchain sub-chains for multiple sub-businesses under house rental, such as blockchain sub-chains specifically used to collect house rental orders, blockchain sub-chains specifically used to collect details of houses available for rent, etc. The above sub-chains are multiple instances that follow the above blockchain main chain protocol. In order to realize a multi-blockchain network ecosystem with value interconnection and information interconnection, cross-blockchain data access or operation becomes the key to solving this problem.
[0121] Reference Figure 1 , Figure 1 Schematic diagram of an embodiment of a cross-chain transaction method, such as Figure 1 As shown in , the cross-chain transaction method includes:
[0122] 101. The first blockchain executes a first transaction and generates a block.
[0123] 102. Send the generated block to the second blockchain.
[0124] 103. The second blockchain verifies the block and determines whether the first transaction is successfully executed on the first blockchain.
[0125] 104. If the first transaction is successfully executed on the first blockchain, the second blockchain triggers the third blockchain to execute the second transaction.
[0126] 105. The third blockchain executes the second transaction.
[0127] However, if the execution of the second transaction on the third blockchain fails for some reason, the successful transaction (the first transaction) needs to be revoked. If the first transaction cannot be revoked, only part (the first transaction) of the interrelated cross-chain transactions (the first transaction and the second transaction) will be successfully executed, while the other part (the second transaction) will not be successfully executed.
[0128] It should be noted that the above-mentioned successful execution refers to updating the corresponding state machine according to the transaction data. In other words, the above-mentioned successful execution refers to updating the corresponding state database according to the transaction data.
[0129] To solve the above problems, an embodiment of the present application provides a cross-chain transaction method. After the first node determines that the transaction state of the first transaction is the first state, it does not directly determine whether to modify the state machine of the first node according to the first state. Instead, it receives the transaction state of the second transaction, and when the transaction state of the second transaction is the first state, it modifies the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also on the consensus verification results of other related cross-chain transactions. There will be no situation where only part of the mutually related cross-chain transactions are successfully executed while the other part is not, realizing the atomic execution of cross-chain transactions on multiple blockchains.
[0130] Refer to Figure 2 , Figure 2 which is a schematic diagram of the architecture of a blockchain network provided by the present application.
[0131] As Figure 1 shown, the blockchain network provided by the present application includes: Blockchain 1 network, Blockchain 2 network, Blockchain 3 network 30, the first client 130, and the second client 230.
[0132] Among them, the Blockchain 1 network includes node clusters 110 and 120. Among them, the node cluster 110 includes multiple nodes peer, and the node cluster 120 includes multiple nodes peer. These nodes peer jointly maintain Blockchain 1.
[0133] The Blockchain 2 network includes node clusters 210 and 220. Among them, the node cluster 210 includes multiple nodes peer, and the node cluster 220 includes multiple nodes peer. These nodes peer jointly maintain Blockchain 2.
[0134] The Blockchain 3 network 30 includes node clusters 310, 110, and 210. Among them, the node cluster 310 includes multiple nodes peer, the node cluster 110 includes multiple nodes peer, and the node cluster 210 includes multiple nodes peer. These nodes peer jointly maintain Blockchain 3.
[0135] Among them, the node cluster 110 can maintain both the blockchain 1 and the blockchain 3, and the node cluster 210 can maintain both the blockchain 2 and the blockchain 3. That is, the node cluster 110 can obtain the data contained in the blockchain 1 and the data contained in the blockchain 3, and the node cluster 210 can obtain the data contained in the blockchain 2 and the data contained in the blockchain 3.
[0136] Exemplarily, a user can initiate a transaction on the first client 130. The first client 130 can generate corresponding transaction information and send it to the cluster 110 through the network. The cluster 110 includes multiple first nodes. The first nodes can act as endorsing nodes, endorse the transaction information, and send an endorsement response to the first client 130 through the network.
[0137] The first client 130 can verify the endorsement response and send the transaction information and the endorsement response to the node cluster 120. Among them, the cluster 120 can be an ordering cluster, including multiple ordering nodes. The ordering nodes can perform a global sort on the received transaction data, combine a batch of sorted transaction data to generate a block, and transmit the block to the cluster 110. The first nodes can determine the validity of the transaction by verifying the block and send the validity of the transaction to the cluster 310.
[0138] Similarly, a user can initiate a transaction on the second client 230. The second client 230 can generate corresponding transaction information and send it to the cluster 210 through the network. The cluster 210 includes multiple second nodes. The second nodes can act as endorsing nodes, endorse the transaction information, and send an endorsement response to the second client 230 through the network.
[0139] The second client 230 can verify the endorsement response and send the transaction information and the endorsement response to the node cluster 220. Among them, the cluster 220 can be an ordering cluster, including multiple ordering nodes. The ordering nodes can perform a global sort on the received transaction data, combine a batch of sorted transaction data to generate a block, and transmit the block to the cluster 210. The first nodes can determine the validity of the transaction by verifying the block and send the validity of the transaction to the cluster 310.
[0140] The cluster 310 can be an ordering cluster, including multiple third nodes. The third nodes can be ordering nodes. The ordering nodes can perform a global sort on the received transaction data, combine a batch of sorted transaction data to generate a block, and transmit the block to the cluster 110 and the cluster 210.
[0141] The cluster 110 can send the transaction result to the first client 130 through the network, and the cluster 210 can send the transaction result to the second client 230 through the network.
[0142] It should be noted that the blockchain stores transaction lists in units of blocks. The blocks in the blockchain are generated in chronological order, and each block is used to record the transaction list generated within a certain period of time. All the transaction lists recorded on the blockchain are the ledger. For example, the ledger recorded on Blockchain 1 is ledger1, the ledger recorded on Blockchain 2 is ledger2, and the ledger recorded on Blockchain 3 is ledger3. In this application, without causing ambiguity, the ledger and the blockchain are equivalent concepts that can be substituted for each other.
[0143] It should be noted that the above system architecture is only a logical schematic; physically, a node in the blockchain network is on a physical machine (server), or multiple nodes in multiple blockchain networks are on the same server. A node can specifically refer to a process or a series of processes running in the server. For example, the nodes in Blockchain 1 network and the nodes in Blockchain 2 network can be two processes running on a server.
[0144] The node described in this application can refer to the server where the node is located.
[0145] It should be noted that Figure 2 The schematic diagram of the architecture of the blockchain network shown in
[0146] It should be noted that the cross-chain transaction method provided in this application can be applied to a multi-chain system composed of multiple blockchains. Among them, the multi-chain systems in the embodiments of this specification can include multiple homogeneous blockchains that follow the same blockchain basic protocol, or can also include heterogeneous blockchains that follow different blockchain basic protocols. The architectures of the above multiple blockchains are not limited to the main chain-side chain architecture, the main chain-multiple sub-chain architecture, or the parallel multi-chain architecture.
[0147] Referring to Figure 3 , Figure 3 is a schematic diagram of a cross-chain transaction method provided by an embodiment of this application. As shown in Figure 3 , the cross-chain transaction method includes:
[0148] 301. The first node determines that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification.
[0149] In the embodiments of this application, the first transaction and the second transaction are mutually related cross-chain transactions. Among them, the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain.
[0150] In the embodiments of the present application, it can be understood that the first transaction belongs to the transaction on the first blockchain, that is, the transaction operation of the first transaction can cause the change of the ledger state of the first blockchain. Similarly, it can be understood that the second transaction belongs to the transaction on the second blockchain, that is, the transaction operation of the second transaction can cause the change of the ledger state of the second blockchain.
[0151] Next, the first blockchain and the second blockchain are taken as examples of the consortium chain fabric chain for illustration.
[0152] Exemplarily, when a user initiates a cross-chain transaction on the first client, the cross-chain transaction includes two interrelated cross-chain sub-transactions (the first transaction and the second transaction). Specifically, the user can implement the transaction operation through the first client. The first client can generate the transaction data corresponding to the first transaction according to the user's transaction operation. The transaction operation can be an operation that causes the change of the ledger states of the first blockchain and the second blockchain. The transaction data can include but is not limited to user identification, transaction parameters (such as transaction amount), transaction time, etc. The first client can generate the transaction information of the first transaction based on the transaction data corresponding to the first transaction. The transaction information can include transaction identification, contract identification of the contract to be invoked by the transaction, contract method, transaction data, and client signature, etc.
[0153] It should be noted that in the embodiments of the present application, the first client can also generate the transaction data corresponding to the second transaction according to the user's transaction operation, and send the transaction data corresponding to the second transaction to the second client. The second client can generate the transaction information of the second transaction based on the transaction data corresponding to the second transaction. The transaction information can include transaction identification, contract identification of the contract to be invoked by the transaction, contract method, transaction data, and client signature, etc.
[0154] The above transaction identification can be generated by the client. The transaction identification can be used to distinguish and determine the operation performed by the transaction on the ledger. The above transaction identification can be a string composed of numbers and letters. In some application scenarios, for each transaction, a hash function can be used to process the operation performed on the ledger corresponding to the transaction, the above transaction data, etc., and the obtained hash value is used as the transaction identification of the transaction.
[0155] Specifically, the first client can use a hash function to process the operation performed on the ledger corresponding to the first transaction, the transaction data of the first transaction, etc., and use the obtained hash value as the transaction identification of the first transaction.
[0156] It should be noted that the second client can perform the same or similar actions as the first client, and the repeated parts will not be elaborated.
[0157] The above client signature may be a signature generated by the first client using its own private key. The private key of the first client may be a hash value generated using a hash algorithm, or a random number generated using a random number function, etc.
[0158] The above contract identifier refers to the identifier of the smart contract jointly observed by each node in the blockchain. The above smart contract may be an application program running on the blockchain network. In some application scenarios, the above smart contract is also called a chain code. The chain code includes a system chain code and a user chain code. The system chain code is used to implement system-level functions, including system configuration, deployment and upgrade of user chain codes, signature and verification policies for user transactions, etc. The user chain code implements the application functions of users. The chain code can be compiled into an independent application program.
[0159] In the blockchain network, the transaction data indicated by the transaction information initiated by the client needs to be verified by one or more endorsing nodes.
[0160] In the embodiments of this application, after the first client generates the transaction information of the first transaction, it may send the transaction information to the endorsing nodes in the first node cluster.
[0161] Among them, a smart contract can be pre-installed on each endorsing node. For the transaction information of the first transaction, the endorsing node can call the smart contract to verify the first transaction.
[0162] Optionally, in one embodiment, the above endorsing nodes may be preset by the first client. In some application scenarios, before the first client sends the transaction information of the first transaction to the endorsing nodes, it may call the endorsement policy in the smart contract to determine at least one endorsing node that endorses the transaction information of the first transaction from the nodes included in the first node cluster. That is to say, in these application scenarios, the above endorsing nodes can be selected by the first client from the nodes included in the first node cluster based on a preset endorsement policy.
[0163] After receiving the transaction information of the first transaction sent by the first client, the above endorsing nodes will call the relevant code in the smart contract to simulate the execution of the first transaction indicated by the transaction information. For example, the endorsing node uses the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its own corresponding ledger, and generates a transaction result including an execution return value, a read operation set, and a write operation set. The above endorsing nodes can package the above read operation set and write operation set, the endorsement result (passed or not passed), and the endorsement signature of the endorsing node to generate an endorsement response. In addition, the above endorsement response may also include the identifier of the client corresponding to the above transaction information, and the transaction identifier.
[0164] The endorsement signature of the above endorsement node can be generated by the endorsement node according to its corresponding private key. The private key of the above endorsement node can be a hash value generated by a hash algorithm or a random number generated by a random number generation function.
[0165] In the embodiment of the present application, the endorsement node can send multiple endorsement responses to the client.
[0166] The first client can receive the endorsement responses sent by each endorsement node, and then determine whether the endorsement responses meet the preset rules.
[0167] Optionally, in one embodiment, the first client can match the client identifier and transaction identifier included in the transaction information generated according to the user operation with the client identifier and transaction identifier in the endorsement response sent by the preset endorsement node received. If the match is successful, it further determines whether the endorsement response meets the preset rules.
[0168] Optionally, in one embodiment, the first client can determine whether the endorsement response includes information indicating that the endorsement result of the transaction information of the first transaction by the endorsement node is passed. If it is determined that the endorsement response includes information indicating that the endorsement result of the transaction information of the first transaction by the preset endorsement node is passed, it is determined that the endorsement response meets the preset rules; or determine whether the number of endorsement nodes corresponding to the received endorsement responses indicating that the endorsement result is passed is greater than or equal to a preset threshold. If it is determined that the number of endorsement nodes corresponding to the received endorsement responses indicating that the endorsement result is passed is greater than or equal to the preset threshold, it is determined that the endorsement response meets the preset rules; or determine whether there is an endorsement node with a weight greater than a preset weight threshold among the endorsement nodes corresponding to the received endorsement responses indicating that the endorsement result is passed; if it is determined that there is an endorsement node with a weight greater than the preset weight threshold among the endorsement nodes corresponding to the received endorsement responses indicating that the endorsement result is passed, it is determined that the endorsement response meets the preset rules.
[0169] It should be noted that the above method for determining the endorsement node and the method for the endorsement node to verify the transaction information of the first transaction are well-known technologies that have been widely studied and applied at present, and will not be elaborated here.
[0170] It should be noted that the number of endorsement nodes can be multiple, and accordingly, the number of endorsement responses can also be multiple. Each endorsement response includes the endorsement signature of one endorsement node, that is, the first client can receive multiple endorsement signatures.
[0171] In the embodiment of the present application, after the first client determines that the endorsement response meets the preset rules, it can send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster.
[0172] In the embodiment of the present application, the nodes included in the second node cluster maintain the first blockchain. The second node cluster is an orderer group, which includes multiple orderer nodes. Each orderer node can be an abstract node deployed on a server, and each orderer node can be used to provide the ordering service in blockchain technology.
[0173] The multiple orderer nodes included in the second node cluster can perform global ordering on the received transaction data, and combine a batch of ordered transaction data to generate a block structure.
[0174] In this embodiment, the above block structure may include but is not limited to the following data: the hash value obtained according to the hash algorithm corresponding to the current block number, the hash value corresponding to the previous block number, the timestamp, and multiple transaction data.
[0175] When one or more orderer nodes in the second node cluster receive N pieces of transaction information (at least including the transaction information of the first transaction and multiple endorsement signatures included in multiple endorsement responses) transmitted by the first client, at least one orderer node can generate corresponding M blocks, sort the M blocks, and transmit the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and sequentially adds the verified blocks to the corresponding blockchain.
[0176] In the embodiment of the present application, the nodes in the first node cluster can receive a third block, and the third block includes the transaction data of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that for the convenience of description, the nodes in the first node cluster are hereinafter described as first nodes.
[0177] When the first node receives a block including the transaction data of the first transaction and multiple endorsement signatures corresponding to the first transaction, it can perform consensus verification on the third block. Specifically, the first node can verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block, etc.
[0178] If the first node passes the consensus verification on the third block, it can determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification.
[0179] If the first node fails the consensus verification on the third block, it can determine that the transaction status is the third status, and the third status indicates that the transaction fails the consensus verification.
[0180] Optionally, the first node may add the third block to the first blockchain and mark the transaction status of the first transaction in the third block.
[0181] In the embodiment of the present application, after the first node determines that the transaction status of the first transaction is the first status, even if the transaction status of the second transaction is not determined, the third block is added to the corresponding blockchain, so as not to block the execution of subsequent transactions.
[0182] In the prior art, if the consensus verification of the block by the first node passes, the field related to the transaction status of the first transaction in the block is marked as valid, and the first transaction is executed. Specifically, the first node may update the status database corresponding to the first transaction (such as account balance and transaction time, etc.). At this time, if the transaction status of the subsequent second transaction is invalid, since the data related to the first transaction in the status database corresponding to the first transaction has been updated and taken effect, the first transaction has been executed, while the second transaction has not been executed.
[0183] In the embodiment of the present application, when the first node determines that the first transaction passes the consensus verification, the field related to the transaction status of the first transaction in the third block may be marked as pending, and the state machine of the first node is not modified.
[0184] It should be noted that, optionally, if the first node determines that the transaction status of the first transaction is the third status (for example: invalid), the field related to the transaction status of the first transaction in the third block may be marked as invalid.
[0185] Optionally, in one embodiment, the first node may send a third transaction to the third node in the third node cluster, and the third transaction includes the transaction status of the first transaction.
[0186] Optionally, in one embodiment, the third transaction may include transaction status indication information, and the transaction status indication information may indicate the transaction status of the first transaction. For example, the transaction status indication information may be a string. When the transaction status of the first transaction is the first status, the transaction status indication information may be pending or other strings that can indicate that the consensus verification passes. When the transaction status of the first transaction is the third status, the validity indication information may be invalid or other strings that can indicate that the consensus verification fails.
[0187] In the embodiments of the present application, the nodes included in the third node cluster maintain the third blockchain. The third node cluster is an orderer group, which includes multiple orderer nodes. Each orderer node can be an abstract node deployed on a server, and each orderer node can be used to provide an ordering service in blockchain technology.
[0188] In the embodiments of the present application, the third node cluster can also receive the transaction status of the second transaction sent by the second node, where the transaction status of the second transaction is determined by the second node and sent to the third node cluster.
[0189] In this embodiment, the multiple orderer nodes included in the third node cluster can perform global ordering on the received transactions and combine a batch of sorted transaction data to generate a block structure.
[0190] Specifically, the third node cluster can generate a first block, and the first block includes the transaction status of the first transaction and the transaction status of the second transaction.
[0191] It should be noted that the transaction status of the first transaction and the transaction status of the second transaction can be on the same block or on different blocks, which is not limited here.
[0192] 302. The first node obtains the transaction status of the second transaction.
[0193] In the embodiments of the present application, the first node can obtain the first block on the third blockchain, and the first block includes the transaction status of the second transaction.
[0194] Specifically, the transaction status of the second transaction can be the first status or the third status. Among them, the first status indicates that the transaction passes the consensus check, and the third status indicates that the transaction fails to pass the consensus check. The first node can receive the first block including the transaction status of the second transaction sent by the third node.
[0195] 303 When the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node.
[0196] In the embodiments of the present application, the first node obtains the transaction status of the second transaction, and then can determine whether the transaction status of the second transaction is the first status or the third status. When the transaction status of the second transaction is the first status, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
[0197] For example, after the first node determines that the consensus verification of the first transaction has passed, it can determine that the transaction status of the first transaction is the first status. Exemplarily, it can mark the transaction status of the first transaction as pending in the block of the first transaction. When the first node determines that the transaction status of the second transaction is also pending, it can update the block of the first transaction to mark its transaction status as valid, and modify the state machine of the first node according to the transaction data of the first transaction.
[0198] In the embodiment of the present application, the first node obtains the transaction status of the second transaction, and then can determine whether the transaction status of the second transaction is the first status or the third status. When the transaction status of the second transaction is the third status, the state machine of the first node is not modified according to the transaction data of the first transaction.
[0199] For example, after the first node determines that the consensus verification of the first transaction has passed, it can determine that the transaction status of the first transaction is the first status. Exemplarily, it can mark the transaction status of the first transaction as pending in the block of the first transaction. When the first node determines that the transaction status of the second transaction is invalid, it can update the block of the first transaction to mark its transaction status as invalid. At the same time, the state machine of the first node is not modified according to the transaction data of the first transaction.
[0200] It should be noted that in the above embodiment, only the cross-chain transaction including the first transaction and the second transaction is taken as an example for illustration. In actual applications, the cross-chain transaction may also include more than two transactions, which is not limited in the present application. The specific implementation manner can refer to the above embodiment and will not be elaborated here.
[0201] It should be noted that in an application scenario, there may be a certain dependency relationship between ordinary transactions and cross-chain transactions. Specifically, there may be a certain dependency relationship between the transaction data of ordinary transactions and cross-chain transactions. It should be pointed out that the ordinary transaction in this embodiment is a transaction that can be executed independently.
[0202] For example, there is a cross-chain transaction: cross-chain transaction A and ordinary transaction A. Cross-chain transaction A includes the first transaction and the second transaction.
[0203] The first transaction needs to update the balance of account A, and ordinary transaction A also needs to update the balance of account A. The first transaction is before the third transaction in terms of time sequence.
[0204] At this time, ordinary transaction A needs to be executed after the first transaction is completed.
[0205] Since the first transaction is a cross-chain transaction, the execution of the first transaction depends on the transaction results of the first transaction and the second transaction, and the transaction time may be very long, which may make the waiting time of the ordinary transaction A very long.
[0206] In this embodiment, if the first node needs to process a third transaction in addition to the first transaction, where the third transaction is an ordinary transaction, that is, a transaction that can be completed independently rather than a cross-chain sub-transaction, the transaction data of the third transaction includes target transaction parameters. Correspondingly, the transaction data of the first transaction also includes target transaction parameters, and the execution timing corresponding to the third transaction is after the execution timing of the first transaction. In other words, if the first node first receives the block where the first transaction is located, or if the blocks where the first transaction and the third transaction are located are the same block, on this block, the third transaction is after the first transaction.
[0207] At this time, if the first node determines the transaction status of the first transaction and then determines the transaction status of the third transaction, the waiting time of the third transaction may be very long.
[0208] In the embodiment of the present application, the first node can directly determine that the transaction status of the third transaction is the third status.
[0209] Optionally, after the first node updates the state machine of the first node according to the transaction data of the first transaction, the method further includes:
[0210] The first node broadcasts synchronization information to the fourth node. The synchronization information is used to indicate that the first node has updated the state machine of the first node. The first node and the fourth node belong to the same node cluster.
[0211] Optionally, in one embodiment, after the first node determines the transaction status of the first transaction and executes or does not execute the first transaction according to the transaction status of the first transaction (modifies the state machine of the first node according to the transaction data of the first transaction or does not modify the state machine of the first node according to the transaction data of the first transaction), the first node can send the synchronization information that the first node has completed the first transaction to the second node cluster. The second node cluster can generate a block including the synchronization information and perform sorting and block generation. Correspondingly, the nodes (fourth nodes) in the first node cluster other than the first node can receive the block including the synchronization information sent by the second node cluster. Similarly, the nodes (fourth nodes) in the first node cluster other than the first node can also send the synchronization information that the first node has completed the first transaction to the second node cluster. The second node cluster can generate a block including the synchronization information and perform sorting and block generation.
[0212] If the first node determines the transaction status of the first transaction, executes or does not execute the first transaction according to the transaction status of the first transaction, and receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has been completed on other nodes. Furthermore, it can be considered that the first transaction has no impact on the third transaction, and the third transaction can be carried out normally.
[0213] If the first node has not determined the transaction status of the first transaction but receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has been completed on other nodes. Furthermore, it can be considered that the first transaction has no impact on the third transaction, and the third transaction can be carried out normally.
[0214] If the first node determines the transaction status of the first transaction but does not receive the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed on other nodes. Furthermore, it can be considered that the first transaction may have an impact on the third transaction, and the first node can directly determine the transaction status of the third transaction as the third status.
[0215] If the first node has not determined the transaction status of the first transaction and does not receive the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed on other nodes. Furthermore, it can be considered that the first transaction may have an impact on the third transaction, and the first node can directly determine the transaction status of the third transaction as the third status.
[0216] The present application provides a cross-chain transaction method, including: the first node determines that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification; the first node obtains the transaction status of the second transaction; when the transaction status of the second transaction is the first status, the first node modifies the state machine of the first node according to the transaction data of the first transaction. By the above method, after the first node determines that the transaction status of the first transaction is the first status, it does not directly determine whether to modify the state machine of the first node according to the first status, but receives the transaction status of the second transaction, and when the transaction status of the second transaction is the first status, modifies the state machine of the first node, so that the execution of the cross-chain sub-transaction does not only depend on the consensus verification result of the first transaction, but also needs to consider the consensus verification results of other related cross-chain transactions, and there will be no situation where only part of the mutually related cross-chain transactions are successfully executed while the other part is not, realizing the atomic execution of cross-chain transactions on multiple blockchains.
[0217] Referring to Figure 4a , Figure 4a is a schematic diagram of an application example of a cross-chain transaction method. Specifically, the cross-chain transaction method includes:
[0218] 4011. The first node determines that the transaction status of the first transaction is the first status;
[0219] 4012. The second node determines that the transaction status of the second transaction is the first status;
[0220] 4021. The first node sends the transaction status of the second transaction;
[0221] 4021. The second node sends the transaction status of the second transaction;
[0222] 4031. The third node generates a block including the transaction status of the first transaction;
[0223] 4032. The third node generates a block including the transaction status of the second transaction;
[0224] 4041. The third node sends the transaction status of the second transaction;
[0225] 4042. The third node sends the transaction status of the first transaction;
[0226] 4051. When the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction;
[0227] 4052. When the transaction status of the first transaction is the first status, the second node modifies the target data according to the transaction data of the first transaction.
[0228] For the specific descriptions of steps 4011 to 4052, reference may be made to the above embodiments, which will not be elaborated here.
[0229] More specifically, referring to Figure 4b , Figure 4b is a schematic diagram of an application example of a cross-chain transaction method. Specifically, the cross-chain transaction method includes:
[0230] 501. The first client receives the transaction operation of the user.
[0231] In the embodiments of the present application, the transaction operation may be an operation that causes the ledger status of the first blockchain and the second blockchain to change.
[0232] 502. The first client generates transaction data.
[0233] In the embodiments of the present application, the first client may generate the transaction data corresponding to the first transaction according to the transaction operation of the user. Among them, the transaction data may include, but is not limited to, user identification, transaction parameters (such as transaction amount), transaction time, etc.
[0234] 503. The first client sends the transaction data to the second client.
[0235] In the embodiment of the present application, the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send the transaction data corresponding to the second transaction to the second client.
[0236] 5041. The first client generates transaction information.
[0237] In the embodiment of the present application, the first client may generate transaction information of the first transaction based on the transaction data corresponding to the first transaction. The transaction information may include a transaction identifier, a contract identifier of the contract to be invoked by the transaction, a contract method, transaction data, and a client signature, etc.
[0238] 5042. The second client generates transaction information.
[0239] In the embodiment of the present application, the second client may generate transaction information of the second transaction based on the transaction data corresponding to the second transaction. The transaction information may include a transaction identifier, a contract identifier of the contract to be invoked by the transaction, a contract method, transaction data, and a client signature, etc.
[0240] 5051. The first client sends a transaction request to the first endorsing node.
[0241] In the embodiment of the present application, the first endorsing node may be a part or all of the nodes in the first node cluster. After generating the transaction information of the first transaction, the first client may send the transaction information to the endorsing nodes in the first node cluster. Among them, a smart contract may be pre-installed on each endorsing node. For the transaction information of the first transaction, the endorsing node may call the smart contract to verify the first transaction.
[0242] 5052. The second client sends a transaction request to the second endorsing node.
[0243] In the embodiment of the present application, the second endorsing node may be a part or all of the nodes in the second node cluster. After generating the transaction information of the second transaction, the second client may send the transaction information to the endorsing nodes in the second node cluster. Among them, a smart contract may be pre-installed on each endorsing node. For the transaction information of the second transaction, the endorsing node may call the smart contract to verify the second transaction.
[0244] 5061. The first endorsing node conducts endorsement.
[0245] In the embodiment of the present application, after the first endorsing node receives the transaction information of the first transaction sent by the first client, it will call the relevant code in the smart contract to simulate the execution of the first transaction indicated by the transaction information. For example, the first endorsing node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates a transaction result including an execution return value, a read operation set, and a write operation set. The first endorsing node can package the above read operation set and write operation set, the endorsement result (passed or not passed), and the endorsement signature of the endorsing node, so as to generate an endorsement response.
[0246] 5062. The second endorsing node conducts endorsement.
[0247] In the embodiment of the present application, after the second endorsing node receives the transaction information of the second transaction sent by the second client, it will call the relevant code in the smart contract to simulate the execution of the second transaction indicated by the transaction information. For example, the endorsing node takes the transaction data in the transaction information of the second transaction as input, simulates the execution of the second transaction on its corresponding ledger, and generates a transaction result including an execution return value, a read operation set, and a write operation set. The second endorsing node can package the above read operation set and write operation set, the endorsement result (passed or not passed), and the endorsement signature of the endorsing node, so as to generate an endorsement response.
[0248] 5071. The first endorsing node sends an endorsement response to the first client.
[0249] 5072. The second endorsing node sends an endorsement response to the first client.
[0250] 5081. The first client passes the verification.
[0251] In the embodiment of the present application, the first client can receive the endorsement response sent by the first endorsing node, and then determine whether the endorsement response conforms to the preset rules.
[0252] 5082. The second client passes the verification.
[0253] In the embodiment of the present application, the second client can receive the endorsement response sent by the second endorsing node, and then determine whether the endorsement response conforms to the preset rules.
[0254] 5091. The first client sends the transaction information and signature to the first ordering node.
[0255] In the embodiment of the present application, if the first client determines that the endorsement response sent by the first endorsing node conforms to the preset rules, it can send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the first ordering node.
[0256] 5092. The second client sends the transaction information and the signature to the second ordering node.
[0257] In the embodiment of the present application, if the second client determines that the endorsement response sent by the second endorsing node conforms to the preset rules, it may send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second ordering node.
[0258] 5101. The first ordering node generates a block.
[0259] 5102. The second ordering node generates a block.
[0260] 5111. The first ordering node sends the block to the first node.
[0261] In the embodiment of the present application, when the first ordering node receives N pieces of transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, the first ordering node may generate corresponding M blocks, sort the M blocks, and transmit the M blocks to the first node.
[0262] 5112. The second ordering node sends the block to the second node.
[0263] In the embodiment of the present application, when the second ordering node receives N pieces of transaction information (including at least the transaction information of the second transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the second client, the second ordering node may generate corresponding M blocks, sort the M blocks, and transmit the M blocks to the second node.
[0264] 5121. The first node verifies the block and determines the transaction status of the first transaction.
[0265] In the embodiment of the present application, when the first node receives a block including the transaction information of the first transaction and the multiple endorsement signatures corresponding to the first transaction, it may verify the block. Specifically, the first node may verify the multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multiversion concurrency control (mvcc) verification on the block, etc.
[0266] 5122. The second node verifies the block and determines the transaction status of the second transaction.
[0267] In the embodiments of the present application, when the second node receives a block including the transaction information of the second transaction and multiple endorsement signatures corresponding to the second transaction, it can verify the block. Specifically, the second node can verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multiversion concurrency control (MVCC) verification on the block, etc.
[0268] 5131. The first node sends the transaction status of the first transaction to the third node.
[0269] 5132. The second node sends the transaction status of the second transaction to the third node.
[0270] 514. The third node generates a block and sorts it.
[0271] 5151. The third node sends the block to the first node.
[0272] 5152. The third node sends the block to the second node.
[0273] In the embodiments of the present application, when the first sorting node receives N pieces of transaction information transmitted by the first client (including at least the transaction information of the first transaction and multiple endorsement signatures included in the endorsement responses of multiple first transactions, as well as the transaction information of the second transaction and multiple endorsement signatures included in the endorsement responses of multiple second transactions), the third node cluster can generate corresponding M blocks, sort the M blocks, and transmit the M blocks to the first node and the second node.
[0274] 5161. The first node determines the transaction status of the first transaction based on the transaction status of the first transaction and the transaction status of the second transaction.
[0275] 5162. The second node determines the transaction status of the second transaction based on the transaction status of the first transaction and the transaction status of the second transaction.
[0276] 5171. The first node determines whether to execute or not execute the first transaction based on the transaction status of the first transaction.
[0277] 5172. The second node determines whether to execute or not execute the second transaction based on the transaction status of the second transaction.
[0278] 5181. The first node sends the execution result to the first client.
[0279] 5182. The second node sends the execution result to the second client.
[0280] Regarding how the first node determines whether to execute or not execute the first transaction based on the transaction status of the first transaction, and how the second node determines whether to execute or not execute the first transaction based on the transaction status of the second transaction, reference may be made to the description of the above embodiments, which will not be elaborated here.
[0281] It should be noted that the above description is based on the example of the first blockchain and the second blockchain being the consortium chain fabric chain. When the first blockchain and the second blockchain are heterogeneous blockchains following different blockchain basic protocols, for example, the first blockchain can be the Ethereum chain. In this case, after the first node determines that the transaction status of the first transaction is the first state, it can deploy the first transaction on the Ethereum chain and lock the first transaction. After receiving the transaction status of the second transaction sent by the third node cluster, when the transaction status of the second transaction is the first state, it determines that the transaction status of the first transaction is the second state, and when the first transaction is in the second state, it executes the first transaction.
[0282] It should be noted that the first node in this application may not belong to the Ethereum chain, but is a node of a newly added distributed node cluster.
[0283] In the embodiment of this application, if the transaction status of the first transaction is the third state, the first transaction is not executed. Specifically, the first node can instruct the Ethereum chain to roll back the first transaction, that is, instruct the Ethereum chain not to execute the first transaction.
[0284] In the embodiment of this application, if the transaction status of the first transaction is the second state, the first transaction is executed. Specifically, the first node can instruct the Ethereum chain to unlock the first transaction, that is, instruct the Ethereum chain to execute the first transaction.
[0285] It should be noted that if the first blockchain is the fabric chain and the second blockchain is the Ethereum chain, the first blockchain executes the execution steps regarding the fabric chain in the above embodiments, and the second blockchain executes the execution steps regarding the Ethereum chain in the above embodiments.
[0286] Refer to Figure 5 , Figure 5 is a schematic diagram of the architecture of a blockchain network according to an embodiment of this application. As Figure 5 shown in, the blockchain network includes: the blockchain 4 network 40, the blockchain 2 network, the blockchain 3 network 30, the first client 130, the second client 230, and the node cluster 510, where the blockchain corresponding to the blockchain 4 network 40 is the Ethereum chain.
[0288] In the embodiment of this application, for the specific description of the blockchain 2 network and the second client 230, reference may be made to Figure 2The description of the corresponding embodiments will not be repeated here.
[0289] In the embodiments of the present application, the blockchain 4 network 40 includes a node cluster 410. The node cluster 410 includes multiple nodes peer, and these nodes peer jointly maintain the Ethereum chain.
[0290] The node cluster 510 includes multiple nodes peer, and Figure 1 Different from the architecture diagram, the blockchain 3 network 30 does not include the node cluster 110. At this time, the node cluster 510 can complete the functions of the node cluster 110, that is, the node cluster 510 can provide the functions of the node cluster 110 as an adapter.
[0291] Exemplarily, a user can initiate a transaction on the first client 130. The first client 130 can generate corresponding transaction information and send it to the cluster 510 through the network. The cluster 510 includes multiple first nodes. After the first node determines that the transaction status of the transaction is the first status, the first node can deploy the transaction on the node cluster 410. Correspondingly, the node cluster 410 can lock the transaction. The first node can also send the transaction status of the first transaction to the cluster 310.
[0292] Similarly, the second node can send the transaction status of the second transaction to the cluster 310.
[0293] The cluster 310 can be an ordering cluster, including multiple third nodes. The third nodes can be ordering nodes. The ordering nodes can perform global sorting on the received transaction data, combine a batch of sorted transaction data to generate a block, and transmit the block to the cluster 510 and the cluster 210.
[0294] The cluster 510 can determine the transaction status of the transaction according to the received block. When the transaction status is the second status, it can instruct the node cluster 410 to execute the transaction. When the transaction status is the third status, it can instruct the node cluster 410 to execute a transaction rollback, that is, not to execute the transaction.
[0295] In some scenarios, cross-chain transactions include multiple associated cross-chain sub-transactions, such as the first transaction and the second transaction. If the first transaction is that user A transfers 10 units of currency to user B, at this time, the first transaction is a reduction of 10 units of currency in the balance of user A's account on the first blockchain, and the second transaction is an increase of 10 units of currency in the balance of user B's account on the second blockchain.
[0296] However, since the client may be untrusted and there is a certain risk of fraud, the transactions initiated by the first client and the second client may not be real. For example, the transaction initiated by the first client is to subtract 10 units of currency from the balance of account A on the first blockchain, while the second transaction is to add 20 units of currency to the balance of account B on the second blockchain. This will disrupt the existing data logical relationship and is unacceptable.
[0297] To solve the above technical problems, the present application provides a cross-chain transaction method.
[0298] Refer to Figure 6 , Figure 6 which is a schematic diagram of a cross-chain transaction method provided by an embodiment of the present application. As shown in Figure 6 , the cross-chain transaction method includes:
[0299] 601. The first node calculates the first hash of the second transaction or receives the first hash of the second transaction sent by the first client, where the first client is the initiator of the first transaction.
[0300] In an embodiment of the present application, the first transaction and the second transaction are cross-chain transactions that are related to each other. Among them, the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain.
[0301] Exemplarily, when a user initiates a cross-chain transaction on the first client, the cross-chain transaction includes two related cross-chain sub-transactions (the first transaction and the second transaction). Specifically, the user can perform transaction operations through the first client. The first client can generate transaction data corresponding to the first transaction according to the user's transaction operations. The transaction operations can be operations that cause changes in the ledger states of the first blockchain and the second blockchain. The transaction data may include, but is not limited to, user identification, transaction parameters (such as transaction amount), transaction time, etc. The first client can generate transaction information corresponding to the first transaction based on the transaction data corresponding to the first transaction, and the transaction information may include the first hash hash(tx1) of the first transaction.
[0302] Among them, the transaction identifier can be used to distinguish and determine the operations performed by the transaction on the ledger. The first hash hash(tx1) of the above first transaction can be a string composed of numbers and letters. In some application scenarios, for each transaction, a hash function can be used to process the operations performed on the ledger corresponding to the transaction, the above transaction data, etc., and the obtained hash value can be used as the transaction identifier of the transaction.
[0303] It should be noted that in the embodiments of the present application, the first client can also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send the transaction data corresponding to the second transaction to the second client. The second client can generate transaction information of the second transaction based on the transaction data corresponding to the second transaction. The transaction information can include the second hash hash(tx2) of the second transaction. Since the transaction identifier can distinguish and determine the operations performed on the ledger by the transaction, the second hash hash(tx2) of the second transaction generated by the second client can uniquely represent the content executed by the second transaction.
[0304] In the embodiments of the present application, in addition to generating the first hash hash(tx1) of the first transaction, the first client also generates the first hash exp_hash(tx2) of the second transaction.
[0305] Optionally, in one embodiment, the first client can obtain the first hash exp_hash(tx2) of the second transaction that the second client "should" generate by calling the helper chain code.
[0306] Specifically, after the first client generates the transaction data corresponding to the second transaction according to the user's transaction operation, it can use the transaction data as input and generate the first hash exp_hash(tx2) of the second transaction by calling the helper chain code. The first hash exp_hash(tx2) of the second transaction can represent the transaction identifier uniquely corresponding to the second transaction that the second client should execute.
[0307] Optionally, in one embodiment, the first client can obtain the first hash exp_hash(tx2) of the second transaction not by querying the helper chain code, but by communicating with the second client to obtain the chain code and parameters that the second client should execute, and calculating the first hash exp_hash(tx2) of the second transaction.
[0308] In the embodiments of the present application, after the first client generates the transaction information of the first transaction, it can send the transaction information to the endorsing nodes in the first node cluster. The transaction information of the first transaction includes the first hash exp_hash(tx2) and the first hash hash(tx1) of the first transaction.
[0309] After receiving the transaction information of the first transaction sent by the first client, the above endorsement node will call the relevant code in the smart contract to simulate the execution of the first transaction indicated by the transaction information. For example, the endorsement node uses the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates a transaction result including an execution return value, a read operation set, and a write operation set. The above endorsement node can package the above read operation set, write operation set, endorsement result (passed or not passed), and the endorsement signature of the endorsement node to generate an endorsement response. In addition, the above endorsement response may further include the identifier of the client corresponding to the above transaction information, as well as the first hash exp_hash(tx2) and the first hash hash(tx1) of the first transaction.
[0310] In the embodiments of this application, the endorsement node can send multiple endorsement responses to the client.
[0311] The first client can receive the endorsement responses sent by each endorsement node, and then determine whether the endorsement responses meet the preset rules.
[0312] In the embodiments of this application, after the first client determines that the endorsement response meets the preset rules, it can send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster, where the transaction information of the first transaction includes the first hash exp_hash(tx2) and the first hash hash(tx1) of the first transaction.
[0313] In the embodiments of this application, the nodes included in the second node cluster maintain the first blockchain. The second node cluster is an ordering cluster (orderer group), which includes multiple ordering nodes. Each ordering node can be an abstract node deployed on a server, and each ordering node can be used to provide an ordering service in blockchain technology.
[0314] The multiple ordering nodes included in the second node cluster can perform a global sort on the received transaction data, and combine a batch of sorted transaction data to generate a block structure.
[0315] When one or more ordering nodes in the second node cluster receive N transaction information (at least including the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, at least one ordering node can generate corresponding M blocks, sort the M blocks, and transmit the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and sequentially adds the verified blocks to the corresponding blockchain.
[0316] In the embodiments of the present application, a node in the first node cluster may receive a block, which includes the transaction information of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that, for convenience of description, the nodes in the first node cluster are hereinafter described as first nodes.
[0317] When the first node receives a block including the transaction information of the first transaction and multiple endorsement signatures corresponding to the first transaction, it can verify the block. Regarding how the first node verifies the block, reference may be made to the above embodiments and will not be elaborated here.
[0318] The first node may send a sixth transaction to the third node, and the sixth transaction includes the first hash hash(tx1) of the first transaction. Optionally, the fourth transaction includes the first hash exp_hash(tx2) of the second transaction.
[0319] In the embodiments of the present application, the nodes included in the third node cluster maintain a third blockchain. The third node cluster is an ordering cluster (orderer group), which includes multiple ordering nodes. Each ordering node can be an abstract node deployed on a server, and each ordering node can be used to provide an ordering service in blockchain technology.
[0320] In the embodiments of the present application, the third node cluster may also receive the second hash hash(tx2) of the second transaction and the second hash exp_hash(tx1) of the first transaction sent by the second node. Specifically, the third node cluster may also receive a fifth transaction sent by the second node, and the fifth transaction may include the second hash hash(tx2) of the second transaction and the second hash exp_hash(tx1) of the first transaction.
[0321] In the embodiments of the present application, multiple ordering nodes included in the third node cluster may perform global sorting on the received transactions and combine a batch of sorted transaction data to generate a block structure.
[0322] Specifically, the third node cluster may generate a fourth block, and the fourth block includes the second hash hash(tx2) of the second transaction and the second hash exp_hash(tx1) of the first transaction. The fourth block may also include the first hash exp_hash(tx2) of the second transaction and the first hash hash(tx1) of the first transaction.
[0323] It should be noted that the second hash hash(tx2) of the second transaction, the second hash exp_hash(tx1) of the first transaction, the first hash exp_hash(tx2) of the second transaction, and the first hash hash(tx1) of the first transaction may be in the same block or in different blocks, which is not limited here.
[0324] 602. The first node receives the second hash of the second transaction sent by the third node. If the first hash of the second transaction is equal to the second hash of the second transaction, it indicates that the transaction data of the second transaction is correct; if the first hash of the second transaction is not equal to the second hash of the second transaction, it indicates that the transaction data of the second transaction is incorrect.
[0325] In an embodiment of the present application, the first node may obtain the fourth block on the third blockchain. The fourth block may include the second hash hash(tx2) of the second transaction. The second hash hash(tx2) of the second transaction is the transaction identifier corresponding to the actual execution of the second transaction, and it can uniquely indicate the transaction data of the second transaction in specific execution.
[0326] Optionally, the fourth block may further include the second hash exp_hash(tx1) of the first transaction.
[0327] Similarly, the second node may receive the fifth block sent by the third node cluster. The fifth block may include the first hash hash(tx1) of the first transaction. The first hash hash(tx1) of the first transaction is the transaction identifier corresponding to the actual execution of the first transaction, and it can uniquely indicate the transaction data of the first transaction in specific execution.
[0328] Optionally, the fifth block may further include the first hash exp_hash(tx2) of the second transaction.
[0329] In one embodiment, if the fourth block and the fifth block generated by the third node cluster are the same block, the first node may receive the block sent by the third node cluster. The block includes the second hash hash(tx2) of the second transaction, the second hash exp_hash(tx1) of the first transaction, the first hash hash(tx1) of the first transaction, and the first hash exp_hash(tx2) of the second transaction.
[0330] In an embodiment of the present application, the first node may determine whether the second transaction is executed according to the correct transaction data by determining whether the second hash hash(tx2) of the second transaction is equal to the first hash exp_hash(tx2) of the second transaction.
[0331] Specifically, since the first hash exp_hash(tx2) of the second transaction is generated by the first client based on the transaction data of the second transaction, it can represent the transaction data that the first client believes the second transaction should execute. And the second hash hash(tx2) of the second transaction represents the transaction data actually executed by the second transaction.
[0332] Therefore, by determining whether the second hash hash(tx2) of the second transaction is equal to the first hash exp_hash(tx2) of the second transaction, it can be determined whether the second transaction is executed according to the correct transaction data.
[0333] Similarly, the second node can determine whether the first transaction is executed according to the correct transaction data by determining whether the first hash hash(tx1) of the first transaction is equal to the second hash exp_hash(tx1) of the first transaction.
[0334] Specifically, since the second hash exp_hash(tx1) of the first transaction is generated by the second client based on the transaction data of the first transaction, it can represent the transaction data that the second client believes the first transaction should execute. And the first hash hash(tx1) of the first transaction represents the transaction data actually executed by the first transaction.
[0335] Therefore, by determining whether the first hash hash(tx1) of the first transaction is equal to the second hash exp_hash(tx1) of the first transaction, it can be determined whether the first transaction is executed according to the correct transaction data.
[0336] Optionally, if the first block includes the second hash exp_hash(tx1) of the first transaction, the first node can obtain the judgment result of the second node by determining whether the first hash hash(tx1) of the first transaction is equal to the second hash exp_hash(tx1) of the first transaction.
[0337] If the second block includes the first hash exp_hash(tx2) of the second transaction, the second node can obtain the judgment result of the first node by determining whether the second hash hash(tx2) of the second transaction is equal to the first hash exp_hash(tx2) of the second transaction.
[0338] In the embodiment of the present application, if the first node determines that the second hash hash(tx2) of the second transaction is equal to the first hash exp_hash(tx2) of the second transaction, the first node can determine that the second transaction is executed according to the correct transaction data.
[0339] In the embodiment of the present application, if the second node determines that the first hash hash(tx1) of the first transaction is equal to the second hash exp_hash(tx1) of the first transaction, the second node can determine that the first transaction is executed according to the correct transaction data.
[0340] In the embodiment of the present application, if the first node determines that the first transaction is executed according to the correct transaction data and the second transaction is executed according to the correct transaction data, the first transaction can be executed.
[0341] In the embodiment of the present application, if the first node determines that the first transaction is not executed according to the correct transaction data and the second transaction is executed according to the correct transaction data, the first transaction is not executed.
[0342] In the embodiment of the present application, if the first node determines that the first transaction is executed according to the correct transaction data and the second transaction is not executed according to the correct transaction data, the first transaction is not executed.
[0343] In the embodiment of the present application, if the second node determines that the first transaction is executed according to the correct transaction data and the second transaction is executed according to the correct transaction data, the second transaction may be executed.
[0344] In the embodiment of the present application, if the second node determines that the first transaction is not executed according to the correct transaction data and the second transaction is executed according to the correct transaction data, the second transaction is not executed.
[0345] In the embodiment of the present application, if the second node determines that the first transaction is executed according to the correct transaction data and the second transaction is not executed according to the correct transaction data, the second transaction is not executed.
[0346] Exemplarily, if the first transaction is that user A transfers 10 units of currency to user B, at this time, the first transaction is to subtract 10 units of currency from the balance of account A on the first blockchain, and the second transaction is to add 10 units of currency to the balance of account B on the second blockchain.
[0347] At this time, the first client generates the first hash hash(tx1) of the first transaction based on the transaction data of the first transaction (including subtracting 10 units of currency from the balance of account A on the first blockchain), and generates the first hash exp_hash(tx2) of the second transaction based on the transaction data of the second transaction (including adding 10 units of currency to the balance of account B on the second blockchain).
[0348] Similarly, the second client generates the second hash exp_hash(tx1) of the first transaction based on the transaction data of the first transaction (including subtracting 10 units of currency from the balance of account A on the first blockchain), and generates the second hash hash(tx2) of the second transaction based on the transaction data of the second transaction (including adding 20 units of currency to the balance of account B on the second blockchain), that is, the second client wants to add more currency to account B.
[0349] After that, since the first node will receive the second hash hash(tx2) of the second transaction sent by the third node, and since the second hash hash(tx2) is different from the first hash exp_hash(tx2) of the second transaction, the first node will determine that the transaction data executed by the second transaction is incorrect, that is, the second client is deceptive, and then the first transaction will not be executed.
[0350] It should be noted that Figure 6 The corresponding embodiments can be carried out Figure 3 simultaneously with the corresponding embodiments, which is not limited here.
[0351] The embodiment of the present application provides a cross-chain transaction method, including: the first node obtains the first hash of the second transaction; the first node obtains the fourth block on the third blockchain, and the fourth block includes the second hash of the second transaction; the first node determines whether the first hash of the second transaction is equal to the second hash of the second transaction according to the fourth block. In the embodiment of the present application, the first node can determine whether the second transaction is executed according to the correct transaction data by judging whether the second hash of the second transaction is equal to the first hash of the second transaction, and when the second transaction is not executed according to the correct transaction data, the first transaction is not executed.
[0352] When there are multiple cross-chain transactions in the blockchain network, there may be certain dependencies among the cross-chain transactions. Specifically, there are certain dependencies among the transaction data of the cross-chain transactions. For example, there are two cross-chain transactions: cross-chain transaction A and cross-chain transaction B. Cross-chain transaction A includes the first transaction and the second transaction, and cross-chain transaction B includes the third transaction and the fourth transaction. The first transaction and the third transaction are transactions on the first blockchain, and the second transaction and the fourth transaction are transactions on the second blockchain.
[0353] The first transaction needs to update the balance of account A, and the third transaction also needs to update the balance of account A. The first transaction is before the third transaction in terms of time sequence.
[0354] The second transaction needs to update the balance of account B, and the fourth transaction also needs to update the balance of account B. The second transaction is after the fourth transaction in terms of time sequence.
[0355] At this time, the third transaction needs to be executed after the first transaction is completed.
[0356] The first transaction and the second transaction belong to the same cross-chain transaction, so the execution of the first transaction depends on the execution result of the second transaction.
[0357] The second transaction needs to be executed after the fourth transaction is completed.
[0358] If the fourth transaction and the third transaction belong to the same cross-chain transaction, the execution completion of the fourth transaction depends on the execution result of the third transaction.
[0359] That is, a deadlock is formed, and neither of the two cross-chain transactions can be completed, resulting in the blocking of transaction execution and the system being unable to provide services.
[0360] Refer to Figure 7a , Figure 7a which is a schematic diagram of the dependency relationship of a cross-chain transaction. As shown in Figure 7a , the first transaction A1 and the second transaction B1 belong to the same cross-chain transaction, the third transaction A2 and the fourth transaction B2 belong to the same cross-chain transaction, the first transaction A1 and the third transaction A2 have a timing dependency relationship, that is, the third transaction A2 can be executed only after the first transaction A1 is executed, and the fourth transaction B2 and the second transaction B1 have a timing dependency relationship, that is, the second transaction B1 can be executed only after the fourth transaction B2 is executed.
[0361] At this time, there is a problem of transaction deadlock among the first transaction A1, the second transaction B1, the third transaction A2, and the fourth transaction B2.
[0362] To solve the above problems, refer to Figure 7b , Figure 7b which is a schematic diagram of an embodiment of a cross-chain transaction method provided by an embodiment of the present application. Specifically, the cross-chain transaction method provided in this embodiment includes:
[0363] 701. The first node receives the transaction data of the first transaction, and the transaction data of the first transaction includes target transaction parameters.
[0364] 702. The first node receives the transaction data of the second transaction.
[0365] 703. If the transaction data of the second transaction includes the target transaction parameters, determine that the transaction status of the second transaction is invalid.
[0366] Optionally, in the embodiment of the present application, the first transaction and the third transaction are mutually related cross-chain transactions, the second transaction and the fourth transaction are mutually related cross-chain transactions, the first transaction and the second transaction are transactions on the first blockchain, and the third transaction and the fourth transaction are transactions on the second blockchain.
[0367] For example, the first transaction is to subtract 5 units of currency from the balance of account A, the second transaction is to subtract 10 units of currency from the balance of account A, the third transaction is to add 5 units of currency to the balance of account B, and the fourth transaction is to add 10 units of currency to the balance of account B.
[0368] At this time, if the transaction data of the first transaction includes the target transaction parameter "A account" and the transaction data of the second transaction includes the target transaction parameter "A account", then the first node can directly determine that the transaction status of the second transaction is invalid and does not execute the second transaction, that is, does not update the status database corresponding to the second transaction.
[0369] In the embodiments of the present application, if it is determined that there is a cross-chain transaction that may cause a transaction deadlock, then the transaction status of one of the transactions is determined to be invalid, thereby solving the transaction execution block caused by the transaction deadlock.
[0370] The following describes in detail the first node corresponding to an embodiment in the present application. Please refer to Figure 8 , Figure 8 which is a schematic diagram of the embodiment of the first node in the embodiments of the present application. The first node 800 in the embodiments of the present application includes:
[0371] A processing module 801, configured to determine that the transaction status of the first transaction is a first status, where the first status indicates that the transaction passes the consensus verification;
[0372] An acquisition module 802, configured to acquire the transaction status of the second transaction;
[0373] The processing module 801 is further configured to, when the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction, where the target data is the data related to the first transaction in the state machine of the first node.
[0374] In the embodiments of the present application, the processing module 801 determines that the transaction status of the first transaction is a first status, where the first status indicates that the transaction passes the consensus verification; the acquisition module 802 acquires the transaction status of the second transaction; when the transaction status of the second transaction is the first status, the processing module 801 modifies the target data according to the transaction data of the first transaction, where the target data is the data related to the first transaction in the state machine of the first node. In the above manner, after the first node determines that the transaction status of the first transaction is the first status, it does not directly determine whether to modify the state machine of the first node according to the first status, but receives the transaction status of the second transaction, and when the transaction status of the second transaction is the first status, modifies the state machine of the first node, so that the execution of the cross-chain sub-transaction does not only depend on the consensus verification result of the first transaction, but also needs to consider the consensus verification results of other related cross-chain transactions, and there will be no situation where only part of the mutually related cross-chain transactions are successfully executed while the other part is not successfully executed, realizing the atomic execution of cross-chain transactions on multiple blockchains.
[0375] Optionally, the obtaining module 802 is specifically configured to: receive the transaction status of the second transaction sent by a third node that does not maintain the first blockchain and the second blockchain.
[0376] Optionally, the first node further includes:
[0377] A sending module 803, configured to send the transaction status of the first transaction to a third node that does not maintain the first blockchain and the second blockchain.
[0378] Optionally, the sending module 803 is specifically configured to:
[0379] The first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
[0380] Next, a first node corresponding to an embodiment in the present application will be described in detail. Please refer to Figure 8 , Figure 8 which is a schematic diagram of an embodiment of the first node in the embodiment of the present application. The first node 800 in the embodiment of the present application includes:
[0381] The processing module 801 is configured to:
[0382] Calculate the first hash of the second transaction, or the receiving module is specifically configured to receive the first hash of the second transaction sent by a first client, where the first client is the initiator of the first transaction;
[0383] The receiving module 804 is configured to receive the second hash of the second transaction sent by the third node;
[0384] Wherein, if the first hash of the second transaction is equal to the second hash of the second transaction, it indicates that the transaction data of the second transaction is correct; if the first hash of the second transaction is not equal to the second hash of the second transaction, it indicates that the transaction data of the second transaction is incorrect.
[0385] Optionally, the processing module 801 is further configured to:
[0386] Calculate the first hash of the first transaction, or the receiving module is specifically configured to receive the first hash of the first transaction sent by the first client;
[0387] The sending module 803 is further configured to send the first hash of the first transaction to the third node.
[0388] Optionally, the sending module 803 is further configured to:
[0389] Broadcast synchronization information to a fourth node, where the synchronization information is used to indicate that the first node has modified target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, and the first node and the fourth node belong to the same node cluster.
[0390] The following will describe in detail the cross-chain transaction device corresponding to an embodiment in the present application. Please refer to Figure 9 , Figure 9 This is a schematic diagram of an embodiment of the third node in the embodiment of the present application. The third node 900 in the embodiment of the present application includes:
[0391] An acquisition module 901, configured to receive the transaction status of a second transaction sent by a second node, where the second node maintains a second blockchain, and the second transaction belongs to the second blockchain;
[0392] A sending module 903, configured to send the transaction status of the second transaction to the first node, so that the first node processes target data based on the transaction status of the second transaction and the transaction status of the first transaction, where the target data is data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are associated cross-chain transactions, the first transaction belongs to a first blockchain, the first node maintains the first blockchain, and the third node does not maintain the first blockchain and the second blockchain.
[0393] Optionally, the third node further includes:
[0394] A processing module 902, configured to generate a first block including the transaction status of the second transaction.
[0395] Optionally, the receiving module is further configured to:
[0396] Receive transactions sent by at least one fifth node;
[0397] The processing module is specifically configured to:
[0398] Sort the transactions sent by the at least one fifth node and the transaction status of the second transaction based on the time when the transactions sent by the at least one fifth node and the transaction status of the second transaction are received, and generate at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
[0399] Optionally, the sending module 903 is specifically configured to:
[0400] Send the first block to the first node.
[0401] Optionally, the receiving module is specifically configured to:
[0402] Receive a fourth transaction sent by the second node, where the fourth transaction includes the transaction status of the second transaction.
[0403] Optionally, the receiving module is further configured to:
[0404] Receive a second hash of the second transaction sent by the second node;
[0405] The sending module is further configured to:
[0406] Send the second hash of the second transaction to the first node, so that the first node determines the correctness of the transaction data of the second transaction based on the second hash and the first hash of the second transaction, where the first hash of the second transaction is calculated by the first node or comes from a first client, and the first client is the initiator of the first transaction.
[0407] An embodiment of the present application further provides a cross-chain transaction device, as Figure 10 shown Figure 10 is a schematic structural diagram of the cross-chain transaction device in the embodiment of the present application. For the convenience of description, only the parts related to the embodiment of the present application are shown. For the specific technical details not disclosed, please refer to the method part of the embodiment of the present application. This cross-chain transaction device runs on a terminal, and the terminal can be any terminal device including a mobile phone, a tablet computer, a personal digital assistant (PDA), a point of sales (POS), an in-vehicle computer, etc. Taking the terminal as a mobile phone as an example:
[0408] The mobile phone includes components such as a radio frequency (RF) circuit 1110, a memory 1120, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a wireless fidelity (WiFi) module 1170, a processor 1180, and a power supply 1190. Those skilled in the art can understand that Figure 10 the structure of the mobile phone shown in
[0409] The RF circuit 1110 can be used for receiving and transmitting information or signals during a call. Specifically, after receiving the downlink information from the base station, it is sent to the processor 1180 for processing. Additionally, the data designed for uplink is sent to the base station. Generally, the RF circuit 1110 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, etc. In addition, the RF circuit 1110 can also communicate with the network and other devices through wireless communication. The above wireless communication can use any communication standard or protocol, including but not limited to the Global System of Mobile Communication (GSM), General Packet Radio Service (GPRS), Code Division Multiple Access (CDMA), Wideband Code Division Multiple Access (WCDMA), Long Term Evolution (LTE), email, Short Messaging Service (SMS), etc.
[0410] The memory 1120 can be used to store software programs and modules. The processor 1180 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1120. The memory 1120 mainly includes a program storage area and a data storage area. Among them, the program storage area can store an operating system, application programs required for at least one function (such as a sound playback function, an image playback function, etc.), etc.; the data storage area can store data created according to the use of the mobile phone (such as audio data, a phone book, etc.), etc. In addition, the memory 1120 can include a high-speed random access memory and can also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other non-volatile solid-state storage devices.
[0411] The input unit 1130 can be used to receive input numeric or character information, and generate key signal inputs related to the user settings and function controls of the mobile phone. Specifically, the input unit 1130 can include a touch panel 1131 and other input devices 1132. The touch panel 1131, also known as a touch screen, can collect touch operations of the user thereon or nearby (such as operations of the user using any suitable object or accessory such as a finger, a stylus, etc. on or near the touch panel 1131), and drive corresponding connection devices according to a preset program. Optionally, the touch panel 1131 can include two parts: a touch detection device and a touch controller. Among them, the touch detection device detects the touch position of the user, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it to the processor 1180, and can receive and execute commands sent by the processor 1180. In addition, various types such as resistive, capacitive, infrared, and surface acoustic wave can be used to implement the touch panel 1131. In addition to the touch panel 1131, the input unit 1130 can also include other input devices 1132. Specifically, the other input devices 1132 can include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control keys, power on / off keys, etc.), a trackball, a mouse, a joystick, etc.
[0412] The display unit 1140 can be used to display information input by the user or information provided to the user as well as various menus of the mobile phone. The display unit 1140 can include a display panel 1141. Optionally, the display panel 1141 can be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc. Further, the touch panel 1131 can cover the display panel 1141. When the touch panel 1131 detects a touch operation thereon or nearby, it transmits it to the processor 1180 to determine the type of touch event. Subsequently, the processor 1180 provides a corresponding visual output on the display panel 1141 according to the type of touch event. Although in Figure 10 the touch panel 1181 and the display panel 1141 are implemented as two independent components to realize the input and input functions of the mobile phone, in some embodiments, the touch panel 1131 and the display panel 1141 can be integrated to realize the input and output functions of the mobile phone.
[0413] The mobile phone may further include at least one sensor 1150, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor may include an ambient light sensor and a proximity sensor. Among them, the ambient light sensor can adjust the brightness of the display panel 1141 according to the brightness of the ambient light, and the proximity sensor can turn off the display panel 1141 and / or the backlight when the mobile phone is moved to the ear. As a kind of motion sensor, the accelerometer sensor can detect the magnitude of acceleration in each direction (generally three axes). When stationary, it can detect the magnitude and direction of gravity, and can be used for applications that identify the posture of the mobile phone (such as horizontal and vertical screen switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc. As for other sensors that the mobile phone can also be configured with, such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., they will not be elaborated here.
[0414] The audio circuit 1160, the speaker 1161, and the microphone 1162 can provide an audio interface between the user and the mobile phone. The audio circuit 1160 can transmit the electrical signal converted from the received audio data to the speaker 1161, and the speaker 1161 converts it into a sound signal for output. On the other hand, the microphone 1162 converts the collected sound signal into an electrical signal, which is received by the audio circuit 1160 and then converted into audio data. After the audio data is output to the processor 1180 for processing, it is sent through the RF circuit 1110 to, for example, another mobile phone, or the audio data is output to the memory 1120 for further processing.
[0415] WiFi belongs to short - range wireless transmission technology. The mobile phone can help users send and receive emails, browse the web, and access streaming media through the WiFi module 1170, which provides users with wireless broadband Internet access. Although Figure 10 the WiFi module 1170 is shown, it can be understood that it does not belong to an essential component of the mobile phone and can be omitted entirely within the scope of not changing the essence of the application according to needs.
[0416] The processor 1180 is the control center of the mobile phone. It connects various parts of the entire mobile phone using various interfaces and lines. By running or executing software programs and / or modules stored in the memory 1120, and by calling the data stored in the memory 1120, it executes various functions of the mobile phone and processes data, thereby monitoring the mobile phone as a whole. Optionally, the processor 1180 may include one or more processing units. Optionally, the processor 1180 may integrate an application processor and a modem processor. Among them, the application processor mainly processes the operating system, user interface, and application programs, etc., and the modem processor mainly processes wireless communication. It can be understood that the above - mentioned modem processor may not be integrated into the processor 1180 either.
[0417] The mobile phone further includes a power source 1190 (such as a battery) for supplying power to each component. Optionally, the power source can be logically connected to the processor 1180 through a power management system, so as to implement functions such as management of charging, discharging, and power consumption management through the power management system.
[0418] Although not shown, the mobile phone may further include a camera, a Bluetooth module, etc., which will not be elaborated here.
[0419] In the embodiment of the present application, the processor 1180 included in the terminal can execute the above Figure 3 、 Figure 4a 、 Figure 4b and Figure 6 the steps described in the corresponding embodiments.
[0420] The cross-chain transaction device provided in the embodiment of the present application can also be deployed in a server. The server can be a single server or a server cluster composed of multiple servers. Hereinafter, a single server will be described. Please refer to Figure 11 , Figure 11 which is a schematic structural diagram of a server provided in the embodiment of the present application. The server 1200 may vary greatly due to different configurations or performances, and may include one or more central processing units (CPUs) 1222 (for example, one or more processors) and a memory 1232, and one or more storage media 1230 (for example, one or more mass storage devices) for storing application programs 1242 or data 1244. Among them, the memory 1232 and the storage media 1230 can be transient storage or persistent storage. The program stored in the storage media 1230 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations on the server. Further, the central processor 1222 can be set to communicate with the storage media 1230 and execute a series of instruction operations in the storage media 1230 on the server 1200.
[0421] The server 1200 may further include one or more power sources 1226, one or more wired or wireless network interfaces 1250, one or more input / output interfaces 1258, and / or one or more operating systems 1241, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
[0422] The steps executed by the server in the above embodiments can be based on the Figure 11 server structure shown.
[0423] The CPU 1222 can execute the above Figure 3, Figure 4a , Figure 4b and Figure 6 the steps described in the corresponding embodiments.
[0424] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product.
[0425] The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website, computer, server, or data center to another website, computer, server, or data center in a wired manner (such as coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wirelessly (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can store, or a data storage device such as a server or data center that includes one or more integrated available media. The available medium can be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a Solid State Disk (SSD)).
[0426] Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working processes of the systems, devices, and units described above can refer to the corresponding processes in the foregoing method embodiments, and will not be described herein again.
[0427] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices, and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division, and there can be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed couplings or direct couplings or communication connections to each other can be indirect couplings or communication connections through some interfaces, devices, or units, and can be in electrical, mechanical, or other forms.
[0428] The unit described as a separation component may or may not be physically separated. The component shown as a unit may or may not be a physical unit, that is, it may be located in one place or may be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0429] In addition, each functional unit in various embodiments of the present application may be integrated in a processing unit, or each unit may exist physically alone, or two or more units may be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
[0430] If the above-mentioned integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present application, in essence, or the part that makes a contribution to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. The foregoing storage medium includes: various media such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs that can store program codes.
[0431] As mentioned above, the above embodiments are only used to illustrate the technical solutions of the present application and are not intended to limit them; although the present application has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments, or perform equivalent replacements on some of the technical features; and these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of various embodiments of the present application.
Claims
1. A cross-chain transaction method, characterized in that, Applied to a first node, the first node maintains a first blockchain, a first transaction belongs to the first blockchain, a second transaction belongs to a second blockchain, and a second node maintains the second blockchain. The method includes: The first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes the consensus verification; The first node sends the transaction status of the first transaction to a third node. The third node does not maintain the first blockchain and the second blockchain, and there are no identical nodes between the nodes maintaining the first blockchain and the nodes maintaining the second blockchain; The first node obtains the transaction status of the second transaction; When the transaction status of the second transaction is the first status, the first node modifies target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node.
2. The method according to claim 1, wherein The first node obtaining the transaction status of the second transaction includes: The first node receives the transaction status of the second transaction sent by the third node, and the third node does not maintain the first blockchain and the second blockchain.
3. The method according to claim 1 or 2, characterized in that, The first node sending the transaction status of the first transaction to the third node includes: The first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
4. The method according to any one of claims 1 to 3, characterized in that, The method further includes: The first node calculates the first hash of the second transaction or receives the first hash of the second transaction sent by a first client, where the first client is the initiator of the first transaction; The first node receives the second hash of the second transaction sent by the third node; Wherein, the equality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is correct; the inequality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is incorrect.
5. The method according to any one of claims 1 to 4, characterized in that The method further includes: The first node calculates the first hash of the first transaction or receives the first hash of the first transaction sent by the first client; The first node sends the first hash of the first transaction to the third node.
6. The method according to any one of claims 1 to 5, characterized in that, After the first node modifies the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, the method further includes: The first node broadcasts synchronization information to a fourth node, and the synchronization information is used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction. The first node and the fourth node belong to the same node cluster.
7. A cross-chain transaction method, characterized in that, The method includes: The third node receives the transaction status of the second transaction from the second node. The second node maintains the second blockchain, and the second transaction belongs to the second blockchain; The third node sends the transaction status of the second transaction to the first node, so that the first node processes target data based on the transaction status of the second transaction and the transaction status of the first transaction, where the target data is the data related to the first transaction in the state machine of the first node, the first transaction belongs to a first blockchain, the first node maintains the first blockchain, the third node does not maintain the first blockchain and the second blockchain, the first transaction is not deployed on the node that maintains the second blockchain, and the second transaction is not deployed on the node that maintains the first blockchain; The third node receives the transaction status of the first transaction from the first node, and the transaction status of the first transaction indicates whether the first transaction passes the consensus verification; The third node sends the transaction status of the first transaction to the second node.
8. The method according to claim 7, characterized in that The method further includes: The third node generates a first block including the transaction status of the second transaction.
9. The method according to claim 8, characterized in that The method further includes: The third node receives transactions sent by at least one fifth node; The third node generates a first block including the transaction status of the second transaction, including: The third node sorts the transactions sent by the at least one fifth node and the transaction status of the second transaction based on the time when it receives the transactions sent by the at least one fifth node and the time when it receives the transaction status of the second transaction, and generates at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
10. The method according to claim 8 or 9, characterized in that, The third node sends the transaction status of the second transaction to the first node, including: The third node sends the first block to the first node.
11. The method according to any one of claims 7 to 10, characterized in that The third node receives the transaction status of the second transaction sent by the second node, including: The third node receives a fourth transaction sent by the second node, and the fourth transaction includes the transaction status of the second transaction.
12. The method according to any one of claims 7 to 11, characterized in that The method further includes: The third node receives the second hash of the second transaction sent by the second node; The third node sends the second hash of the second transaction to the first node, so that the first node determines the correctness of the transaction data of the second transaction based on the second hash of the second transaction and the first hash of the second transaction, where the first hash of the second transaction is calculated by the first node or comes from a first client, and the first client is the initiator of the first transaction.
13. A cross-chain transaction method, characterized in that, Applied to a cross-chain transaction system, the cross-chain transaction system includes a first node, a second node and a third node, the first node maintains a first blockchain, the first transaction belongs to the first blockchain, the second transaction belongs to a second blockchain, the second node maintains the second blockchain, the third node does not maintain the first blockchain and the second blockchain, and the method includes: The first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes the consensus verification, and the execution of the consensus verification is performed by the first node; The first node sends the transaction status of the first transaction to the third node, so that the third node sends the transaction status of the first transaction to the second node; The second node sends the transaction status of the second transaction to the third node; The third node sends the transaction status of the second transaction to the first node; When the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction, and the target data is the data related to the first transaction in the state machine of the first node.
14. The method according to claim 13, wherein The method further includes: The third node generates a first block including the transaction status of the second transaction.
15. The method according to claim 14, wherein The method further includes: The third node receives transactions sent by at least one fourth node; The third node generates a first block including the transaction status of the second transaction, including: The third node sorts the transactions sent by the at least one fifth node and the transaction status of the second transaction based on the time of receiving the transactions sent by the at least one fifth node and the time of receiving the transaction status of the second transaction, and generates at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
16. The method according to any one of claims 13 to 15, characterized in that, The second node sends the transaction status of the second transaction to the third node, including: The second node sends a fourth transaction to the third node, and the fourth transaction includes the transaction status of the second transaction.
17. The method according to claim 14, wherein The first node sends the transaction status of the first transaction to the third node, including: The first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
18. The method according to any one of claims 13 to 17, characterized in that The method further includes: The first node calculates the first hash of the second transaction, or receives the first hash of the second transaction sent by the first client, where the first client is the initiator of the first transaction; The third node receives the second hash of the second transaction sent by the second node; The first node receives the second hash of the second transaction sent by the third node; Wherein, the equality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is correct; the inequality of the first hash and the second hash of the second transaction indicates that the transaction data of the second transaction is incorrect.
19. The method according to any one of claims 13 to 18, characterized in that, The cross-chain transaction system further includes a fourth node, the first node and the fourth node belong to the same node cluster. After the first node modifies the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, the method further includes: The first node broadcasts synchronization information to the fourth node, and the synchronization information is used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction.
20. A cross-chain transaction device, comprising: A memory, a transceiver, a processor, and a bus system; wherein, the memory is used for storing programs and instructions; the transceiver is used for receiving or sending information under the control of the processor; the processor is used for executing the programs in the memory; the bus system is used for connecting the memory, the transceiver, and the processor to enable communication among the memory, the transceiver, and the processor; the processor is used for invoking the program instructions in the memory and executing the cross-chain transaction method as described in any one of claims 1 to 19.
21. A cross-chain transaction device, comprising: A memory, a transceiver, a processor, and a bus system; wherein, the memory is used for storing programs and instructions; the transceiver is used for receiving or sending information under the control of the processor; the processor is used for executing the programs in the memory; the bus system is used for connecting the memory, the transceiver, and the processor to enable communication among the memory, the transceiver, and the processor; the processor is used for invoking the program instructions in the memory and executing the cross-chain transaction method as described in any one of claims 1 to 19.
22. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the instructions run on a computer, the computer is caused to execute the cross-chain transaction method as described in any one of claims 1 to 19.
23. A computer-readable storage medium, wherein instructions are stored in the computer-readable storage medium, and when the instructions run on a computer, the computer is caused to execute the cross-chain transaction method as described in any one of claims 1 to 19.
24. A computer program product, characterized in that, Including computer-readable instructions, when the computer-readable instructions run on a computer device or a processor, the computer device or the processor is caused to execute the method as described in any one of claims 1 to 19.