Patent Description:
In a blockchain (Blockchain) system, all data is stored in blocks. Newly written data forms a new block, and is added to the end of a current blockchain. When storing data, each block also needs to store a number (usually a hash value of all recorded data) that uniquely corresponds to all recorded data in a previous block, to form a chain. Therefore, the blockchain system may be considered as a system in which computers in a distributed network that do not completely trust each other follow a consensus protocol to maintain a set of traceable and tamper-proof chain data together.

There are a plurality of possible scenarios of cross-chain transactions between blockchains. For example, in a scenario <NUM>, a user A on a blockchain <NUM> pays several assets to a user B on a blockchain <NUM>, and in a scenario <NUM>, a user E initiates a transaction a and a transaction b respectively on a blockchain <NUM> and a blockchain <NUM>. The transaction a and the transaction b are associated.

Using the scenario <NUM> as an example, an implementation solution in the prior art is: After negotiation, the user A and the user B determine a user C who has assets on both the blockchains to act as an intermediary. The user A initiates a transaction (transfers an asset) to Escrow on the blockchain <NUM>. The user C initiates a transaction to Escrow on the blockchain <NUM>. Escrow has assets on both the blockchains and is similar to a trusted neutral broker. After determining that both the transactions are completed, Escrow transfers the corresponding assets to the user C and the user B respectively in the two blockchains. However, because the solution relies on the intermediary for implementation, Escrow needs to initiate payment transactions respectively to the user C and the user B on the two blockchains. If either transaction fails for some reason, the successful one needs to be revoked. However, the successful transaction may be irrevocable. As a result, atomic submission of associated transactions to two blockchains fails to be fully implemented.

In conclusion, a cross-chain transaction method is urgently needed at present to implement atomic submission of associated transactions to a plurality of blockchains.

<CIT> describe techniques for implementing cross-chain interoperability between blockchains, aimed at facilitating asset exchanges with minimal modification of the existing blockchain infrastructures.

This application provides a cross-chain transaction method, to implement atomic submission of associated transactions to a plurality of blockchains.

Various aspects of the present disclosure have been defined in the independent claims. Further technical features of each of these aspects have been defined in the respective dependent claims.

In accordance with the principles taught in the present application, for any node on the first blockchain of the blockchains on which the plurality of associated transactions occur, after receiving the association transaction sent by the consensus node, the node needs to determine, based on the identifier of the anchor transaction included in the association transaction, whether the anchor transaction is a valid transaction, and if the anchor transaction is a valid transaction, writes the transaction that occurs in the first blockchain into the first blockchain based on the identifiers of the blockchains on which the plurality of transactions occur, to ensure that the plurality of associated transactions on the plurality of blockchains are successfully submitted simultaneously, and effectively avoid problems in the prior art that a plurality of transactions fail to be submitted simultaneously and a successful transaction may be irrevocable. In addition, according to the method in this application, because the plurality of transactions are atomic, it is not necessary to design an intermediate status and a rollback transaction based on a specific service type, thereby effectively resolving a problem in the prior art that it is difficult to design an intermediate status and a rollback transaction when service logic is relatively complex.

While the description often refers to embodiments, the embodiments of the invention are those which comprise at least all the features of an independent claim. Any embodiment which does not fall within the scope of the claims does not form part of the invention, but rather included as an illustrative example that is useful for understanding the invention.

This application is described below in detail with reference to the accompanying drawings of the specification.

A cross-chain transaction method in this application is applicable to various system architectures. <FIG> is a schematic diagram of a system architecture to which this application is applicable. The system architecture may include a consensus service network, and two or more blockchain networks, for example, a first blockchain network and a second blockchain network that are shown in <FIG>. The consensus service network may include a plurality of consensus nodes, for example, a consensus node a1, a consensus node a2, a consensus node a3, and a consensus node a4 shown in <FIG>, that have a consensus function. In the architecture shown in <FIG>, the first blockchain network and the second blockchain network share consensus services provided by the consensus nodes in the consensus service network.

Specifically, a blockchain network is a peer to peer (peer to peer, P2P) network formed by a plurality of nodes. P2P is an application layer protocol running on a transmission control protocol (transmission control protocol, TCP). Nodes in the blockchain network are equivalent to each other. There is no central node in the network, and each node may be randomly connected to another node.

Because the blockchain network is a P2P distributed network, it is a relatively slow process to check a transaction record and reach a consensus among many nodes. However, during actual application, a relatively fast transaction speed is required in many scenarios. One relatively fast consensus mechanism is proof of.

In this way, the consensus node receives the anchor transaction sent by the node, monitors the data corresponding to the data identifiers in the anchor transaction, and notifies the nodes of a detection result after detecting that the data is modified, to make the nodes fail, based on the detection result, in submitting the plurality of associated transactions simultaneously, so that the plurality of transactions are atomic.

In a possible design, the anchor transaction further includes an anchor version number; and
that the consensus node detects that the data is modified includes:.

In a possible design, after the consensus node receives the anchor transaction sent by the node, the method further includes:
broadcasting, by the consensus node based on the identifiers of the blockchains on which the plurality of transactions occur, the anchor transaction to nodes on blockchains on which the anchor data is located.

In a possible design, after the broadcasting, by the consensus node, the anchor transaction to the nodes on the blockchains on which the plurality of transactions occur, the method further includes:.

According to a third aspect, this application provides a cross-chain transaction system, where the cross-chain transaction system includes a plurality of consensus nodes and nodes on blockchains on which a plurality of associated transactions occur, the nodes on the blockchains on which the plurality of associated transactions occur include a connection node, and the connection node is a node common to the blockchains on which the plurality of associated transactions occur;.

According to a fourth aspect, this application provides a server, where the server is a server on which any node on a first blockchain is located, and the server includes:.

In a possible design, if determining that the anchor transaction is an invalid transaction, the server discards the association transaction.

In a possible design, the transceiver module is further configured to receive an invalid anchor transaction sent by the consensus node, where the invalid anchor transaction includes the identifier of the anchor transaction; and
the processing module is specifically configured to set the anchor transaction to the invalid transaction based on the invalid anchor transaction.

In a possible design, before receiving the association transaction sent by the consensus node, the transceiver module is further configured to receive the anchor transaction sent by the consensus node; and
the processing module is further configured to write the anchor transaction into the first blockchain.

In a possible design, the server is a server on which a node common to the blockchains on which the plurality of transactions occur is located; and
before receiving the association transaction sent by the consensus node, the transceiver module is further configured to: send the anchor transaction corresponding to the plurality of transactions to the consensus node, where the anchor transaction includes data identifiers of the plurality of transactions, the identifiers of the blockchains on which the plurality of transactions occur, and an anchor version number; and send the association transaction to the consensus node after determining that the anchor transaction succeeds.

In a possible design, the transceiver module is further configured to send, by the node, an anchor request corresponding to the plurality of transactions to a notary node, where the anchor request is used to request the notary node to generate the anchor transaction and send the anchor transaction to the consensus node.

In a possible design, the transceiver module is specifically configured to:.

According to a fifth aspect, this application provides a server, where the server is a server on which a consensus node is located, and the server includes:.

In a possible design, the anchor transaction further includes an anchor version number; and
the transceiver module is further configured to:.

In a possible design, after receiving the anchor transaction sent by the node, the transceiver module is further configured to:
broadcast, based on the identifiers of the blockchains on which the plurality of transactions occur, the anchor transaction to nodes on blockchains on which the anchor data is located.

In a possible design, after broadcasting the anchor transaction to the nodes on the blockchains on which the plurality of transactions occur, the transceiver module is further configured to:.

According to a sixth aspect, this application further provides a server, where the server has a function in a method example in the foregoing fourth aspect, and the communications apparatus includes a communications module and a processor;.

Optionally, the communications apparatus may further include a memory, configured to store a program, and the like. Specifically, the program may include program code, and the program code includes an instruction. The memory may include a RAM, and may further include a non-volatile memory (non-volatile memory), for example, at least one magnetic disk memory. The processor executes an application program stored in the memory, so that the server implements the foregoing function.

In a possible manner, the communications module, the processor, and the memory may be connected to each other by using the bus. The bus may be a bus of a peripheral component interconnect (peripheral component interconnect, PCI) standard, a bus with an extended industry standard architecture (extended industry standard architecture, EISA), or the like. The bus may include an address bus, a data bus, a control bus, and the like.

According to a seventh aspect, this application further provides a server, where the server has a function in a method example in the foregoing fifth aspect, and the communications apparatus includes a communications module and a processor;.

This application further provides a computer-readable storage medium, where the storage medium stores an instruction, and when running on a computer, the instruction enables the computer to perform the cross-chain transaction method provided in any one of the foregoing designs.

This application further provides a computer program product including an instruction, and when running on a computer, the computer program product enables the computer to perform the cross-chain transaction method provided in any one of the foregoing designs.

This application further provides a computer program, and when running on a computer, the computer program enables the computer to perform the cross-chain transaction method provided in any one of the foregoing designs.

Because the blockchain network is a P2P distributed network, it is a relatively slow process to check a transaction record and reach a consensus among many nodes. However, during actual application, a relatively fast transaction speed is required in many scenarios. One relatively fast consensus mechanism is proof of endorse (proof of endorse, PoE). The core of the consensus mechanism lies in that a plurality of endorsers (endorser) in the blockchain network execute a smart contract and endorse a contract execution result (content of a contract execution result of a specific endorser is signed to ensure that a result is sent by the endorser). A user may set, according to an actual requirement, endorsers that need to be trusted for a smart contract of the user and a verification policy of a plurality of contract execution results. For example, an execution proposal (proposal) for a smart contract may be sent to three endorsers. The verification policy may require that three contract execution results have consistent content or require that at least two contract execution results have consistent content. A client device collects the contract execution results returned by the endorsers, adds the contract execution results to a transaction, and broadcasts the contract execution results to all nodes (including the endorsers) in the blockchain network by using a consensus service network. The nodes check the received transaction, and if the transaction meets the verification policy, the nodes accept modifications to data by the transaction, and write the transaction into a blockchain.

During actual execution, the entire blockchain network is distributed, leading to time differences in data synchronization. Data obtained by an endorser when the endorser executes code of a smart contract of a transaction is probably inconsistent with data that exists when the transaction is eventually to be issued into a blockchain, leading to an endorsement failure of the endorser. To resolve the problem, an auto-increment version number may be set for each piece of data of a smart contract, and the version number of the data is updated when the data is updated.

As shown in <FIG>, the first blockchain network includes a node b1, a node b2, a node b3, a node b4, a node d1, and a node d2. The nodes maintain a blockchain <NUM> together. The second blockchain network includes a node c1, a node c2, a node c3, a node c4, a node c5, the node d1, and the node d2. The nodes maintain a blockchain <NUM> together. A blockchain stores a list of transactions in blocks. Blocks on the blockchain are generated in chronological order, and each block is used to record a list of transactions generated within a period of time. A list of all transactions recorded on the blockchain is a ledger (Ledger). For example, a ledger recorded on the blockchain <NUM> is a Ledger <NUM>, and a ledger recorded on the blockchain <NUM> is a Ledger <NUM>. In this application, a ledger and a blockchain may be equivalent and interchangeable concepts without causing ambiguity.

It should be noted that the foregoing system architecture is merely a logical example. Physically, a node on a blockchain network is on a physical machine (server), or a plurality of nodes in a plurality of blockchain networks are on a same server. A node may be specifically a process or a series of processes that run on a server. For example, the node a1 in the first blockchain network and the node c1 in the second blockchain network may be two processes running on a server.

The node described in this application may be a server on which the node is located.

Further, one or more clients may communicate with a node by accessing a network. For example, if a user A has an asset on the blockchain <NUM>, the user A may communicate with any node in the first blockchain network by using a client a, to initiate a transaction on the blockchain <NUM>. If a user B has an asset on the blockchain <NUM>, the user B may communicate with any node in the second blockchain network by using a client b, to initiate a transaction on the blockchain <NUM>. If a user C has assets on both the blockchain <NUM> and the blockchain <NUM>, the user C may communicate with any node in both the first blockchain network and the second blockchain network by using a client c, to initiate a transaction on the blockchain <NUM> or the blockchain <NUM>.

It should be noted that in this application, a client device may be omitted. In this case, a user may directly initiate a transaction on a blockchain by using a node on the blockchain, and this is not specifically limited.

Based on the architecture shown in <FIG>, an asset transaction is conducted between blockchains. For example, in a scenario, the user A on the blockchain <NUM> pays <NUM> units of asset to the user B on the blockchain <NUM>. In an implementation in the prior art, a role of Escrow similar to a neutral broker is introduced in each blockchain. The user A and the user B first respectively initiate transactions to Escrow in the two blockchains. After determining that both the transactions are completed, Escrow separately transfers assets to participants on the blockchains. A specific procedure is as follows:.

The foregoing solution may expand to asset payment of N blockchains (a blockchain <NUM>→. →a blockchain N). The notaries observe whether a payee on the blockchain N has issued a payee signature, to instruct Escrow to send escrowed assets to recipients of transactions or return the assets to initiators of the transactions on all the blockchains.

In the foregoing implementation, Escrow needs to initiate payment transactions respectively to the user C and the user B on the two blockchains. If either transaction fails for some reason, the successful one needs to be revoked. However, the successful transaction may be irrevocable. As a result, transaction security is relatively poor.

Based on this, this application provides a cross-chain transaction method. For any node on a first blockchain of blockchains on which a plurality of associated transactions occur, after receiving an association transaction sent by a consensus node, the node needs to determine, based on an identifier of an anchor transaction included in the association transaction, whether the anchor transaction is a valid transaction, and if the anchor transaction is a valid transaction, writes a transaction that occurs in the first blockchain into the first blockchain based on identifiers of the blockchains on which the plurality of transactions occur, to ensure that the plurality of associated transactions on the plurality of blockchains are successfully submitted simultaneously, and effectively avoid problems in the prior art that a plurality of transactions fail to be submitted simultaneously and a successful transaction may be irrevocable. In addition, according to the method in this application, because the plurality of transactions are atomic, it is not necessary to design an intermediate status and a rollback transaction based on a specific service type, thereby effectively resolving a problem in the prior art that it is difficult to design an intermediate status and a rollback transaction when service logic is relatively complex.

To describe this application clearly, a node that may conduct an association transaction on a plurality of blockchains (for example, the blockchain <NUM> and the blockchain <NUM> in <FIG>) may be referred to as a connection node (connect peer), and a node that may perform endorsement for data transacted on the plurality of blockchains may be referred to as a notary node (notary peer). The connection node and the notary node are both nodes common to the blockchain <NUM> and the blockchain <NUM>. The notary node is a node specified in advance from nodes common to a plurality of blockchains and is configured to provide third-party notarization. The notary node can receive transaction information of the plurality of blockchains.

Based on the system architecture shown in <FIG>, <FIG> is a schematic flowchart corresponding to a cross-chain transaction method according to Embodiment <NUM> of this application.

Step <NUM>: A connection node generates an anchor transaction corresponding to a plurality of transactions based on the plurality of associated transactions, and sends the anchor transaction to a consensus node, where the anchor transaction includes data identifiers of the plurality of transactions, identifiers of blockchains on which the plurality of transactions occur, and an anchor version number.

Herein, the plurality of associated transactions may be two or more associated transactions. Correspondingly, the blockchains on which the plurality of transactions occur are two or more blockchains, for example, a blockchain <NUM>, a blockchain <NUM>,. , and a blockchain N, where N is a positive integer.

By using a scenario in which "a user A needs to use an asset of the user A on the blockchain <NUM> to pay several assets on the blockchain <NUM> to a user B on the blockchain <NUM>, and selects a user C that has assets on both the blockchains as an intermediary" as an example, the user A, the user B, and the user C negotiate that the user A pays an asset to the user C on the blockchain <NUM> (a first transaction), and the user C pays an asset to the user B on the blockchain <NUM> (a second transaction). The first transaction and the second transaction are the plurality of associated transactions. A blockchain on which the first transaction occurs is the blockchain <NUM>, and a blockchain on which the second transaction occurs is the blockchain <NUM>.

The data identifiers of the plurality of transactions are variables of data to be accessed by invoking a smart contract request on the blockchains on which the plurality of transactions occur. The data corresponding to the data identifiers of the plurality of transactions is the data to be accessed by invoking the smart contract request on the blockchains on which the plurality of transactions occur. For example, a data identifier of the first transaction may be an identifier of the user A and an identifier of the user C. Data corresponding to the identifier of the user A is asset data of the user A on the blockchain <NUM>, and data corresponding to the identifier of the user C is asset data of the user C on the blockchain <NUM>.

The anchor version number is a version number of the data to be accessed by invoking the smart contract request on the blockchains on which the plurality of transactions occur.

An identifier of a blockchain may be information, for example, a number of the blockchain, used to uniquely identify the blockchain, and is not specifically limited.

Further, in this application, the plurality of associated transactions may carry a same association identifier. After generating the anchor transaction corresponding to the plurality of transactions, the connection node may establish and store a correspondence between an identifier of the anchor transaction and the association identifier carried in the plurality of transactions. There may be a plurality of specific storage manners, for example, storage in a form of a data table, as shown in Table <NUM>.

Step <NUM>: The consensus node receives the anchor transaction, and monitors the data corresponding to the data identifiers.

In this application, the consensus node implements monitoring in a plurality of manners. For example, the consensus node may implement monitoring by maintaining a local data monitoring table. Each time the consensus node sends an anchor transaction, the consensus node adds the anchor transaction to the data monitoring table; and when detecting that the data corresponding to the data identifiers is modified, the consensus node removes the anchor transaction from the data monitoring table.

Specifically, the consensus node may be implemented by using message queuing middleware, and receives, via a same interface, anchor transactions sent by connection nodes. As shown in <FIG>, the consensus node records, based on the identifiers of the blockchains on which the plurality of transactions in the anchor transaction occur, transaction information into different partitions, for example, a partition <NUM>, a partition <NUM>, and a partition <NUM>, and different partitions correspond to transactions on different blockchains. For example, the partition <NUM> corresponds to a transaction on the blockchain <NUM>, the partition <NUM> corresponds to a transaction on the blockchain <NUM>, and the partition <NUM> corresponds to a transaction on the blockchain <NUM>. Using the partition <NUM> as an example, numbers (<NUM>, <NUM>, <NUM>,. , <NUM>, <NUM>,. ) in the partition <NUM> are used to indicate transactions that need to be monitored on the blockchain <NUM>. The consensus node may pack, based on an identifier of a blockchain, transaction information in different partitions into a block (block), and send the block to a node of the corresponding blockchain.

Step <NUM>: The consensus node broadcasts an invalid anchor transaction to nodes on the blockchains on which the plurality of transactions occur if detecting that the data corresponding to the data identifiers is modified, where the invalid anchor transaction includes identifier information of the anchor transaction, and the invalid anchor transaction is used to indicate that the anchor transaction is an invalid transaction.

In this application, there may be a plurality of cases resulting in modifications to the data corresponding to the data identifiers. For example, the consensus node receives a third transaction (the user A pays an asset to a user D on the blockchain <NUM>). Because the third transaction has modified the asset data of the user A, the data corresponding to the data identifiers is modified. Specifically, when the third transaction includes a version number of the data corresponding to the data identifiers, if it is determined that the version number included in the third transaction is different from the anchor version number in the anchor transaction, the consensus node detects that the data corresponding to the data identifiers is modified. When the third transaction does not include a version number, if it is determined that a write operation is performed on the data corresponding to the data identifiers in the third transaction, the consensus node detects that the data corresponding to the data identifiers is modified.

After receiving the third transaction, the consensus node detects that the third transaction has modified the data (specifically, the asset data of the user A on the blockchain <NUM>) corresponding to the data identifiers in the anchor transaction, records the third transaction into a queue of transactions to be broadcasted on the blockchain <NUM>, immediately adds the invalid anchor transaction to queues of transactions to be broadcasted of the blockchain <NUM> and the blockchain <NUM>, updates the local data monitoring table, deletes the anchor transaction from the data monitoring table, and no longer monitors anchor data.

Step <NUM>: Nodes on the blockchains on which the plurality of transactions occur receive the invalid anchor transaction sent by the consensus node.

Step <NUM>: The connection node sends an association transaction to the consensus node, where the association transaction includes transaction content of the plurality of transactions, the identifiers of the blockchains on which the plurality of transactions occur, and the identifier of the anchor transaction.

Step <NUM>: The consensus node receives the association transaction, and sends, based on the identifiers of the blockchains on which the plurality of transactions occur, the association transaction to the nodes on the blockchains on which the plurality of transactions occur.

Herein, for the foregoing scenario, after receiving the association transaction, the consensus node may send the association transaction to the nodes on the blockchain <NUM> and the nodes on the blockchain <NUM> based on an identifier of the blockchain <NUM> on which the first transaction occurs and an identifier of the blockchain <NUM> on which the second transaction occurs.

Step <NUM>: For any node on the first blockchain of the blockchains on which the plurality of transactions occur, after receiving the association transaction, the node determines, based on the identifier of the anchor transaction included in the association transaction, that the anchor transaction is an invalid transaction, and discards the association transaction.

In this application, the node further needs to locally verify a transaction format, a signature, and the like of the association transaction, and the node can write a transaction that occurs in the first blockchain into the first blockchain only when the transaction format, the signature, and the like are locally verified and the anchor transaction is a valid transaction. Refer to the prior art for specific content of locally verifying the transaction format, the signature, and the like of the association transaction, and details are not described herein again. Further, a sequence of the local verification and the anchor transaction verification is not limited in this application. In a possible implementation, the node may first verify whether the anchor transaction is a valid transaction, and if the anchor transaction is an invalid transaction, the node may directly discard the association transaction and no longer needs to perform validity verification, thereby reducing processing burden.

Herein, the first blockchain is any blockchain of the blockchains on which the plurality of transactions occur, for example, the blockchain <NUM> or the blockchain <NUM>. Specifically, after receiving the association transaction, the node on the blockchain <NUM> and the node on the blockchain <NUM> determine that the anchor transaction is an invalid transaction based on the identifier of the anchor transaction included in the association transaction and the invalid anchor transaction that is received in step <NUM>, and then discard the association transaction. In this case, the first transaction and the second transaction in the association transaction fail to be submitted simultaneously.

It should be noted that, in this application, in step <NUM>, if the consensus node does not detect that the data corresponding to the data identifiers is modified, the consensus node may skip processing. In this way, the nodes on the blockchains on which the plurality of transactions occur do not receive the invalid anchor transaction. Correspondingly, in step <NUM>, after receiving the association transaction, the nodes on the blockchains on which the plurality of transactions occur determine that the anchor transaction is a valid transaction, and write the association transaction into corresponding blockchains. Specifically, after receiving the association transaction, the node on the blockchain <NUM> determines that the anchor transaction is a valid transaction, and writes the first transaction into the blockchain <NUM>. After receiving the association transaction, the node on the blockchain <NUM> determines that the anchor transaction is a valid transaction, and writes the second transaction into the blockchain <NUM>. After receiving the association transaction, the connection node (a node common to the blockchain <NUM> and the blockchain <NUM>) determines that the anchor transaction is a valid transaction, writes the first transaction into the blockchain <NUM>, and writes the second transaction into the blockchain <NUM>. In this case, the first transaction and the second transaction in the association transaction are successfully submitted simultaneously. Refer to <FIG> for a specific procedure in this case. By comparing a procedure shown in <FIG> with that in <FIG>, because detection results of the consensus node are different, different execution results are caused. Refer to descriptions in <FIG> for all related steps in <FIG>, and details are not described again.

Further, in the foregoing step <NUM>, to reduce the processing burden of the consensus node, a corresponding timer may be started when the consensus node receives the anchor transaction and starts monitoring. If the timer does not detect, within specified duration, that the data is modified, the invalid anchor transaction may be broadcasted, and the consensus node no longer performs monitoring. The specified duration may be set by a person skilled in the art based on an actual case. In a possible scenario, the consensus node does not detect, within the specified duration, that the data is modified, and the association transaction has been successfully submitted before the specified duration of the timer ends. In this case, the consensus node no longer needs to monitor the anchor transaction. To prevent the anchor transaction from subsequent malicious use, the consensus node may broadcast the invalid anchor transaction to the nodes on the blockchains on which the plurality of transactions occur.

It should be noted that, (<NUM>) numbers of the foregoing steps are merely examples of indication of an execution process, and sequences of the steps are not specifically limited in this application. (<NUM>) Step <NUM> and step <NUM> may occur at any time after step <NUM> and before step <NUM>, and this is not specifically limited. (<NUM>) In <FIG> and <FIG>, a case in which there are only two blockchains (the blockchain <NUM> and the blockchain <NUM>) is used as an example. During specific implementation, there may be more than two blockchains (the blockchain <NUM>, the blockchain <NUM>,. , the blockchain N), and refer to the foregoing descriptions for an implementation process when there are more than two blockchains.

<FIG> is a schematic flowchart corresponding to a cross-chain transaction method according to this application.

Step <NUM>: A connection node generates an anchor request corresponding to a plurality of transactions based on the plurality of associated transactions, and sends the anchor request to a notary node, where the anchor request includes data identifiers of the plurality of transactions, identifiers of blockchains on which the plurality of transactions occur, and an anchor version number.

In this application, the plurality of associated transactions may carry a same association identifier. After generating the anchor request corresponding to the plurality of transactions, the connection node may establish and store a correspondence between an identifier of the anchor request and the association identifier carried in the plurality of transactions. There may be a plurality of specific storage manners, for example, storage in a form of a data table, as shown in Table <NUM>.

Step <NUM>: After receiving the anchor request sent by the connection node, the notary node generates an anchor transaction corresponding to the anchor request, and sends the anchor transaction to a consensus node, where the anchor transaction includes the data identifiers of the plurality of transactions, the identifiers of the blockchains on which the plurality of transactions occur, and the anchor version number.

Herein, after receiving the anchor request, the notary node may verify whether the anchor version number in the anchor request is the same as that in a local ledger, and if the anchor version number in the anchor request is the same as that in the local ledger, generates the anchor transaction corresponding to the anchor request, and executes a subsequent procedure, or if the anchor version number in the anchor request is not the same as that in the local ledger, returns a message indicating invalid data to the connection node and ends the procedure.

In this application, after generating the anchor transaction corresponding to the anchor request, the notary node may establish and store a correspondence between the identifier of the anchor request and the identifier of the anchor transaction, as shown in Table <NUM>.

Step <NUM>: The consensus node receives the anchor transaction, sends, based on the identifiers of the blockchains on which the plurality of transactions occur, the anchor transaction to nodes on the blockchains on which the plurality of transactions occur, and monitors data corresponding to the data identifiers.

Step <NUM>: The consensus node broadcasts an invalid anchor transaction to the nodes on the blockchains on which the plurality of transactions occur if detecting that the data corresponding to the data identifiers is modified, where the invalid anchor transaction includes identifier information of the anchor transaction, and the invalid anchor transaction is used to indicate that the anchor transaction is an invalid transaction.

Step <NUM>: The nodes on the blockchains on which the plurality of transactions occur receive the invalid anchor transaction sent by the consensus node, and set the anchor transaction to an invalid transaction.

Specifically, when the nodes set the anchor transaction to an invalid transaction, the nodes may set an invalidity identifier for the anchor transaction. The invalidity identifier indicates that the anchor transaction is an invalid transaction, or setting may be performed in another manner, and this is not specifically limited.

In this application, a node may locally maintain a list of anchor transactions. The list includes the identifier of the anchor transaction and an invalidity identifier indicating that the anchor transaction is an invalid transaction. An anchor transaction with an invalidity identifier is an invalid transaction, and an anchor transaction without an invalidity identifier is a valid transaction. In this way, it can be quickly determined, by searching the list, whether the anchor transaction is a valid transaction or an invalid transaction.

It should be noted that, when the nodes set the anchor transaction to an invalid transaction, the nodes may directly delete an invalid anchor transaction from the list. In this way, the nodes search the list, and if the nodes cannot find the anchor transaction in the list, the nodes determine that the anchor transaction is an invalid transaction, and if the nodes can find the anchor transaction in the list, the nodes determine that the anchor transaction is a valid transaction.

Step <NUM>: After receiving the anchor transaction sent by the consensus node in step <NUM>, the notary node sends anchor indication information to an intermediate node, where the anchor indication information is used to indicate that the anchor transaction succeeds, and the anchor indication information includes the identifier of the anchor transaction and the identifier of the anchor request corresponding to the anchor transaction.

Herein, after receiving the anchor transaction, the notary node may determine the identifier of the corresponding anchor request based on the identifier of the anchor transaction and the correspondence between the identifier of the anchor transaction and the identifier of the anchor request, and further sends the anchor indication information to the intermediate node.

Step <NUM>: The connection node receives the anchor indication information sent by the notary node, determines, based on the identifier of the anchor request, a corresponding association identifier, further generates the association transaction based on the plurality of transactions carrying the association identifier, and sends the association transaction to the consensus node, where the association transaction includes the transaction content of the plurality of transactions, the identifiers of the blockchains on which the plurality of transactions occur, and the identifier of the anchor transaction.

It should be noted that in this application, in step <NUM>, if the consensus node does not detect that the data corresponding to the data identifiers is modified, the consensus node may skip processing. In this way, in step <NUM>, after receiving the association transaction, the nodes on the blockchains on which the plurality of transactions occur determine that the anchor transaction is a valid transaction, and write the association transaction into corresponding blockchains. Specifically, after receiving the association transaction, the node on the blockchain <NUM> determines that the anchor transaction is a valid transaction, and writes the first transaction into the blockchain <NUM>, after receiving the association transaction, the node on the blockchain <NUM> determines that the anchor transaction is a valid transaction, and writes the second transaction into the blockchain <NUM>, and after receiving the association transaction, the notary node and the connection node (where the notary node and the connection node are both nodes common to the blockchain <NUM> and the blockchain <NUM>) determine that the anchor transaction is a valid transaction, write the first transaction into the blockchain <NUM>, and write the second transaction into the blockchain <NUM>. Refer to <FIG> for a specific procedure in this case. By comparing a procedure shown in <FIG> with that in <FIG>, because detection results of the consensus node are different, different execution results are caused. Refer to descriptions in <FIG> for all related steps in <FIG>, and details are not described again.

Further, in the foregoing step <NUM>, to reduce the processing burden of the consensus node, a corresponding timer may be started when the consensus node receives the anchor transaction and starts monitoring. If the timer does not detect, within specified duration, that the data is modified, the invalid anchor transaction may be broadcasted, and the consensus node no longer performs monitoring. The specified duration may be set by a person skilled in the art based on an actual case. In a possible scenario, after the consensus node broadcasts the anchor transaction to the nodes on the blockchains on which the plurality of transactions occur, the node may verify the anchor transaction. When the node receives the anchor transaction, if the anchor version number in the anchor transaction is different from that in a ledger on the node, it indicates that the anchor version number has expired. In this case, the node may directly set the anchor transaction to an invalid transaction. For the consensus node, the specified duration is set, so that after the specified duration of the timer ends, the consensus node broadcasts the invalid anchor transaction to the nodes on the blockchains on which the plurality of transactions occur, and no longer monitors the anchor transaction.

It should be noted that, (<NUM>) numbers of the foregoing steps are merely examples of indication of an execution process, and sequences of the steps are not specifically limited in this application. (<NUM>) Step <NUM> and step <NUM> may occur at any time after step <NUM> and before step <NUM>, and this is not specifically limited. (<NUM>) For the foregoing step <NUM> and step <NUM>, in another possible implementation, the anchor request sent by the connection node to the notary node includes only the data identifiers of the plurality of transactions and the identifiers of the blockchains on which the plurality of transactions occur, and further the notary node obtains the anchor version number based on the anchor request, and generates and sends the anchor transaction to the consensus node. (<NUM>) In <FIG> and <FIG>, a case in which there are only two blockchains (the blockchain <NUM> and the blockchain <NUM>) is used as an example. During specific implementation, there may be more than two blockchains (the blockchain <NUM>, the blockchain <NUM>,. , the blockchain N), and refer to the foregoing descriptions for an implementation process when there are more than two blockchains.

For specific implementation processes of the foregoing Embodiment <NUM> and Embodiment <NUM>, it can be learned that Embodiment <NUM> differs from Embodiment <NUM> in that: (<NUM>) The notary node is used in Embodiment <NUM>. To be specific, before initiating the association transaction, the connection node first sends the anchor request to the notary node, and further, the notary node sends the anchor transaction to the consensus node. The notary node that has authority is introduced, verifies the anchor version number, and generates the anchor transaction after the anchor version number is verified, so that the validity of the anchor version number can be ensured. (<NUM>) In Embodiment <NUM>, after receiving the anchor transaction, the consensus node broadcasts, based on the identifiers of the blockchains on which the plurality of transactions occur, the anchor transaction to the nodes on the blockchains on which the plurality of transactions occur, so that the nodes on the blockchains can effectively record an implementation process of the transactions by receiving the anchor transaction. In addition, when the implementation in Embodiment <NUM> is used, if the consensus node maliciously broadcasts the invalid anchor transaction, the nodes on the blockchains receive only the invalid anchor transaction, and as a result cannot recognize the malicious invalid anchor transaction, leading to a transaction failure. When the implementation in Embodiment <NUM> is used, because the nodes on the blockchains first receive the anchor transaction, the nodes may identify, based on the anchor transaction, whether the invalid anchor transaction is malicious, thereby effectively ensuring reliable implementation of the transactions.

In addition to the differences described above, refer to corresponding steps in Embodiment <NUM> for specific implementations of the steps in Embodiment <NUM>.

A cross-chain transaction method in this application is described below with reference to a specific embodiment (an implementation procedure in Embodiment <NUM> is used).

A scenario of this embodiment is: A user A on a blockchain <NUM> (Chain <NUM>) intends to pay currency on a blockchain <NUM> to a user B on the blockchain <NUM> (Chain <NUM>), a type of currency on the blockchain <NUM> is Coin <NUM>, a type of the currency on the blockchain <NUM> is Coin <NUM>, and the user A invites a user C who has assets on both the blockchain <NUM> and the blockchain <NUM> to act as an intermediary. Before a transaction starts, assets of the roles are shown in Table 4a and Table 4b.

After negotiation among the user A, the user B, and the user C, the user C needs to charge <NUM> Coin <NUM> (referred to as a transaction <NUM>) to the user A on the blockchain <NUM>, and pays <NUM> Coin <NUM> (referred to as a transaction <NUM>) to user B on the blockchain <NUM>. A function of a transfer transaction is transfer, and pseudocode of a function of a smart contract is as follows:
<IMG>
<IMG>.

After a final transaction is completed, a desired effect is shown in Table 5a and Table 5b.

An implementation process of an association transaction is described below in detail:.

(<NUM>) A connection node generates a corresponding anchor request (anchor request) based on the transaction <NUM> and the transaction <NUM> that are associated with each other, and sends the anchor request to a notary node, where the anchor request includes data identifiers (key) of the transaction <NUM> and the transaction <NUM>, identifiers (chain name) of blockchains on which the transaction <NUM> and the transaction <NUM> occur, and an anchor version number (version). Specific content included in the anchor request is shown in Table <NUM>.

(<NUM>) After receiving the anchor request, the notary node verifies whether the anchor version number in the anchor request is the same as that in a local ledger, and if the anchor version number in the anchor request is not the same as that in the local ledger, sends a message indicating invalid data to the connection node and ends a procedure, or if the anchor version number in the anchor request is the same as that in the local ledger, generates an anchor transaction (Tx <NUM>) corresponding to the anchor request based on the anchor request, and sends the anchor transaction to the consensus node. The anchor transaction includes the data identifiers (key) of the transaction <NUM> and the transaction <NUM>, the identifiers (chain name) of the blockchains on which the transaction <NUM> and the transaction <NUM> occur, and the anchor version number (version). Specific content included in the anchor transaction is shown in Table <NUM>.

(<NUM>) After receiving the anchor transaction, the consensus node starts to monitor a write operation on data corresponding to the data identifiers in a subsequent transaction, and broadcasts the anchor transaction to all nodes on the blockchain <NUM> and the blockchain <NUM>.

(<NUM>) After receiving the anchor transaction broadcasted from the consensus node, the notary node sends anchor indication information to the connection node, where the anchor indication information includes an identifier of the anchor transaction and an identifier of the anchor request corresponding to the anchor transaction, and the notary node provides a signature.

(<NUM>) After receiving the anchor indication information, the connection node obtains, based on the identifier of the anchor request, the transaction <NUM> and the transaction <NUM> that correspond to the anchor request, further generates an association transaction (Tx <NUM>) based on the transaction <NUM> and the transaction <NUM>, and sends the association transaction to the consensus node. Specific content in the association transaction is shown in Table <NUM>.

(<NUM>) The consensus node broadcasts the association transaction to all the nodes on the blockchain <NUM> and the blockchain <NUM>.

(<NUM>) When receiving the association transaction, in addition to normal verification of a transaction format, a signature, and the like (the node of each blockchain verifies only content related to the a blockchain on which the node is located), the nodes on the blockchain <NUM> and the blockchain <NUM> further need to verify whether the anchor transaction corresponding to the association transaction is a valid transaction; if the anchor transaction corresponding to the association transaction is a valid transaction, the node on the blockchain <NUM> writes the transaction <NUM> into the blockchain <NUM>, and the node on the blockchain <NUM> writes the transaction <NUM> into the blockchain <NUM>.

At this time, the transaction <NUM> and the transaction <NUM> are successfully submitted simultaneously.

In the foregoing process, because the consensus node does not monitor a write operation on the anchor data in a subsequent transaction, the transaction <NUM> and the transaction <NUM> are successfully submitted simultaneously. It is assumed that there is another transaction <NUM> that conflicts with (that is, same data needs to be modified) the association transaction between (<NUM>) to (<NUM>) in the foregoing, and the transaction <NUM> reaches the consensus node before the association transaction for broadcasting. A format of the transaction <NUM> is shown in Table <NUM>.

In this way, after the foregoing step (<NUM>), a corresponding procedure is:.

(4a) When receiving the transaction <NUM> (Tx <NUM>), and detecting that the transaction <NUM> modifies anchor data Chain <NUM>/A in the anchor transaction, the consensus node immediately adds a transaction <NUM> (Tx <NUM>) of an invalid anchor transaction separately to the blockchain <NUM> and the blockchain <NUM> included in the anchor transaction after recording the transaction <NUM> into a queue of transactions to be broadcasted of the blockchain <NUM>. A format of the transaction <NUM> is shown in Table <NUM>.

In addition, the consensus node updates the local data monitoring table, deletes the anchor transaction (Tx <NUM>) from the data monitoring table, and no longer monitors a data change in the anchor transaction. (4b) After receiving the transaction <NUM> (Tx <NUM>), the nodes on the blockchain <NUM> and the blockchain <NUM> find the Tx <NUM> in the locally maintained list of anchor transactions based on the identifier (Tx <NUM>) of the anchor transaction included in the transaction <NUM>, and mark the Tx <NUM> as invalid (or deletes the Tx <NUM> from the list). (4c) The nodes receive the association transaction (Tx <NUM>) sent by the consensus node, search the list of anchor transactions based on the identifier of the anchor transaction (Tx <NUM>) included in the association transaction, determine the anchor transaction as an invalid transaction, and further discard the association transaction without writing the association transaction into the blockchains maintained by the nodes. In this case, the transaction <NUM> and the transaction <NUM> fail to be submitted simultaneously.

For the foregoing method procedure, this application further provides a server. Refer to the foregoing method procedure for specific implementation of the server.

This application provides a first server. The server is configured to implement a procedure or step performed by any one of a connection node, a node on the blockchain <NUM>, a node on the blockchain <NUM>,. , and a node on the blockchain N in the method embodiment shown in <FIG>, <FIG>, <FIG>, and <FIG>. Referring to <FIG>, a server <NUM> may include a transceiver module <NUM> and a processing module <NUM>.

The transceiver module <NUM> is configured to receive an association transaction sent by a consensus node, where the association transaction includes transaction content of a plurality of transactions, identifiers of blockchains on which the plurality of transactions occur, and an identifier of an anchor transaction, and the first blockchain is any blockchain of the blockchains on which the plurality of transactions occur.

The processing module <NUM> is configured to write a transaction that occurs in the first blockchain into the first blockchain based on the identifiers of the blockchains on which the plurality of transactions occur if determining, based on the identifier of the anchor transaction, that the anchor transaction is a valid transaction.

This application provides a second server. The server is configured to implement a procedure or step performed by a consensus node in the method embodiment shown in <FIG>, <FIG>, <FIG>, and <FIG>. Referring to <FIG>, a server <NUM> may include a transceiver module <NUM> and a processing module <NUM>.

The transceiver module <NUM> is configured to receive an anchor transaction sent by a node, where the anchor transaction includes data identifiers of the plurality of transactions, identifiers of blockchains on which the plurality of transactions occur, and an anchor version number.

The processing module <NUM> is configured to: monitor data corresponding to the data identifiers, and broadcast, by using the transceiver module, an invalid anchor transaction to nodes on the blockchains on which the plurality of transactions occur if detecting that the data corresponding to the data identifiers is modified, where the invalid anchor transaction includes identifier information of the anchor transaction, and the invalid anchor transaction is used to indicate that the anchor transaction is an invalid transaction.

It should be noted that, in this embodiment of this application, module division is exemplary, and is merely a logical function division. In actual implementation, another division manner may be used. Functional modules in the embodiments of this application may be integrated into one processing module, or each of the modules may exist alone physically, or two or more modules are integrated into one module. The integrated module may be implemented in a form of hardware, or may be implemented in a form of a software functional module.

When the integrated module is implemented in the form of a software functional module and sold or used as an independent product, the integrated unit may be stored in a computer-readable storage medium. Based on such an understanding, the technical solutions of this application essentially, or the part contributing to the prior art, or all or some of the technical solutions may be implemented in the form of a software product. The software product is stored in a storage medium and includes several instructions for instructing a computer device (which may be a personal computer, a server, or a network device) or a processor (processor) to perform all or some of the steps of the methods described in the embodiments of this application. The foregoing storage medium includes: any medium that can store program code, such as a USB flash drive, a removable hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk, or an optical disc.

This application provides a third server. The server is configured to implement a procedure or step performed by any one of a connection node, a node on the blockchain <NUM>, a node on the blockchain <NUM>,. , and a node on the blockchain N in the method embodiment shown in <FIG>, <FIG>, <FIG>, and <FIG>. The server implements a function of the server <NUM> shown in <FIG>. As shown in <FIG>, a communications apparatus <NUM> includes a communications module <NUM> and a processor <NUM>.

The communications module <NUM> is configured to communicatively interact with another device, where the communications module <NUM> may be an RF circuit, a Wi-Fi module, a communications interface, a Bluetooth module, or the like.

The processor <NUM> is configured to implement a function of the processing module in <FIG>.

Optionally, the communications apparatus may further include the memory <NUM>, configured to store a program, and the like. Specifically, the program may include program code, and the program code includes an instruction. The memory <NUM> may include a RAM, and may further include a non-volatile memory (non-volatile memory), for example, at least one magnetic disk memory. The processor <NUM> executes an application program stored in the memory <NUM>, to implement the foregoing function.

In a possible manner, the communications module <NUM>, the processor <NUM>, and the memory <NUM> may be connected to each other by using the bus <NUM>. The bus <NUM> may be a bus of a peripheral component interconnect (peripheral component interconnect, PCI) standard, a bus with an extended industry standard architecture (extended industry standard architecture, EISA), or the like. The bus <NUM> may include an address bus, a data bus, a control bus, and the like.

This application further provides a fourth server. The server is configured to implement a procedure or step performed by a consensus node in the method embodiment shown in <FIG>, <FIG>, <FIG>, and <FIG>. The server implements a function of the server <NUM> shown in <FIG>. As shown in <FIG>, a communications apparatus <NUM> includes a communications module <NUM> and a processor <NUM>.

A person skilled in the art should understand that the embodiments of the present invention may be provided as a method, a system, or a computer program product. Therefore, the embodiments of the present invention may use a form of hardware only embodiments, software only embodiments, or embodiments with a combination of software and hardware. Moreover, the embodiments of the present invention may use a form of a computer program product that is implemented on one or more computer-usable storage media (including but not limited to a disk memory, a CD-ROM, an optical memory, and the like) that include computer-usable program code.

The embodiments of the present invention are described with reference to the flowcharts and/or block diagrams of the method, the device (system), and the computer program product according to the embodiments of the present invention. It should be understood that computer program instructions may be used to implement each procedure and/or each block in the flowcharts and/or the block diagrams and a combination of a procedure and/or a block in the flowcharts and/or the block diagrams. These computer program instructions may be provided for a general-purpose computer, a special-purpose computer, an embedded processor, or a processor of any other programmable data processing device to generate a machine, so that the instructions executed by a computer or a processor of any other programmable data processing device generate an apparatus for implementing a specific function in one or more procedures in the flowcharts and/or in one or more blocks in the block diagrams.

These computer program instructions may be stored in a computer readable memory that can instruct the computer or any other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory generate an article of manufacture that includes an instruction apparatus. The instruction apparatus implements a specific function in one or more procedures in the flowcharts and/or in one or more blocks in the block diagrams.

Claim 1:
A cross-chain transaction method, comprising:
receiving (<NUM>), by a node, an association transaction sent by a consensus node of a plurality of consensus nodes of a consensus service network, wherein:
the association transaction comprises transaction content of a plurality of transactions, identifiers of a plurality of blockchains on which the plurality of transactions occur, and an identifier of an anchor transaction,
the anchor transaction comprises data identifiers of the plurality of transactions, identifiers of a plurality of blockchains on which the plurality of transactions occur, and an identifier of an anchor transaction,
the node is any node on a first blockchain,
the first blockchain is any blockchain of the plurality of blockchains on which the plurality of transactions occur, and
the first blockchain and a second blockchain of the plurality of blockchains comprise:
a connection node for generating an anchor request and for generating the association transaction based on the plurality of transactions carrying an association identifier corresponding to the identifier of an anchor transaction,
a notary node for generating the anchor transaction corresponding to the anchor request,
wherein the connection node and the notary node are common to the first blockchain and the second blockchain; and
writing (<NUM>), by the node, a transaction that occurs in the first blockchain into the first blockchain based on the identifiers of the blockchains on which the plurality of transactions occur if determining, based on the identifier of the anchor transaction, that the anchor transaction is a valid transaction;
wherein before the node receives the association transaction sent by the consensus node, the method further comprises:
receiving (<NUM>), by the node, the anchor transaction sent by the consensus node, and writing the anchor transaction into the first blockchain.