WO2023040363A1 - 跨链交易有序执行方法和跨链系统 - Google Patents

跨链交易有序执行方法和跨链系统 Download PDF

Info

Publication number
WO2023040363A1
WO2023040363A1 PCT/CN2022/097229 CN2022097229W WO2023040363A1 WO 2023040363 A1 WO2023040363 A1 WO 2023040363A1 CN 2022097229 W CN2022097229 W CN 2022097229W WO 2023040363 A1 WO2023040363 A1 WO 2023040363A1
Authority
WO
WIPO (PCT)
Prior art keywords
chain
transaction
cross
sub
transactions
Prior art date
Application number
PCT/CN2022/097229
Other languages
English (en)
French (fr)
Inventor
李志平
谢家贵
郭健
张波
刘远超
朱斯语
Original Assignee
中国信息通信研究院
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 中国信息通信研究院 filed Critical 中国信息通信研究院
Publication of WO2023040363A1 publication Critical patent/WO2023040363A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/401Transaction verification

Definitions

  • the present disclosure relates to the field of blockchain technology, and in particular, to a method for orderly execution of cross-chain transactions and a cross-chain system.
  • Blockchain technology has its technical advantages mainly in the aspects of non-tamperable data information, traceable data information, distributed decentralization, and trustless systems.
  • Blockchain technology has already been used in finance, health It can be applied in many fields such as medical care, supply chain, asset management, and Internet e-commerce.
  • Embodiments of the present disclosure provide a method for orderly execution of cross-chain transactions, a cross-chain system, equipment and media.
  • a method for orderly execution of cross-chain transactions is provided, the method for orderly execution of cross-chain transactions is applied to a cross-chain system, and the cross-chain system includes a main chain and multiple sub-chains, so
  • the methods for orderly execution of cross-chain transactions include:
  • the main chain obtains multiple cross-chain transactions of the source chain, at least one of the multiple cross-chain transactions carries a target chain ID and a transaction number, and the transaction number is used to represent the cross-chain transaction to which the transaction number belongs.
  • the execution order of chain transactions in the source chain, the source chain is one of the multiple sub-chains, and the target chain corresponding to the target chain ID is one of the multiple sub-chains except the source chain outer child chain;
  • the main chain For at least one of the multiple sub-chains, the main chain generates a cross-chain transaction package of the at least one sub-chain according to the multiple cross-chain transactions, and distributes the cross-chain transaction package to the At least one sub-chain; the cross-chain transaction package includes at least one empty transaction and at least one cross-chain transaction among the multiple cross-chain transactions; the target chain ID carried by the cross-chain transaction in the cross-chain transaction package It is the same as the sub-chain ID of the sub-chain to which the cross-chain transaction package belongs; an empty transaction of the at least one empty transaction corresponds to a cross-chain transaction, and the target chain ID carried by the cross-chain transaction corresponding to the at least one empty transaction is the same as The sub-chain IDs of the sub-chains to which the cross-chain transaction package belongs are different, and the at least one empty transaction also carries the transaction ID corresponding to the cross-chain transaction; the at least one cross-chain transaction in the cross-chain transaction package and the At least one empty transaction sorted by transaction number;
  • the at least one sub-chain After the at least one sub-chain obtains the cross-chain transaction package, it executes the transactions in the cross-chain transaction package sequentially according to the order of transactions in the cross-chain transaction package; wherein, one of the at least one sub-chain After executing a cross-chain transaction, the sub-chain sends the transaction ID of the executed cross-chain transaction to the remaining sub-chains of the at least one sub-chain; one sub-chain in the at least one sub-chain executes an empty transaction , according to the transaction ID carried by the empty transaction, detect whether a sub-chain in the at least one sub-chain has received the same transaction ID sent by other sub-chains, if it has received the same transaction ID sent by the other sub-chains , execute the empty transaction;
  • each transaction is executed sequentially according to the order of transactions in the cross-chain transaction package, including: the ordering node of one of the at least one sub-chain receives The multiple intra-chain transactions submitted by other nodes of the at least one sub-chain, and receive the cross-chain transaction package; the ordering node of a sub-chain in the at least one sub-chain combines multiple intra-chain transactions with the cross-chain
  • the transaction in the chain transaction package is packaged into a sub-chain transaction package, and the sub-chain transaction package is distributed to at least one node in the at least one sub-chain; after the at least one node obtains the sub-chain transaction package, it will The multiple intra-chain transactions in the sub-chain transaction package are divided into a first transaction group, the transactions of the cross-chain transaction package in the sub-chain transaction package are divided into a second transaction group, and the first transaction group is processed in parallel and the second transaction group; when processing the second transaction group, the at least one node executes transactions sequentially according
  • a method for orderly execution of cross-chain transactions is provided, the method is applied to the target sub-chain in the cross-chain system, and the cross-chain system includes a main chain and multiple sub-chains, so The target sub-chain is a sub-chain in the plurality of sub-chains, and the method includes:
  • the cross-chain transaction package distributed by the main chain;
  • the cross-chain transaction package includes at least one cross-chain transaction and at least one empty transaction, and the target chain ID carried by the at least one cross-chain transaction is the same as that of the target sub-chain
  • the sub-chain IDs are the same; one of the at least one empty transaction corresponds to a cross-chain transaction, and the target chain ID carried by the cross-chain transaction corresponding to the at least one empty transaction is the same as the sub-chain ID of the target sub-chain Not the same, the at least one empty transaction also carries the transaction ID of the corresponding cross-chain transaction;
  • the at least one cross-chain transaction and the at least one empty transaction in the cross-chain transaction package are sorted according to the transaction number, and the transaction number It is used to characterize the execution order of the at least one cross-chain transaction in the source chain, and the source chain is a sub-chain in the plurality of sub-chains;
  • the transactions in the cross-chain transaction package are executed sequentially; wherein, after a cross-chain transaction is executed, the transaction ID of the executed cross-chain transaction is sent to the multiple other sub-chains except the target sub-chain; before executing the empty transaction, check whether the same transaction ID sent by the other sub-chains has been received according to the transaction ID carried by the empty transaction, if so, then Execute said empty transaction;
  • the ordering node of the target sub-chain receives multiple intra-chain transactions submitted by the remaining nodes, and receives the cross-chain transaction package distributed by the main chain; the ordering node combines the multiple intra-chain transactions and all The transaction in the cross-chain transaction package is packaged into a sub-chain transaction package, and the sub-chain transaction package is distributed to at least one node of the target sub-chain; at least one node of the target sub-chain obtains the sub-chain transaction After packaging, divide the plurality of intra-chain transactions in the sub-chain transaction package into a first transaction group, and divide the transactions of the cross-chain transaction package in the sub-chain transaction package into a second transaction group, and Processing the first transaction group and the second transaction group in parallel; when processing the second transaction group, the at least one node executes transactions sequentially according to the order of transactions in the second transaction group.
  • a cross-chain system includes a main chain and multiple sub-chains, and the cross-chain operation between the main chain and the multiple sub-chains adopts any one of the present disclosure.
  • an electronic device including:
  • One or more processors communicate with the memory to execute executable instructions so as to complete the operations of each step in the method described in any embodiment of the present disclosure.
  • a computer-readable medium for storing computer-readable instructions, and when the instructions are executed, the operation of each step in the method described in any embodiment of the present disclosure is implemented.
  • multiple transactions in the cross-chain transaction package are sorted according to transaction numbers, and multiple transactions in the cross-chain transaction package are kept in the source chain. order of execution.
  • the transaction ID of the cross-chain transaction will be sent to other sub-chains after the cross-chain transaction is processed. chain.
  • the sub-chain executes the empty transaction, and then executes the next transaction after executing the empty transaction.
  • multiple cross-chain transactions of the source chain will be executed sequentially by several sub-chains according to the order in which these cross-chain transactions are executed in the source sub-chain, which helps to realize the orderly execution of cross-chain transactions.
  • FIG. 1 is a flow chart of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure
  • Fig. 2 is a schematic diagram of a cross-chain system proposed by an embodiment of the present disclosure
  • Fig. 3 is a schematic flow diagram of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure
  • Fig. 4 is a schematic diagram of backbone nodes sorting cross-chain transactions proposed by an embodiment of the present disclosure
  • Fig. 5 is a schematic diagram of a cross-chain transaction package generated by a verification node proposed by an embodiment of the present disclosure
  • Fig. 6 is a schematic diagram of verification node A generating a cross-chain transaction package proposed by an embodiment of the present disclosure
  • Fig. 7 is a schematic diagram of a verification node C generating a cross-chain transaction package proposed by an embodiment of the present disclosure
  • Fig. 8 is a schematic flowchart of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure.
  • plural may refer to two or more than two, and “at least one” may refer to one, two or more than two.
  • Embodiments of the present disclosure may be applied to electronic devices such as terminal devices, computer systems, servers, etc., which may operate with numerous other general purpose or special purpose computing system environments or configurations.
  • Examples of well known terminal devices, computing systems, environments and/or configurations suitable for use with electronic devices such as terminal devices, computer systems, servers include, but are not limited to: personal computer systems, server computer systems, thin clients, thick client Computers, handheld or laptop devices, microprocessor-based systems, set-top boxes, programmable consumer electronics, networked personal computers, minicomputer systems, mainframe computer systems, and distributed cloud computing technology environments including any of the foregoing, etc.
  • Electronic devices such as terminal devices, computer systems, servers, etc. may be described in the general context of computer system-executable instructions, such as program modules, being executed by the computer system.
  • program modules may include routines, programs, objects, components, logic, data structures, etc., that perform particular tasks or implement particular abstract data types.
  • the computer system/server can be practiced in distributed cloud computing environments where tasks are performed by remote processing devices that are linked through a communications network.
  • program modules may be located in both local and remote computing system storage media including storage devices.
  • a user registered in sub-chain A has initiated cross-chain transaction tx1 and cross-chain transaction tx2 within a period of time.
  • the user hopes to first purchase m amount of bond assets in sub-chain B through cross-chain transaction tx1, and then use the remaining account assets to purchase n amount of fund assets in sub-chain C through cross-chain transaction tx2.
  • the embodiments of the present disclosure provide an orderly execution method for cross-chain transactions, a cross-chain system, equipment and media. Multiple transactions in the cross-chain transaction package are sorted according to the transaction numbers, and the transactions in the cross-chain transaction package Multiple transactions maintain the order of execution in the source chain. Moreover, during the sequential execution of the transactions in the cross-chain transaction package by the sub-chain, if the currently processed transaction is a cross-chain transaction, after the cross-chain transaction is processed, the transaction ID of the processed cross-chain transaction will be sent to other sub-chains. If the currently processed transaction is an empty transaction, then according to the transaction ID carried by the empty transaction, check whether the sub-chain has received the same transaction ID sent by other sub-chains.
  • the solutions in the embodiments of the present disclosure can be implemented by using various computer languages, for example, the object-oriented programming language Java and the literal translation scripting language JavaScript.
  • FIG. 1 is a flowchart of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure.
  • the method of orderly execution of cross-chain transactions is applied to a cross-chain system, which includes a main chain and multiple sub-chains.
  • the orderly execution method of cross-chain transactions includes the following steps:
  • S110 The main chain obtains multiple cross-chain transactions of the source chain.
  • each cross-chain transaction carries the target chain ID and transaction number.
  • the transaction number of each cross-chain transaction is used to represent the execution sequence of the cross-chain transaction in the source chain.
  • the source chain is a sub-chain among multiple sub-chains
  • the target chain is a sub-chain other than the source chain among multiple sub-chains.
  • each cross-chain transaction carries a transaction ID in addition to the target chain ID and transaction number.
  • the transaction number can reflect the execution order of cross-chain transactions in the source chain.
  • the transaction numbers of multiple cross-chain transactions are gradually increasing numbers. The larger the number of a cross-chain transaction, the later the execution order of the cross-chain transaction in the source chain.
  • a cross-chain transaction carries the following information "tx_id: 077ae2439; nonce: 175; Account: b1; Source_chain_id: chain-b; Destination_chain_id: chain-a", indicating the transaction ID of the cross-chain transaction It is 077ae2439, the transaction number of the cross-chain transaction is 175, the cross-chain transaction is initiated by account b1, the source chain ID of the cross-chain transaction is chain-b, and the target chain ID of the cross-chain transaction is chain-a.
  • cross-chain transaction carries the following information "tx_id: 8d69cbc53; nonce: 176; Account: b1; Source_chain_id: chain-b; Destination_chain_id: chain-c", indicating that the transaction ID of the cross-chain transaction is 8d69cbc53, the cross-chain The transaction number of the transaction is 176, the cross-chain transaction is initiated by account b1, the source chain ID of the cross-chain transaction is chain-b, and the target chain ID of the cross-chain transaction is chain-c.
  • the cross-chain system also includes multiple backbone nodes, each of which corresponds to a sub-chain, and one of the multiple backbone nodes is used to connect the main chain and the sub-chain corresponding to the backbone node .
  • the process for the main chain to obtain multiple cross-chain transactions of the source chain specifically includes: the backbone node of the source chain obtains multiple cross-chain transactions of the source chain; the backbone node transfers at least one of the multiple cross-chain transactions The transaction structure of the transaction is adjusted to match the transaction structure of the main chain, and at least one adjusted cross-chain transaction is assigned a transaction number, and then multiple cross-chain transactions assigned the transaction number are submitted to the main chain. In this way, the main chain obtains multiple cross-chain transactions submitted by the backbone node.
  • step S110 may be performed by the main chain in the cross-chain system.
  • the main chain For at least one of the multiple sub-chains, the main chain generates a cross-chain transaction package of at least one sub-chain according to multiple cross-chain transactions, and distributes the cross-chain transaction package to at least one sub-chain.
  • the cross-chain transaction package of at least one sub-chain includes at least one cross-chain transaction and at least one empty transaction.
  • the target chain ID carried in the cross-chain transaction package of at least one sub-chain is the same as the sub-chain ID of the sub-chain.
  • At least one empty transaction in the cross-chain transaction package of at least one sub-chain corresponds to a cross-chain transaction respectively, and the target chain ID carried by the cross-chain transaction corresponding to at least one empty transaction is the same as the sub-chain ID of the sub-chain Not the same, at least one empty transaction also carries the transaction ID corresponding to the cross-chain transaction.
  • At least one cross-chain transaction and at least one empty transaction in the cross-chain transaction package of each sub-chain are sorted according to the transaction number.
  • the ordering of at least one transaction in the cross-chain transaction package of at least one sub-chain is the same as if at least one Cross-chain transactions are executed in the same order in the source chain.
  • the process of the main chain distributing the cross-chain transaction package of at least one sub-chain to at least one sub-chain specifically includes: the main chain distributes the cross-chain transaction package of at least one sub-chain to at least one sub-chain Backbone node; the backbone node of one subchain in at least one subchain adjusts the transaction structure of each transaction in the cross-chain transaction package to match the transaction structure of the subchain, and submits the adjusted cross-chain transaction package to the child chain.
  • the cross-chain system of the present disclosure includes multiple sub-chains
  • the multiple sub-chains can be various heterogeneous chains, and the transaction structures supported by each of the multiple sub-chains are different from each other. Therefore, in order to achieve smooth cross-chain between multiple sub-chains, before the cross-chain transaction of at least one sub-chain in this disclosure is sent to the main chain, the backbone nodes of at least one sub-chain will exchange the cross-chain transaction of the corresponding sub-chain The structure is adjusted, and then the adjusted cross-chain transaction is sent to the main chain, so that the main chain can smoothly execute the cross-chain transaction. Similarly, the backbone nodes of each sub-chain can also adjust the transaction structure of the cross-chain transaction sent by the main chain, and then send the adjusted cross-chain transaction to the corresponding sub-chain, so that the sub-chain can smoothly execute the cross-chain transaction.
  • step S120 may be performed by the main chain in the cross-chain system.
  • one of the multiple sub-chains executes a cross-chain transaction, it sends the transaction ID of the executed cross-chain transaction to the sub-chains of the above-mentioned multiple sub-chains except those who have currently executed the cross-chain transaction. The remaining sub-chains outside the chain.
  • one of the above sub-chains checks whether the sub-chain has received the same transaction ID sent by other sub-chains according to the transaction ID carried by the empty transaction. If the transaction ID is the same, the empty transaction will be executed.
  • the sub-chain preparing to execute the empty transaction will suspend the execution of the empty transaction until The same transaction ID sent by the other sub-chains except the sub-chain preparing to execute the empty transaction is received.
  • step S130 may be executed by the processor calling corresponding instructions stored in the memory, or may be executed by a cross-chain transaction packet processing module run by the processor.
  • a sub-chain executes a cross-chain transaction, it sends the transaction ID of the cross-chain transaction to other sub-chains in the following way:
  • step S130-1 can be performed by sub-chains in the cross-chain system.
  • the main link After receiving the transaction ID, the main link forwards the transaction ID to at least one of the multiple sub-chains, for example, the transaction ID can be forwarded to each of the multiple sub-chains.
  • step S130-2 can be performed by the main chain in the cross-chain system.
  • the transaction ID is forwarded to at least one sub-chain in the cross-chain system through the main chain, for example, the transaction ID is forwarded to all sub-chains in the cross-chain system through the main chain, so the at least one sub-chain does not need to save and update the sub-chain at any time
  • the routing relationship between them is conducive to simplifying the design of sub-chains and reducing the amount of computing tasks for sub-chains.
  • the main chain includes multiple main chain nodes, and at least one main chain node corresponds to a sub-chain, for example, each main chain node corresponds to a sub-chain.
  • the sub-chain executes a cross-chain transaction
  • the sub-chain sends the transaction ID of the cross-chain transaction to the backbone node of the sub-chain.
  • the backbone node submits the transaction ID to the main chain node corresponding to the sub-chain.
  • the main chain node After the main chain node receives the transaction ID, the main chain node will synchronize the transaction ID to other main chain nodes of the main chain through the P2P network of the main chain.
  • each main chain node in the other main chain nodes After receiving the transaction ID, each main chain node in the other main chain nodes sends the transaction ID to the backbone node of the sub-chain corresponding to each main chain node. After each backbone node receives the transaction ID sent by the main chain node, it sends the transaction ID to the corresponding sub-chain. After the sub-chain receives the transaction ID, it synchronizes within the sub-chain through the P2P network of the sub-chain, so that each sub-chain node receives the transaction ID.
  • At least one sub-chain in the cross-chain system can save and update the routing relationship between the sub-chains at any time, for example, each sub-chain in the cross-chain system can save and update the routing relationship between the sub-chains at any time Routing relationship.
  • the sub-chain can directly send the transaction ID of the cross-chain transaction to other sub-chains according to the routing relationship between the sub-chains.
  • At least one sub-chain in the cross-chain system can perform cross-chain transactions, for example, each sub-chain in the cross-chain system can perform multiple intra-chain transactions in addition to cross-chain transactions, In order to improve the overall execution efficiency of sub-chain transactions in the cross-chain system.
  • sub-chains in the cross-chain system can package intra-chain transactions and cross-chain transactions into the same transaction package (hereinafter referred to as sub-chain transaction package) for processing.
  • sub-chain transaction package for processing.
  • the specific implementation includes the following processes:
  • the ordering node of at least one sub-chain receives multiple intra-chain transactions submitted by other nodes of the sub-chain, for example, the ordering node of each sub-chain in the cross-chain system receives multiple intra-chain transactions submitted by other nodes of the sub-chain, and Receive the cross-chain transaction package distributed by the main chain; the ordering node of the at least one sub-chain packages each transaction in multiple intra-chain transactions and cross-chain transaction packages into a sub-chain transaction package, and distributes the sub-chain transaction package to the sub-chain At least one node in the sub-chain; after obtaining the sub-chain transaction package, the at least one node divides multiple intra-chain transactions in the sub-chain transaction package into the first transaction group, and divides each transaction in the sub-chain transaction package into the cross-chain transaction package Divide into a second transaction group, and process the first transaction group and the second transaction group in parallel.
  • each sub-chain node in the cross-chain system executes the transactions in the second transaction group sequentially according to the order of transactions in the second transaction group. Specifically, as mentioned above, after a cross-chain transaction is executed, the transaction ID of the executed cross-chain transaction is sent to the remaining sub-chains. Before executing the empty transaction, according to the transaction ID carried by the empty transaction, it is detected whether the same transaction ID sent by other sub-chains has been received, and if the same transaction ID sent by other sub-chains has been received, the empty transaction is executed. In addition, if the same transaction ID sent by other sub-chains has not been received, the execution of the empty transaction will be suspended until the same transaction ID sent by other sub-chains is received.
  • the execution of intra-chain transactions in a sub-chain transaction package into the first transaction group by dividing the intra-chain transactions in a sub-chain transaction package into the first transaction group, the cross-chain transactions and empty transactions in the sub-chain transaction package are divided into the second transaction group, and there are The child chain processes these two transaction groups in parallel. Therefore, the execution of intra-chain transactions will not be affected by empty transactions. For example, during the execution of empty transactions, sub-chain nodes have not received the same transaction ID sent by other sub-chains in the cross-chain system except the sub-chain that is executing empty transactions. During the waiting period, although the execution of subsequent cross-chain transactions will be affected by empty transactions, the intra-chain transactions in the first transaction group will not be affected and can still be executed, thus further improving the overall execution efficiency of sub-chains for transactions . In the present disclosure, after the execution of the first transaction group and the second transaction group is completed, the sub-chains that execute the first transaction group and the second transaction group generate blocks and perform consensus on the blocks.
  • the multiple transactions in the cross-chain transaction package are sorted according to the transaction numbers, and the multiple transactions in the cross-chain transaction package maintain the execution order in the source chain.
  • the cross-chain transaction if the currently processed transaction is a cross-chain transaction, after the cross-chain transaction is processed, the cross-chain transaction The transaction ID is sent to other sub-chains. If the currently processed transaction is an empty transaction, then according to the transaction ID carried by the empty transaction, it is detected whether the sub-chain has received the same transaction ID sent by other sub-chains in the cross-chain system except this sub-chain.
  • the sub-chain If the sub-chain has received the same transaction ID sent by the other sub-chains, it means that the other sub-chains have processed the cross-chain transaction corresponding to the empty transaction, and then the sub-chain executes the empty transaction, and after executing the After the empty transaction, the next transaction is executed. If the sub-chain has not received the same transaction ID sent by the remaining sub-chain, it means that the remaining sub-chain has not processed the cross-chain transaction corresponding to the empty transaction, so the sub-chain waits until it receives the transaction ID sent by the remaining sub-chain The same transaction ID, the empty transaction is executed, and then the next transaction is executed. In this way, for multiple cross-chain transactions of the source chain, the execution order of these cross-chain transactions in the source sub-chain will be executed sequentially by the sub-chains, thus realizing the orderly execution of cross-chain transactions.
  • FIG. 2 is a schematic diagram of a cross-chain system proposed by an embodiment of the present disclosure.
  • the cross-chain system includes a main chain, multiple sub-chains, and multiple backbone nodes.
  • At least one backbone node corresponds to a sub-chain.
  • each backbone node corresponds to a sub-chain.
  • Each backbone node is used to connect The main chain and the sub-chain corresponding to the backbone node.
  • the backbone node acts as a cross-chain gateway.
  • the backbone node has a built-in cross-chain account (that is, an account registered in the main chain) and is responsible for message communication between the sub-chain and the main chain.
  • the main chain can be oriented to sub-chains in multiple fields, and is used to realize the data circulation of sub-chains in multiple fields.
  • the cross-chain process based on this cross-chain system mainly includes:
  • the backbone node obtains the cross-chain transaction TX of the sub-chain, and verifies the cross-chain transaction TX of the sub-chain, and adjusts the cross-chain transaction TX to the transaction structure supported by the main chain, and sends it to the main chain.
  • step S210 may be performed across backbone nodes in the chain system.
  • S220 After forwarding, executing and verifying the cross-chain transaction TX between the verification nodes of the main chain, submit the cross-chain transaction TX to the consensus node of the main chain.
  • step S220 can be performed across the main chain in the chain system.
  • S230 The consensus node of the main chain packages, agrees on and uploads the cross-chain transaction TX to generate a block block, in which multiple cross-chain transaction TXs are recorded.
  • step S230 can be performed across the main chain in the chain system.
  • the verification node of the main chain obtains the block block generated by the consensus node, reads the cross-chain transaction TX from the block block, and for each cross-chain transaction TX, according to the target chain ID carried by the cross-chain transaction TX, Notify the backbone node corresponding to the target chain.
  • step S240 can be performed across the main chain in the chain system.
  • the backbone node adjusts the cross-chain transaction TX to the transaction structure supported by the corresponding sub-chain, and routes the adjusted cross-chain transaction TX to the corresponding sub-chain.
  • step S250 may be performed across backbone nodes in the chain system.
  • S260 After the sub-chain obtains the cross-chain transaction TX, verify the signature of the cross-chain transaction TX, and execute the cross-chain transaction TX after the signature verification is passed.
  • step S260 may be performed across sub-chains in the chain system.
  • Figure 2 shows the cross-chain operation process proposed in this disclosure.
  • the cross-chain system can perform the cross-chain operation steps shown in Figure 1 during the cross-chain operation.
  • this disclosure introduces the method for orderly execution of cross-chain transactions and the cross-chain system through some embodiments.
  • the present disclosure further introduces the orderly execution method of cross-chain transactions through other embodiments.
  • FIG. 3 is a schematic flowchart of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure. As shown in Figure 3, the method includes the following steps:
  • the backbone node monitors the block generation event of the sub-chain. When the sub-chain generates a new block, the backbone node obtains the block from the sub-chain, and identifies each transaction in the block according to the type of transaction. Determine whether the transaction is a cross-chain transaction. If the transaction is a cross-chain transaction, the backbone node will put the transaction into the cross-chain transaction queue according to the preset sorting rules.
  • the backbone node will arrange these cross-chain transactions into the cross-chain transaction queue according to the execution order of multiple cross-chain transactions in the sub-chain.
  • the backbone node has obtained two blocks of the sub-chain within a period of time. These two blocks are: the block whose block height is equal to A block with a block height equal to 102. Each block includes several cross-chain transactions.
  • the block height of sub-chain b equals 101 includes cross-chain transactions such as tx3 and tx12
  • the block height of sub-chain b equals 102 includes tx9 and tx12.
  • Cross-chain transactions such as tx28.
  • step S310 may be performed across backbone nodes in the chain system.
  • S320 The backbone node adjusts the transaction structure of each cross-chain transaction, so that the adjusted transaction structure is a transaction structure that the main chain can handle.
  • the backbone node is registered with a cross-chain account (that is, the account of the backbone node in the main chain), and the cross-chain account of the backbone node is used to assign a nonce value to the cross-chain account (the nonce value in this disclosure is the transaction number).
  • the backbone nodes first adjust the transaction structure of each cross-chain transaction to the transaction structure that the main chain can handle according to the preset adjustment method. Then, for each cross-chain transaction in the cross-chain transaction queue, the backbone node assigns the nonce value to the cross-chain transaction in turn. Every time a backbone node assigns a nonce value, the nonce value automatically increases by 1.
  • the backbone node assigns the transaction sequence number value 175 to tx3.
  • the nonce value is automatically increased by 1 and updated to 176, and the backbone node assigns the nonce value 176 to tx12.
  • the nonce value of the backbone node is automatically increased by 1 and updated to 177, and the backbone node assigns the transaction sequence number value 2757 to tx9.
  • the nonce value of the backbone node is automatically increased by 1 and updated to 178, and the backbone node assigns the transaction sequence number value 178 to tx28.
  • the backbone nodes assign different nonce values to multiple cross-chain transactions in turn, and the nonce values of multiple cross-chain transactions increase sequentially.
  • step S320 may be performed across backbone nodes in the chain system.
  • the backbone node sends multiple cross-chain transactions to the verification nodes corresponding to the multiple cross-chain transactions in the main chain; the verification node verifies the cross-chain transactions, and after passing the verification, sends multiple cross-chain transactions to the main chain
  • the consensus node executes; the consensus node generates a block after executing the cross-chain transaction, and synchronizes the block to the verification node.
  • the main chain includes multiple verification nodes and multiple consensus nodes, each verification node corresponds to a sub-chain and a backbone node, and multiple verification nodes are connected to multiple consensus nodes.
  • the backbone node sends multiple cross-chain transactions to the verification node corresponding to the backbone node.
  • step S330 may be performed across backbone nodes in the chain system.
  • each verification node After each verification node obtains the block generated by the main chain, it groups multiple cross-chain transactions according to the backbone node account information carried by each cross-chain transaction in the block, and the cross-chain transactions in each group follow the The nonce values are sorted. [0076] For ease of understanding, as shown in Figure 5, the new block generated by the main chain includes 6 cross-chain transactions such as tx1 to tx6. Among them, each cross-chain transaction records: backbone node account information, nonce value, personal account information, and target chain ID and other information.
  • backbone B account means that tx1 carries the account information of backbone node B, in other words, tx1 is a cross-chain transaction sent by backbone node B to the main chain.
  • Period account b1 means that tx1 was first initiated by personal account b1 on the sub-chain of backbone node B.
  • Target chain a means that tx1 needs to be sent to the subchain a connected by backbone node A.
  • step S340 can be performed across the main chain in the chain system.
  • verification node A As shown in Figure 3, taking verification node A as an example, after verification node A obtains the new block generated by the main chain, verification node A divides the six cross-chain transactions in the new block into two groups according to the account information of the backbone node. One group is the cross-chain transaction of the bone B account, and the other group is the cross-chain transaction of the bone D account. In each group of cross-chain transactions, multiple cross-chain transactions are sorted according to the nonce value from small to large.
  • the verification node processes each group of cross-chain transactions separately. During the processing of a group of cross-chain transactions, the verification node, for each cross-chain transaction, if the target chain ID carried by the cross-chain transaction is connected to the corresponding backbone node If the target chain ID carried by the cross-chain transaction is not the sub-chain ID connected to the corresponding backbone node, then the cross-chain transaction will be replaced with an empty transaction, and the cross-chain transaction will be retained by the empty transaction. The transaction ID of the transaction. In this way, a group of cross-chain transactions is converted into several cross-chain transactions and several empty transactions, and the original order of these transactions is still maintained, and these transactions form a cross-chain transaction package.
  • TX12 since the target chain ID carried by TX12 is c, and the target chain c is not the sub-chain connected to the backbone node A corresponding to verification node A, TX12 is replaced with an empty transaction, which retains the transaction ID of TX12.
  • TX9 since the target chain ID carried by TX9 is c, and the target chain c is not the sub-chain connected to the backbone node A corresponding to verification node A, TX9 is replaced with an empty transaction, which retains the transaction ID of TX9.
  • TX28 since the target chain ID carried by TX28 is a, and the target chain a is just the sub-chain connected to the backbone node A corresponding to verification node A, the cross-chain transaction TX28 is reserved.
  • verification node A generated a cross-chain transaction package as shown in Figure 6, and verification node C generated a transaction package as shown in Figure 7.
  • verification node C and verification node E also generated a transaction package for a group of cross-chain transactions of the bone D account. To simplify the description, details are not repeated here.
  • step S350 can be performed across the main chain in the chain system.
  • the verification node sends the cross-chain transaction package to the corresponding backbone node; the backbone node transforms each transaction in the cross-chain transaction package into a transaction structure that the sub-chain can handle, and then sends the cross-chain transaction package to the sub-chain connected to the backbone node. chain.
  • the sub-chain includes the following steps when processing transactions:
  • the master node master of the sub-chain sorts and packages each transaction in the cross-chain transaction package together with the intra-chain transactions of the sub-chain to generate a sub-chain transaction package;
  • the sub-chain transaction package includes multiple Intra-chain transactions and multiple cross-chain transactions, multiple cross-chain transactions retain the original order;
  • the master node master distributes the sub-chain transaction package to each node of the sub-chain.
  • step S371 may be performed across sub-chains in the chain system.
  • each node of the sub-chain divides multiple intra-chain transactions in the sub-chain transaction package into the first transaction group, and divides several cross-chain transactions and several empty transactions in the sub-chain transaction package Divided into the second transaction group, several cross-chain transactions and several empty transactions in the second transaction group maintain the original order.
  • step S372 may be performed across sub-chains in the chain system.
  • each node uses the first process to sequentially process each transaction in the first transaction group, and uses the second process to sequentially process each transaction in the second transaction group.
  • step S373 may be performed across sub-chains in the chain system.
  • the second process directly executes the cross-chain transaction, and after processing the cross-chain transaction, Send the transaction ID of the cross-chain transaction to the master node master.
  • the master node master receives the transaction ID sent by most nodes (for example, 60% nodes)
  • the master node master sends the transaction ID to the backbone node, so that the transaction ID is routed to other sub-chains through the backbone node and the main chain. cache.
  • the second process tries to read the transaction ID of the empty transaction from the cache. If the second process reads the transaction ID, it means that other sub-chains have already processed the cross-chain transaction corresponding to the empty transaction. In this case, the second process executes the empty transaction (for example, directly updates the execution status of the empty transaction to be executed), and then processes the next transaction after executing the empty transaction. If the second process does not read the transaction ID, it means that other sub-chains have not finished processing the cross-chain transaction corresponding to the empty transaction. In this case, the second process waits until the corresponding transaction ID is stored in the cache. In this way, for multiple cross-chain transactions from the same sub-chain, even if these cross-chain transactions are executed on different sub-chains, they will be executed sequentially according to the order of transaction numbers.
  • sub-chain a executes the cross-chain transaction TX3
  • sub-chain a sends the transaction ID of the cross-chain transaction TX3 to other sub-chains.
  • the empty transaction TX3 will not be executed until the sub-chain c receives the transaction ID of the cross-chain transaction TX3.
  • the sub-chain c will execute the cross-chain transaction TX12 after executing the empty transaction TX3.
  • the sub-chain c sends the transaction ID of the cross-chain transaction TX12 to other sub-chains. Sub-chain c then executes the cross-chain transaction TX9.
  • sub-chain c After sub-chain c executes the cross-chain transaction TX9, sub-chain c sends the transaction ID of the cross-chain transaction TX9 to other sub-chains.
  • the empty transaction TX12 will not be executed until sub-chain a receives the transaction ID of the cross-chain transaction TX12.
  • Sub-chain a executes the empty transaction TX12 and receives the transaction ID of the cross-chain transaction TX9 before executing the empty transaction TX9.
  • the cross-chain transaction TX28 will not be executed until the sub-chain a executes the empty transaction TX9.
  • sub-chain a After sub-chain a executes the cross-chain transaction TX28, sub-chain a sends the transaction ID of the cross-chain transaction TX28 to other sub-chains.
  • the empty transaction TX28 will not be executed until the sub-chain c receives the transaction ID of the cross-chain transaction TX28.
  • the cross-chain transaction TX3, cross-chain transaction TX12, cross-chain transaction TX9 and cross-chain transaction TX28 are executed sequentially in sub-chain a and sub-chain c.
  • the cross-chain transaction TX12 will be executed by sub-chain c.
  • the cross-chain transaction TX9 will be executed by sub-chain c.
  • the cross-chain transaction TX28 will be executed by sub-chain a.
  • step S374 may be performed across sub-chains in the chain system.
  • the present disclosure proposes a method for orderly execution of cross-chain transactions through some embodiments, and the method for orderly execution of cross-chain transactions is applied to the entire cross-chain system.
  • the present disclosure provides a method for orderly execution of cross-chain transactions applied to sub-chains through other embodiments.
  • the following specific implementation methods of the orderly execution method of cross-chain transactions applied to sub-chains can refer to the above-mentioned embodiments. In order to avoid repetition, the following is a brief introduction to the orderly execution method of cross-chain transactions applied to sub-chains.
  • FIG. 8 is a schematic flowchart of a method for orderly execution of cross-chain transactions proposed by an embodiment of the present disclosure.
  • the method for orderly execution of cross-chain transactions is applied to sub-chains in the cross-chain system. As shown in Figure 8, the method includes the following steps:
  • the cross-chain transaction package includes at least one cross-chain transaction and at least one empty transaction, and the target chain ID carried by at least one cross-chain transaction is the same as the sub-chain ID of the target sub-chain.
  • One of the at least one empty transaction corresponds to a cross-chain transaction
  • the target chain ID carried by the cross-chain transaction corresponding to the at least one empty transaction is different from the sub-chain ID of the target sub-chain
  • the at least one empty transaction also carries The transaction ID corresponding to the cross-chain transaction.
  • the at least one cross-chain transaction and the at least one empty transaction in the cross-chain transaction package of each sub-chain are sorted according to the transaction number.
  • the transaction number is used to represent the execution order of each cross-chain transaction in the source chain.
  • a sub-chain in the chain is used to represent the execution order of each cross-chain transaction in the source chain.
  • step S810 may be performed across sub-chains in the chain system.
  • S820 Execute the transactions in the cross-chain transaction package sequentially according to the order of transactions in the cross-chain transaction package; wherein, after executing a cross-chain transaction, send the transaction ID of the executed cross-chain transaction to the remaining sub-chains; Before executing the empty transaction, according to the transaction ID carried by the empty transaction, it is checked whether the same transaction ID sent by other sub-chains has been received, and if the same transaction ID sent by other sub-chains has been received, the empty transaction will be executed.
  • step S820 may be performed across sub-chains in the chain system.
  • the execution of the empty transaction is suspended until the same transaction ID sent by other sub-chains is received.
  • the target sub-chain obtains the cross-chain transaction package distributed by the main chain, and according to the order of transactions in the cross-chain transaction package, the specific process of sequentially executing the transactions in the cross-chain transaction package includes:
  • the ordering node of the target sub-chain receives multiple intra-chain transactions submitted by other nodes of the target sub-chain, and receives the cross-chain transaction package distributed by the main chain; the ordering node of the target sub-chain combines multiple intra-chain transactions and cross-chain transaction packages Each transaction of the sub-chain is packaged into a sub-chain transaction package, and the sub-chain transaction package is distributed to at least one node of the target sub-chain; after the at least one node of the target sub-chain obtains the sub-chain transaction package, multiple The intra-chain transactions are divided into the first transaction group, each transaction in the cross-chain transaction package in the sub-chain transaction package is divided into the second transaction group, and the first transaction group and the second transaction group are processed in parallel; the at least one node is processing the second transaction group In the second transaction group, the transactions are executed sequentially according to the order of the transactions in the second transaction group.
  • the specific process of sending the transaction ID of the executed cross-chain transaction to other sub-chains includes: after executing a cross-chain transaction, sending The transaction ID of the completed cross-chain transaction is sent to the main chain, so that the main chain forwards the transaction ID to at least one of the multiple sub-chains.
  • the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Accordingly, the present disclosure can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present disclosure may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
  • computer-usable storage media including but not limited to disk storage, CD-ROM, optical storage, etc.
  • These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing apparatus to operate in a specific manner, such that the instructions stored in the computer-readable memory produce an article of manufacture comprising instruction means, the instructions
  • the device realizes the function specified in one or more procedures of the flowchart and/or one or more blocks of the block diagram.

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)

Abstract

一种跨链交易有序执行方法和跨链系统,其中,跨链交易有序执行方法包括:主链获得源链的多个跨链交易;所述主链针对所述多个子链中的至少一个子链,根据所述多个跨链交易生成所述至少一个子链的跨链交易包,并将所述跨链交易包分发给所述至少一个子链;所述至少一个子链获得所述跨链交易包后,按照所述跨链交易包中交易的排序,依次执行所述跨链交易包中的交易。该方法有助于实现跨链交易的有序执行。

Description

跨链交易有序执行方法和跨链系统
本公开要求在2021年09月16日提交中国专利局、申请号为CN 202111084581.8、发明名称为“一种跨链交易有序执行方法和跨链系统”的中国专利申请的优先权,其全部内容通过引用结合在本公开中。
技术领域
本公开涉及区块链技术领域,具体地,涉及跨链交易有序执行方法和跨链系统。
背景技术
区块链技术作为一种分布式账本技术,其技术优势主要体现于数据信息不可篡改、数据信息可溯源、分布式去中心化、无须信任系统等方面,区块链技术目前已经在金融、健康医疗、供应链、资产管理、互联网电商等诸多领域得以应用。
发明内容
本公开实施例中提供跨链交易有序执行方法、跨链系统、设备和介质。
根据本公开实施例的一个方面,提供的一种跨链交易有序执行方法,所述跨链交易有序执行方法应用于跨链系统,所述跨链系统包括主链和多个子链,所述跨链交易有序执行方法包括:
所述主链获得源链的多个跨链交易,所述多个跨链交易中的至少一个跨链交易携带目标链ID和交易编号,所述交易编号用于表征所述交易编号所属的跨链交易在所述源链中的执行顺序,所述源链是所述多个子链中的一个子链,所述目标链ID对应的目标链是所述多个子链中除所述源链之外的子链;
所述主链针对所述多个子链中的至少一个子链,根据所述多个跨链交易生成所述至少一个子链的跨链交易包,并将所述跨链交易包分发给所述至少一个子链;所述跨链交易包中包括至少一个空交易和所述多个跨链交易中的至少一个跨链交易;所述跨链交易包中的跨链交易所携带的目标链ID与所述跨链交易包所属子链的子链ID相同;所述至少一个空交易的一个空交易对应一个跨链交易,所述至少一个空交易对应的跨链交易所携带的目标链ID与所述跨链交易包所属子链的子链ID不相同,所述至少一个空交易还携带对应跨链交易的交易ID;所述跨链交易包中的所述至少一个跨链交易和所述至少一个空交易按照交易编号 进行排序;
所述至少一个子链获得所述跨链交易包后,按照所述跨链交易包中交易的排序,依次执行所述跨链交易包中的交易;其中,所述至少一个子链中的一个子链在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给所述至少一个子链的其余子链;所述至少一个子链中的一个子链在执行空交易之前,根据所述空交易携带的交易ID,检测所述至少一个子链中的一个子链是否已经接收到其他子链发送的相同交易ID,若已经接收到所述其他子链发送的相同交易ID,则执行该所述空交易;
所述至少一个子链获得所述跨链交易包后,按照所述跨链交易包中交易的排序,依次执行每个交易,包括:所述至少一个子链中的一个子链的排序节点接收所述至少一个子链的其他节点提交的多个链内交易,并接收所述跨链交易包;所述至少一个子链中的一个子链的排序节点将多个链内交易和所述跨链交易包中的交易打包成子链交易包,并将所述子链交易包分发给所述至少一个子链内的至少一个节点;所述至少一个节点在获得所述子链交易包后,将所述子链交易包中的多个链内交易划分为第一交易组,将所述子链交易包中跨链交易包的交易划分为第二交易组,并且并行处理所述第一交易组和所述第二交易组;所述至少一个节点在处理所述第二交易组时,按照所述第二交易组中交易的排序,依次执行交易。
根据本公开实施例的另一个方面,提供的一种跨链交易有序执行方法,所述方法应用于跨链系统中的目标子链,所述跨链系统包括主链和多个子链,所述目标子链是所述多个子链中的一个子链,所述方法包括:
获得所述主链分发的跨链交易包;所述跨链交易包中包括至少一个跨链交易和至少一个空交易,所述至少一个跨链交易携带的目标链ID与所述目标子链的子链ID相同;所述至少一个空交易中的一个空交易分别对应一个跨链交易,所述至少一个空交易对应的跨链交易所携带的目标链ID与所述目标子链的子链ID不相同,所述至少一个空交易还携带对应跨链交易的交易ID;所述跨链交易包中所述至少一个跨链交易和所述至少一个空交易按照交易编号进行排序,所述交易编号用于表征所述至少一个跨链交易在源链中的执行顺序,所述源链是所述多个子链中的一个子链;
按照所述跨链交易包中交易的排序,依次执行所述跨链交易包中的交易;其中,在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给所述多个子链中除所述目标子链外的其余子链;在执行空交易之前,根据所述空交易携带的交易ID,检测是否已经接收到所述其余子链发送的相同交易ID,若是,则执行所述空交易;
所述目标子链的排序节点接收所述其余节点提交的多个链内交易,并接收所述主链分发的所述跨链交易包;所述排序节点将所述多个链内交易和所述跨链交易包中的交易打 包成子链交易包,并将所述子链交易包分发给所述目标子链的至少一个节点;所述目标子链的至少一个节点在获得所述子链交易包后,将所述子链交易包中的所述多个链内交易划分为第一交易组,将所述子链交易包中所述跨链交易包的交易划分为第二交易组,并且并行处理所述第一交易组和所述第二交易组;所述至少一个节点在处理所述第二交易组时,按照所述第二交易组中交易的排序,依次执行交易。
根据本公开实施例的又一个方面,一种跨链系统,所述跨链系统包括主链和多个子链,所述主链和所述多个子链之间的跨链操作采用本公开任一实施例所述方法的步骤。
根据本公开实施例的再一个方面,提供一种电子设备,包括:
存储器,存储可执行指令;
一个或多个处理器,与存储器通信以执行可执行指令从而完成本公开任一实施例所述方法中各步骤的操作。
根据本公开实施例的再一个方面,提供一种计算机可读介质,用于存储计算机可读取的指令,所述指令被执行时实现本公开任一实施例所述方法中各步骤的操作。
基于本公开上述实施例提供的跨链交易有序执行方法和跨链系统,跨链交易包中的多个交易按照交易编号进行排序,跨链交易包中的多个交易保持了在源链中的执行顺序。并且,子链在按序执行跨链交易包中的交易期间,如果当前处理的交易是一个跨链交易,则在处理完该跨链交易后,将该跨链交易的交易ID发送给其他子链。如果当前处理的交易是一个空交易,则根据该空交易携带的交易ID,检测该子链是否已经接收到其他子链发送的相同交易ID,若已经接收到其他子链发送的相同交易ID,则说明其他子链已经处理了该空交易对应的跨链交易,接着子链才执行该空交易,并且在执行完该空交易后接着执行下一个交易。如此,对于源链的多个跨链交易,会按照这些跨链交易在源子链中的执行顺序,被若干子链依次执行,有助于实现跨链交易的有序执行。
下面通过附图和实施例,对本公开的技术方案做进一步的详细描述。
附图说明
构成说明书的一部分的附图描述了本公开的实施例,并且连同描述一起用于解释本公开的原理。
参照附图,根据下面的详细描述,可以更加清楚地理解本公开。显而易见地,下面描述中的附图仅仅是本公开的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其它的附图:
图1是本公开一实施例提出的跨链交易有序执行方法的流程图;
图2是本公开一实施例提出的跨链系统的示意图;
图3是本公开一实施例提出的跨链交易有序执行方法的流程示意图;
图4是本公开一实施例提出的骨干节点对跨链交易进行排序的示意图;
图5是本公开一实施例提出的验证节点生成跨链交易包的示意图;
图6是本公开一实施例提出的验证节点A生成跨链交易包的示意图;
图7是本公开一实施例提出的验证节点C生成跨链交易包的示意图;
图8是本公开一实施例提出的跨链交易有序执行方法的流程示意图。
具体实施方式
现在将参照附图来详细描述本公开的各种示例性实施例。应注意到:除非另外说明,否则在这些实施例中阐述的部件和步骤的相对布置、数字表达式和数值不限制本公开的范围。
还应理解,在本公开实施例中,“多个”可以指两个或两个以上,“至少一个”可以指一个、两个或两个以上。
本领域技术人员可以理解,本公开实施例中的“第一”、“第二”等术语仅用于区别不同步骤、设备或模块等,既不代表任何特定技术含义,也不表示它们之间的必然逻辑顺序。
还应理解,对于本公开实施例中提及的任一部件、数据或结构,在没有明确限定或者在前后文给出相反启示的情况下,一般可以理解为一个或多个。
还应理解,本公开对各个实施例的描述着重强调各个实施例之间的不同之处,其相同或相似之处可以相互参考,为了简洁,不再一一赘述。
以下对至少一个示例性实施例的描述实际上仅仅是说明性的,决不作为对本公开及其应用或使用的任何限制。
对于相关领域普通技术人员已知的技术、方法和设备可能不作详细讨论,但在适当情况下,所述技术、方法和设备应当被视为说明书的一部分。
应注意到:相似的标号和字母在下面的附图中表示类似项,因此,一旦某一项在一个附图中被定义,则在随后的附图中不需要对其进行进一步讨论。
本公开实施例可以应用于终端设备、计算机系统、服务器等电子设备,其可与众多其它通用或专用计算系统环境或配置一起操作。适于与终端设备、计算机系统、服务器等电子设备一起使用的众所周知的终端设备、计算系统、环境和/或配置的例子包括但不限于:个人计算机系统、服务器计算机系统、瘦客户机、厚客户机、手持或膝上设备、基于微处理器的系统、机顶盒、可编程消费电子产品、网络个人电脑、小型计算机系统﹑大型计算 机系统和包括上述任何系统的分布式云计算技术环境,等等。
终端设备、计算机系统、服务器等电子设备可以在由计算机系统执行的计算机系统可执行指令(诸如程序模块)的一般语境下描述。通常,程序模块可以包括例程、程序、目标程序、组件、逻辑、数据结构等等,它们执行特定的任务或者实现特定的抽象数据类型。计算机系统/服务器可以在分布式云计算环境中实施,分布式云计算环境中,任务是由通过通信网络链接的远程处理设备执行的。在分布式云计算环境中,程序模块可以位于包括存储设备的本地或远程计算系统存储介质上。
在实现本公开的过程中,发明人发现,由于跨链技术和跨链系统的复杂性,导致跨链交易的有序执行难以实现,从而引发业务问题。比如在子链A中注册的用户在一段时间内先后发起了跨链交易tx1和跨链交易tx2。用户希望首先通过跨链交易tx1,在子链B中购买m数量的债券资产,然后通过跨链交易tx2,利用剩余账户资产在子链C中购买n数量的基金资产。然而当账户a1的总资产不足以同时购买m数量的债券资产和n数量的基金资产时,如果两个跨链交易按序执行,则仍然能成功购买到用户最想购买的债券资产。但是如果两个跨链交易没有按序执行,则不能成功购买到用户最想购买的债券资产。可见,跨链交易的按序执行尤为重要。
针对上述问题,本公开实施例中提供了一种跨链交易有序执行方法、跨链系统、设备和介质,跨链交易包中的多个交易按照交易编号进行排序,跨链交易包中的多个交易保持了在源链中的执行顺序。并且,子链在按序执行跨链交易包中的交易期间,如果当前处理的交易是一个跨链交易,则在处理完该跨链交易后,将处理完的跨链交易的交易ID发送给其他子链。如果当前处理的交易是一个空交易,则根据空交易携带的交易ID,检测该子链是否已经接收到其他子链发送的相同交易ID,若是,则说明其他子链已经处理了该空交易对应的跨链交易,接着该子链才执行该空交易,并且在执行完该空交易后接着执行下一个交易。如此,对于源链的多个跨链交易,会按照这些跨链交易在源子链中的执行顺序,被若干子链依次执行,从而实现了跨链交易的有序执行。
本公开实施例中的方案可以采用各种计算机语言实现,例如,面向对象的程序设计语言Java和直译式脚本语言JavaScript等。
为了使本公开实施例中的技术方案及优点更加清楚明白,以下结合附图对本公开的示例性实施例进行进一步详细的说明,显然,所描述的实施例仅是本公开的一部分实施例,而不是所有实施例的穷举。需要说明的是,在不冲突的情况下,本公开中的实施例及实施例中的特征可以相互组合。
参考图1,图1是本公开一实施例提出的跨链交易有序执行方法的流程图。如图1所示, 跨链交易有序执行方法应用于跨链系统,该跨链系统包括主链和多个子链。如图1所示,跨链交易有序执行方法包括以下步骤:
S110:主链获得源链的多个跨链交易。
其中,每个跨链交易均携带目标链ID和交易编号,每个跨链交易的交易编号用于表征该跨链交易在源链中的执行顺序,源链是多个子链中的一个子链,目标链是多个子链中除源链之外的其他子链。
本公开中,每个跨链交易除了携带目标链ID和交易编号,还携带交易ID。其中,交易编号能反映跨链交易在源链中的执行顺序。比如多个跨链交易的交易编号是逐渐递增的数字编号,一个跨链交易的数字编号越大,该跨链交易在源链中的执行顺序越靠后。
为便于理解,示例性地,假设一个跨链交易携带如下信息“tx_id:077ae2439;nonce:175;Account:b1;Source_chain_id:chain-b;Destination_chain_id:chain-a”,说明该跨链交易的交易ID为077ae2439,该跨链交易的交易编号为175,该跨链交易是由账户b1发起的,该跨链交易的源链ID是chain-b,该跨链交易的目标链ID是chain-a。
又假设另一个跨链交易携带如下信息“tx_id:8d69cbc53;nonce:176;Account:b1;Source_chain_id:chain-b;Destination_chain_id:chain-c”,说明该跨链交易的交易ID为8d69cbc53,该跨链交易的交易编号为176,该跨链交易是由账户b1发起的,该跨链交易的源链ID是chain-b,该跨链交易的目标链ID是chain-c。
在一些可能的实施方式中,跨链系统还包括多个骨干节点,每个骨干节点分别对应一个子链,多个骨干节点中的一个骨干节点用于连接主链和该骨干节点对应的子链。在这些实施方式中,主链获得源链的多个跨链交易的过程具体包括:源链的骨干节点获得源链的多个跨链交易;骨干节点将多个跨链交易的至少一个跨链交易的交易结构调整为与主链匹配的交易结构,以及为至少一个调整后的跨链交易赋予交易编号,再将赋予交易编号后的多个跨链交易提交给主链。如此,主链获得该骨干节点提交的多个跨链交易。
在一个可选示例中,步骤S110可以由跨链系统中的主链执行。
S120:主链针对多个子链中的至少一个子链,根据多个跨链交易生成至少一个子链的跨链交易包,并将跨链交易包分发给至少一个子链。
其中,至少一个子链的跨链交易包中包括至少一个跨链交易和至少一个空交易。至少一个子链的跨链交易包中的跨链交易所携带的目标链ID与该子链的子链ID相同。至少一个子链的跨链交易包中的至少一个空交易中的一个空交易分别对应一个跨链交易,至少一个空交易对应的跨链交易所携带的目标链ID与该子链的子链ID不相同,至少一个空交易还携带对应跨链交易的交易ID。每个子链的跨链交易包中至少一个跨链交易和至少一个空交易按 照交易编号进行排序。
本公开中,由于每个子链的跨链交易包中至少一个跨链交易和至少一个空交易按照交易编号进行排序,因此至少一个子链的跨链交易包中至少一个交易的排序与若至少一个跨链交易在源链中的执行顺序一致。
在一些可能的实施方式中,主链将至少一个子链的跨链交易包分发给至少一个子链的过程具体包括:主链将至少一个子链的跨链交易包分发给至少一个子链的骨干节点;至少一个子链中的一个子链的骨干节点将跨链交易包中每个交易的交易结构调整为与该子链匹配的交易结构,并将调整后的跨链交易包提交给该子链。
需要说明的是,由于本公开的跨链系统中包括多个子链,而为了提高系统兼容性,多个子链可以是多种异构链,多个子链各自支持的交易结构互不相同。因此,为了使得多个子链之间顺利实现跨链,本公开中至少一个子链的跨链交易在被发送至主链之前,至少一个子链的骨干节点对相应子链的跨链交易的交易结构进行调整,然后将调整后的跨链交易发送给主链,使得主链能顺利执行跨链交易。同样地,每个子链的骨干节点也可以对主链发来的跨链交易的交易结构进行调整,然后将调整后的跨链交易发送给相应子链,使得子链能顺利执行跨链交易。
在一个可选示例中,步骤S120可以由跨链系统中的主链执行。
S130:每个子链获得跨链交易包后,按照跨链交易包中交易的排序,依次执行跨链交易包中的交易。
如图1所示,上述多个子链中的一个子链在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给上述多个子链中除了当前执行完跨链交易的子链之外的其余子链。上述多个子链中的一个子链在执行空交易之前,根据该空交易携带的交易ID,检测该子链是否已经接收到其他子链发送的相同交易ID,若已经接收到其他子链发送的相同交易ID,则执行该空交易。此外,如果该子链还未接收到上述多个子链中除了准备执行空交易的子链之外的其余子链发送的相同交易ID,则准备执行空交易的子链暂停执行该空交易,直至接收到上述多个子链中除了准备执行空交易的子链之外的其余子链发送的相同交易ID。
在一个可选示例中,步骤S130可以由处理器调用存储器存储的相应指令执行,也可以由被处理器运行的跨链交易包处理模块执行。
在一些可能的实施方式中,如图1所示,子链在执行完一个链跨交易后,通过以下方式将该跨链交易的交易ID发送给其余子链:
S130-1:子链在执行完一个链跨交易后,将该跨链交易的交易ID发送给主链。
在一个可选示例中,步骤S130-1可以由跨链系统中的子链执行。
S130-2:主链接收到交易ID后,将交易ID转发给多个子链中的至少一个子链,例如,可以将该交易ID转发给多个子链中的每个子链。
在一个可选示例中,步骤S130-2可以由跨链系统中的主链执行。
本公开中,通过主链向跨链系统中至少一个子链转发交易ID,例如通过主链向跨链系统中所有子链转发交易ID,因此该至少一个子链不需要保存和随时更新子链之间的路由关系,有利于简化子链设计,减少子链计算任务量。
具体实现时,主链中包括多个主链节点,至少一个主链节点对应有子链,例如每个主链节点分别对应一个子链。当某个子链执行完一个跨链交易后,该子链将该跨链交易的交易ID发送给该子链的骨干节点。骨干节点将该交易ID提交给该子链对应的主链节点。主链节点接收到交易ID后,主链节点通过主链的P2P网络,将交易ID同步给主链的其他主链节点。该其他主链节点中的每个主链节点接收到交易ID后,将交易ID发送给每个主链节点对应的子链的骨干节点。每个骨干节点接收到主链节点发送的交易ID后,将交易ID发送给对应子链。子链接收到交易ID后,通过子链的P2P网络,在子链内进行同步,使得各个子链节点接收到该交易ID。
在另一些可能的实施方式中,跨链系统中的至少一个子链可以保存和随时更新子链之间的路由关系,例如跨链系统中的每个子链可以保存和随时更新子链之间的路由关系。当跨链系统中的某个子链执行完一个跨链交易后,该子链可以根据子链之间的路由关系,将该跨链交易的交易ID直接发送给其余子链。
在一些可能的实施方式中,跨链系统中的至少一个子链可以执行跨链交易,例如跨链系统中的每个子链除了可以执行跨链交易之外,还可以执行多个链内交易,为了提升跨链系统中的子链对交易的整体执行效率。本公开中,跨链系统中的子链可以将链内交易和跨链交易打包至同一个交易包(以下称为子链交易包)进行处理。具体实现时,包括以下过程:
至少一个子链的排序节点接收该子链的其他节点提交的多个链内交易,例如跨链系统中的每个子链的排序节点接收该子链的其他节点提交的多个链内交易,并接收主链分发的跨链交易包;该至少一个子链的排序节点将多个链内交易和跨链交易包中的各个交易打包成子链交易包,并将子链交易包分发给该子链内的至少一个节点;该至少一个节点在获得子链交易包后,将子链交易包中的多个链内交易划分为第一交易组,将子链交易包中跨链交易包的各个交易划分为第二交易组,并且并行处理所述第一交易组和所述第二交易组。
至少一个节点在处理第二交易组时,例如跨链系统中的每个子链节点在处理第二交易组时,按照第二交易组中交易的排序,依次执行第二交易组中的交易。具体地,如前所述,在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给其余子链。在执行空交易之前, 根据该空交易携带的交易ID,检测是否已经接收到其他子链发送的相同交易ID,若已经接收到其他子链发送的相同交易ID,则执行该空交易。此外,若还未接收到其他子链发送的相同交易ID,则暂停执行该空交易,直至接收到其他子链发送的相同交易ID。
本公开中,通过将一个子链交易包中的链内交易划分成第一交易组,将子链交易包中的跨链交易和空交易划分成第二交易组,并且有跨链系统中的子链并行处理这两个交易组。因此链内交易的执行不会受到空交易的影响,比如子链节点在执行空交易期间,由于还没有接收到跨链系统中除了正在执行空交易的子链的其余子链发送的相同交易ID而进行等待期间,虽然会影响空交易后续的跨链交易的执行,但是第一交易组中的链内交易不会受到影响,仍然可以继续执行,从而进一步提升了子链对交易的整体执行效率。本公开中,当第一交易组和第二交易组均执行完毕后,执行第一交易组和第二交易组的子链生成区块并对区块进行共识。
采用本公开实施例中提供的跨链交易有序执行方法,跨链交易包中的多个交易按照交易编号进行排序,跨链交易包中的多个交易保持了在源链中的执行顺序。并且,跨链系统中的一个子链在按序执行跨链交易包中的交易期间,如果当前处理的交易是一个跨链交易,则在处理完该跨链交易后,将该跨链交易的交易ID发送给其他子链。如果当前处理的交易是一个空交易,则根据该空交易携带的交易ID,检测该子链是否已经接收到跨链系统除该子链之外的其余子链发送的相同交易ID。如果该子链已经接收到该其余子链发送的相同交易ID,则说明该其余子链已经处理了该空交易对应的跨链交易,接着该子链才执行该空交易,并且在执行完该空交易后接着执行下一个交易。如果该子链还没有接收到该其余子链发送的相同交易ID,则说明该其余子链还没有处理该空交易对应的跨链交易,因此子链进行等待,直至接收到该其余子链发送的相同交易ID,才执行该空交易,然后接着执行下一个交易。如此,对于源链的多个跨链交易,会按照这些跨链交易在源子链中的执行顺序,被子链依次执行,从而实现了跨链交易的有序执行。
参考图2,图2是本公开一实施例提出的跨链系统的示意图。如图2所示,该跨链系统包括主链、多个子链以及多个骨干节点,至少一个骨干节点对应有子链,例如每个骨干节点分别对应一个子链,每个骨干节点用于连接主链和该骨干节点对应的子链。
其中,骨干节点的作用是跨链网关,骨干节点内置跨链账户(即在主链中注册的账户),负责子链与主链之间的消息通信。主链可以面向多个领域的子链,用于实现多个领域子链的数据流通。
如图2所示,基于该跨链系统的跨链过程主要包括:
S210:骨干节点获得子链的跨链交易TX,并对子链的跨链交易TX进行验证,以及将跨链交易TX调整成主链支持的交易结构,并发送至主链。
在一个可选示例中,步骤S210可以跨链系统中的骨干节点执行。
S220:主链的验证节点之间,对跨链交易TX进行转发、执行以及验证后,将跨链交易TX提交给主链的共识节点。
在一个可选示例中,步骤S220可以跨链系统中的主链执行。
S230:主链的共识节点对跨链交易TX进行打包、共识以及上链,从而生成区块block,区块block中记录有多个跨链交易TX。
在一个可选示例中,步骤S230可以跨链系统中的主链执行。
S240:主链的验证节点获得共识节点生成的区块block,从区块block中读取出跨链交易TX,并针对每个跨链交易TX,根据该跨链交易TX携带的目标链ID,通知目标链对应的骨干节点。
在一个可选示例中,步骤S240可以跨链系统中的主链执行。
S250:骨干节点将跨链交易TX调整成相应子链支持的交易结构,并将调整后的跨链交易TX路由给相应子链。
在一个可选示例中,步骤S250可以跨链系统中的骨干节点执行。
S260:子链获得跨链交易TX后,验证跨链交易TX的签名,验签通过后执行跨链交易TX。
在一个可选示例中,步骤S260可以跨链系统中的子链执行。
图2示出了本公开提出的跨链操作流程,为了实现跨链交易的有序性,跨链系统在跨链操作期间,可以执行如图1所示的跨链操作步骤。
以上,本公开通过一些实施例对跨链交易有序执行方法和跨链系统进行了介绍。以下,本公开通过另一些实施例对跨链交易有序执行方法做进一步详细介绍。
参考图3,图3是本公开一实施例提出的跨链交易有序执行方法的流程示意图。如图3所示,该方法包括以下步骤:
S310:骨干节点监听子链的区块生成事件,当子链生成新的区块后,骨干节点从子链获取到该区块,并针对区块中的每个交易,根据交易的类型标识,判断该交易是否为跨链交易,如果该交易是跨链交易,则骨干节点按照预设排序规则,将该交易放入跨链交易队列。
本公开中,对于多个跨链交易,骨干节点会按照多个跨链交易在子链中的执行顺序,将这些跨链交易排列至跨链交易队列。
为便于理解,如图4所示,骨干节点在一段时间内获得了子链的两个区块,这两个区块分别是:子链b的区块高度等于101的区块、子链b的区块高度等于102的区块。每个区块中包括若干跨链交易,例如子链b的区块高度等于101的区块中包括tx3和tx12等跨链交易,子链b的区块高度等于102的区块中包括tx9和tx28等跨链交易。
在按照预设排序规则对多个跨链交易进行排序时,首先按照区块高度从小到大的顺序排列,针对每个区块内的多个跨链交易,再按照跨链交易在区块内的原有顺序进行排序。如此,图4所示的多个跨链交易的最终排序为:tx3、tx12、tx9、tx28。
在一个可选示例中,步骤S310可以跨链系统中的骨干节点执行。
S320:骨干节点对每个跨链交易的交易结构进行调整,使得调整后的交易结构是主链能处理的交易结构。
具体实现时,骨干节点注册有跨链账户(即骨干节点在主链中的账户),骨干节点的跨链账户用于向跨链账户赋予nonce值(本公开中nonce值即是交易编号)。骨干节点首先按照预设调整方式,将每个跨链交易的交易结构调整为主链能处理的交易结构。然后骨干节点针对跨链交易队列中的每个跨链交易,依次将nonce值赋予这个跨链交易。骨干节点每赋予一次nonce值,nonce值自动增加1。
为便于理解,假设骨干节点在为tx3赋予nonce值之前,nonce值等于175,则骨干节点将交易序号值175赋予tx3。此后nonce值自动加1,更新为176,骨干节点将nonce值176赋予tx12。此后骨干节点的nonce值自动加1,更新为177,骨干节点将交易序号值2757赋予tx9。此后骨干节点的nonce值自动加1,更新为178,骨干节点将交易序号值178赋予tx28。最终,骨干节点依次为多个跨链交易分别赋予了不同的nonce值,多个跨链交易的nonce值依次递增。
在一个可选示例中,步骤S320可以跨链系统中的骨干节点执行。
S330:骨干节点将多个跨链交易发送给主链中与多个跨链交易对应的验证节点;验证节点对跨链交易进行验证,在验证通过后,将多个跨链交易发送给主链的共识节点执行;共识节点执行跨链交易后生成区块,并将区块同步给验证节点。
本公开中,如图2所示,主链包括多个验证节点和多个共识节点,每个验证节点分别对应一个子链和骨干节点,多个验证节点与多个共识节点连接。骨干节点将多个跨链交易发送给骨干节点对应的验证节点。
在一个可选示例中,步骤S330可以跨链系统中的骨干节点执行。
S340:每个验证节点在获得主链生成的区块后,根据区块中每个跨链交易携带的骨干节点账户信息,对多个跨链交易进行分组,每个分组中的跨链交易按照nonce值排序。[0076]为便于理解,如图5所示,主链生成的新区块中包括tx1至tx6等6个跨链交易。其中,每个跨链交易中记录有:骨干节点账户信息、nonce值、个人账户信息以及目标链ID等信息。以tx1为例,其中“骨B账户”表示tx1携带骨干节点B的账户信息,换言之,tx1是由骨干节点B发送给主链的跨链交易。“nonce=175”表示tx1的nonce值等于175。“个人账户b1”表示tx1最早是 由个人账户b1在骨干节点B的子链上发起的。“目标链a”表示tx1需要被发送给骨干节点A连接的子链a。
在一个可选示例中,步骤S340可以跨链系统中的主链执行。
如图3所示,以验证节点A为例,验证节点A获得主链生成的新区块后,验证节点A根据骨干节点账户信息,将新区块中的6个跨链交易划分成两组,其中一组是骨B账户的跨链交易,另一组是骨D账户的跨链交易。每组跨链交易中,多个跨链交易按照nonce值从小到大进行排序。
S350:验证节点对每组跨链交易分别进行处理,验证节点在处理一组跨链交易期间,针对其中的每个跨链交易,如果该跨链交易携带的目标链ID是对应骨干节点所连接的子链ID,则保留该跨链交易,如果该跨链交易携带的目标链ID不是对应骨干节点所连接的子链ID,则将该跨链交易替换为空交易,空交易保留该跨链交易的交易ID。如此,将一组跨链交易转换成若干跨链交易和若干空交易,这些交易之间仍然维持原有顺序,这些交易形成一个跨链交易包。
为便于理解,如图5所示,以验证节点A为例,针对骨B账户对应的一组跨链交易(包括TX3、TX12、TX9以及TX28)。首先针对TX3,由于TX3携带的目标链ID为a,而目标链a恰好是验证节点A对应的骨干节点A所连接的子链,因此保留跨链交易TX3。
然后针对TX12,由于TX12携带的目标链ID为c,而目标链c不是验证节点A对应的骨干节点A所连接的子链,因此将TX12替换成空交易,该空交易保留TX12的交易ID。
接着针对TX9,由于TX9携带的目标链ID为c,而目标链c不是验证节点A对应的骨干节点A所连接的子链,因此将TX9替换成空交易,该空交易保留TX9的交易ID。
最后针对TX28,由于TX28携带的目标链ID为a,而目标链a恰好是验证节点A对应的骨干节点A所连接的子链,因此保留跨链交易TX28。
最终,验证节点A生成了如图6所示的跨链交易包,验证节点C生成了如图7所示的交易包。此外,验证节点C和验证节点E还针对骨D账户的一组跨链交易生成了交易包,为简化说明,此处不做赘述。
在一个可选示例中,步骤S350可以跨链系统中的主链执行。
S360:验证节点将跨链交易包,并发送给对应的骨干节点;骨干节点将跨链交易包中各交易改造成子链能处理的交易结构后,将跨链交易包发送给骨干节点连接的子链。
对于子链而言,子链在处理交易时,包括以下步骤:
S371:子链的主节点master获得跨链交易包后,将跨链交易包中的各交易与子链的链内交易一起进行排序打包,生成子链交易包;子链交易包中包括多个链内交易和多个跨链交 易,多个跨链交易保留了原有顺序;主节点master将子链交易包分发给子链的每个节点。
在一个可选示例中,步骤S371可以跨链系统中的子链执行。
S372:子链的每个节点在获得子链交易包后,将子链交易包中的多个链内交易划分为第一交易组,将子链交易包中的若干跨链交易和若干空交易划分为第二交易组,第二交易组中若干跨链交易和若干空交易保持原有顺序。
在一个可选示例中,步骤S372可以跨链系统中的子链执行。
S373:每个节点在处理交易时,利用第一进程来按序处理第一交易组中的各个交易,利用第二进程来按序处理第二交易组中的各个交易。
在一个可选示例中,步骤S373可以跨链系统中的子链执行。
其中,第二进程在按序处理第二交易组中的交易期间,如果当前处理的交易是一个跨链交易,则第二进程直接执行该跨链交易,并且在处理完该跨链交易后,将该跨链交易的交易ID发送给主节点master。当主节点master接收到大多数节点(例如60%节点)发送的交易ID后,主节点master将该交易ID发送给骨干节点,从而通过骨干节点和主链,将该交易ID路由给其他子链进行缓存。
如果当前处理的交易是一个空交易,则第二进程尝试从缓存中读取该空交易的交易ID。如果第二进程读取到交易ID,则说明其他子链已经处理完该空交易对应的跨链交易。在此情况下,第二进程执行该空交易(例如直接将空交易的执行状态更新为已执行),并且在执行完该空交易后接着处理下一个交易。如果第二进程没有读取到交易ID,则说明其他子链还没有处理完该空交易对应的跨链交易。在此情况下,第二进程进行等待,直到缓存中存入相应交易ID。如此,对于来自于同一子链多个跨链交易,这些跨链交易即使在不同子链上执行,也会按照交易编号顺序被依次执行。
为便于理解,示例性地,结合图6和图7,子链a执行完跨链交易TX3之后,子链a将跨链交易TX3的交易ID发送给其他子链。子链c接收到跨链交易TX3的交易ID之后,才会执行空交易TX3。子链c在执行完空交易TX3之后,才会执行跨链交易TX12。子链c执行完跨链交易TX12之后,子链c将跨链交易TX12的交易ID发送给其他子链。子链c接着执行跨链交易TX9,子链c执行完跨链交易TX9之后,子链c将跨链交易TX9的交易ID发送给其他子链。子链a接收到跨链交易TX12的交易ID后,才会执行空交易TX12。子链a执行完空交易TX12,且接收到跨链交易TX9的交易ID后,才会执行空交易TX9。子链a执行完空交易TX9之后,才会执行跨链交易TX28。子链a执行完跨链交易TX28之后,子链a将跨链交易TX28的交易ID发送给其他子链。子链c接收到跨链交易TX28的交易ID之后,才会执行空交易TX28。
上述过程中,跨链交易TX3、跨链交易TX12、跨链交易TX9以及跨链交易TX28在子链a和子链c中按序执行。换言之,跨链交易TX3被子链a执行完后,跨链交易TX12才会被子链c执行。跨链交易TX12被子链c执行完后,跨链交易TX9才会被子链c执行。跨链交易TX9被子链c执行完后,跨链交易TX28才会被子链a执行。
S374:当两个进程分别处理完第一交易组和第二交易组之后,子链的节点再按照原有交易顺序生成区块并共识。
在一个可选示例中,步骤S374可以跨链系统中的子链执行。
以上,本公开通过一些实施例提出了跨链交易有序执行方法,上述跨链交易有序执行方法应用于整个跨链系统。以下,本公开通过另一些实施例提供一种应用于子链的跨链交易有序执行方法。以下应用于子链的跨链交易有序执行方法的具体实施方式,可参考上述实施例,为避免重复,以下对应用于子链的跨链交易有序执行方法进行简要介绍。
参考图8,图8是本公开一实施例提出的跨链交易有序执行方法的流程示意图,该跨链交易有序执行方法应用于跨链系统中的子链。如图8所示,该方法包括以下步骤:
S810:获得主链分发的跨链交易包。
其中,跨链交易包中包括至少一个跨链交易和至少一个空交易,至少一个跨链交易携带的目标链ID与目标子链的子链ID相同。该至少一个空交易中的一个空交易对应一个跨链交易,该至少一个空交易对应的跨链交易所携带的目标链ID与目标子链的子链ID不相同,该至少一个空交易还携带对应跨链交易的交易ID。每个子链的跨链交易包中该至少一个跨链交易和该至少一个空交易按照交易编号进行排序,交易编号用于表征每个跨链交易在源链中的执行顺序,源链是多个子链中的一个子链。
在一个可选示例中,步骤S810可以跨链系统中的子链执行。
S820:按照跨链交易包中交易的排序,依次执行跨链交易包中的交易;其中,在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给其余子链;在执行空交易之前,根据该空交易携带的交易ID,检测是否已经接收到其他子链发送的相同交易ID,若已经接收到其他子链发送的相同交易ID,则执行该空交易。
在一个可选示例中,步骤S820可以跨链系统中的子链执行。
在一些可能的实施方式中,如果还未接收到其他子链发送的相同交易ID,则暂停执行该空交易,直至接收到其他子链发送的相同交易ID。
在一些可能的实施方式中,目标子链获得主链分发的跨链交易包,按照跨链交易包中交易的排序,依次执行跨链交易包中的交易的具体过程包括:
目标子链的排序节点接收目标子链的其他节点提交的多个链内交易,并接收主链分发的 跨链交易包;目标子链的排序节点将多个链内交易和跨链交易包中的各个交易打包成子链交易包,并将子链交易包分发给目标子链的至少一个节点;目标子链的该至少一个节点在获得子链交易包后,将子链交易包中的多个链内交易划分为第一交易组,将子链交易包中跨链交易包的各个交易划分为第二交易组,并且并行处理第一交易组和第二交易组;该至少一个节点在处理第二交易组时,按照第二交易组中交易的排序,依次执行交易。
在一些可能的实施方式中,目标子链在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给其余子链的具体过程包括:在执行完一个链跨交易后,将执行完的跨链交易的交易ID发送给主链,使主链将交易ID转发给多个子链中的至少一个子链。
本领域内的技术人员应明白,本公开的实施例可提供为方法、系统、或计算机程序产品。因此,本公开可采用完全硬件实施例、完全软件实施例、或结合软件和硬件方面的实施例的形式。而且,本公开可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。
本公开是参照根据本公开实施例的方法、设备(系统)、和计算机程序产品的流程图和/或方框图来描述的。应理解可由计算机程序指令实现流程图和/或方框图中的每一流程和/或方框、以及流程图和/或方框图中的流程和/或方框的结合。可提供这些计算机程序指令到通用计算机、专用计算机、嵌入式处理机或其他可编程数据处理设备的处理器以产生一个机器,使得通过计算机或其他可编程数据处理设备的处理器执行的指令产生用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的装置。
这些计算机程序指令也可存储在能引导计算机或其他可编程数据处理设备以特定方式工作的计算机可读存储器中,使得存储在该计算机可读存储器中的指令产生包括指令装置的制造品,该指令装置实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能。
这些计算机程序指令也可装载到计算机或其他可编程数据处理设备上,使得在计算机或其他可编程设备上执行一系列操作步骤以产生计算机实现的处理,从而在计算机或其他可编程设备上执行的指令提供用于实现在流程图一个流程或多个流程和/或方框图一个方框或多个方框中指定的功能的步骤。

Claims (8)

  1. 一种跨链交易有序执行方法,其特征在于,所述跨链交易有序执行方法应用于跨链系统,所述跨链系统包括主链和多个子链,所述跨链交易有序执行方法包括:
    所述主链获得源链的多个跨链交易,所述多个跨链交易中的至少一个跨链交易携带目标链ID和交易编号,所述交易编号用于表征所述交易编号所属的跨链交易在所述源链中的执行顺序,所述源链是所述多个子链中的一个子链,所述目标链ID对应的目标链是所述多个子链中除所述源链之外的子链;
    所述主链针对所述多个子链中的至少一个子链,根据所述多个跨链交易生成所述至少一个子链的跨链交易包,并将所述跨链交易包分发给所述至少一个子链;所述跨链交易包中包括至少一个空交易和所述多个跨链交易中的至少一个跨链交易;所述跨链交易包中的跨链交易所携带的目标链ID与所述跨链交易包所属子链的子链ID相同;所述至少一个空交易的一个空交易对应一个跨链交易,所述至少一个空交易对应的跨链交易所携带的目标链ID与所述跨链交易包所属子链的子链ID不相同,所述至少一个空交易还携带对应跨链交易的交易ID;所述跨链交易包中的所述至少一个跨链交易和所述至少一个空交易按照交易编号进行排序;
    所述至少一个子链获得所述跨链交易包后,按照所述跨链交易包中交易的排序,依次执行所述跨链交易包中的交易;其中,所述至少一个子链中的一个子链在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给所述至少一个子链的其余子链;所述至少一个子链中的一个子链在执行空交易之前,根据所述空交易携带的交易ID,检测所述至少一个子链中的一个子链是否已经接收到其他子链发送的相同交易ID,若已经接收到所述其他子链发送的相同交易ID,则执行该所述空交易;
    所述至少一个子链获得所述跨链交易包后,按照所述跨链交易包中交易的排序,依次执行每个交易,包括:所述至少一个子链中的一个子链的排序节点接收所述至少一个子链的其他节点提交的多个链内交易,并接收所述跨链交易包;所述至少一个子链中的一个子链的排序节点将多个链内交易和所述跨链交易包中的交易打包成子链交易包,并将所述子链交易包分发给所述至少一个子链内的至少一个节点;所述至少一个节点在获得所述子链交易包后,将所述子链交易包中的多个链内交易划分为第一交易组,将所述子链交易包中跨链交易包的交易划分为第二交易组,并且并行处理所述第一交易组和所述第二交易组;所述至少一个节点在处理所述第二交易组时,按照所述第二交易组中交易的排序,依次执行交易。
  2. 根据权利要求1所述的方法,其特征在于,所述方法还包括:
    如果所述至少一个子链中的一个子链还未接收到所述其他子链发送的相同交易ID,则所 述至少一个子链中的一个子链暂停执行所述空交易,直至接收到所述其他子链发送的相同交易ID。
  3. 根据权利要求1所述的方法,其特征在于,所述至少一个子链中的一个子链在执行完一个链跨交易后,将执行完的跨链交易的交易ID发送给所述至少一个子链中的其余子链,包括:
    所述至少一个子链中的一个子链在执行完一个链跨交易后,将执行完的跨链交易的交易ID发送给所述主链,所述主链将所述交易ID转发给所述多个子链中的至少一个子链。
  4. 根据权利要求1至3任一所述的方法,其特征在于,所述跨链系统还包括多个骨干节点,所述多个骨干节点中的一个骨干节点对应一个子链,所述多个骨干节点中的一个骨干节点用于连接所述主链和所述多个骨干节点中的一个骨干节点对应的子链;
    所述主链获得源链的多个跨链交易,包括:
    所述源链的骨干节点获得所述源链的多个跨链交易,并将所述多个跨链交易的至少一个跨链交易的交易结构调整为与所述主链匹配的交易结构,以及为至少一个调整后的跨链交易赋予交易编号,再将赋予交易编号后的多个跨链交易提交给所述主链;
    所述主链将所述跨链交易包分发给所述至少一个子链,包括:
    所述主链将所述跨链交易包分发给所述至少一个子链的骨干节点,所述至少一个子链的骨干节点将所述跨链交易包中至少要给交易的交易结构调整为与所述至少一个子链匹配的交易结构,并将调整后的跨链交易包提交给所述至少一个子链。
  5. 一种跨链交易有序执行方法,其特征在于,所述方法应用于跨链系统中的目标子链,所述跨链系统包括主链和多个子链,所述目标子链是所述多个子链中的一个子链,所述方法包括:
    获得所述主链分发的跨链交易包;所述跨链交易包中包括至少一个跨链交易和至少一个空交易,所述至少一个跨链交易携带的目标链ID与所述目标子链的子链ID相同;所述至少一个空交易中的一个空交易分别对应一个跨链交易,所述至少一个空交易对应的跨链交易所携带的目标链ID与所述目标子链的子链ID不相同,所述至少一个空交易还携带对应跨链交易的交易ID;所述跨链交易包中所述至少一个跨链交易和所述至少一个空交易按照交易编号进行排序,所述交易编号用于表征所述至少一个跨链交易在源链中的执行顺序,所述源链是所述多个子链中的一个子链;
    按照所述跨链交易包中交易的排序,依次执行所述跨链交易包中的交易;其中,在执行完一个跨链交易后,将执行完的跨链交易的交易ID发送给所述多个子链中除所述目标子链外的其余子链;在执行空交易之前,根据所述空交易携带的交易ID,检测是否已经接收到所述其余子链发送的相同交易ID,若是,则执行所述空交易;
    所述目标子链的排序节点接收所述其余节点提交的多个链内交易,并接收所述主链分发的所述跨链交易包;所述排序节点将所述多个链内交易和所述跨链交易包中的交易打包成子链交易包,并将所述子链交易包分发给所述目标子链的至少一个节点;所述目标子链的至少一个节点在获得所述子链交易包后,将所述子链交易包中的所述多个链内交易划分为第一交易组,将所述子链交易包中所述跨链交易包的交易划分为第二交易组,并且并行处理所述第一交易组和所述第二交易组;所述至少一个节点在处理所述第二交易组时,按照所述第二交易组中交易的排序,依次执行交易。
  6. 根据权利要求5所述的方法,其特征在于,所述方法还包括:
    如果还未接收到所述其余子链发送的相同交易ID,则暂停执行所述空交易,直至接收到所述其余子链发送的相同交易ID。
  7. 根据权利要求5所述的方法,其特征在于,所述在执行完一个跨链交易后,将该跨链交易的交易ID发送给其余子链,包括:
    在执行完一个链跨交易后,将执行完的跨链交易的交易ID发送给所述主链,使所述主链将所述交易ID转发给所述多个子链中的至少一个子链。
  8. 一种跨链系统,其特征在于,所述跨链系统包括主链和多个子链,所述主链和所述多个子链之间的跨链操作采用如权利要求1至4任一所述方法的步骤。
PCT/CN2022/097229 2021-09-16 2022-06-06 跨链交易有序执行方法和跨链系统 WO2023040363A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202111084581.8 2021-09-16
CN202111084581.8A CN113537991B (zh) 2021-09-16 2021-09-16 一种跨链交易有序执行方法和跨链系统

Publications (1)

Publication Number Publication Date
WO2023040363A1 true WO2023040363A1 (zh) 2023-03-23

Family

ID=78092679

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/097229 WO2023040363A1 (zh) 2021-09-16 2022-06-06 跨链交易有序执行方法和跨链系统

Country Status (2)

Country Link
CN (1) CN113537991B (zh)
WO (1) WO2023040363A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171236A (zh) * 2023-11-02 2023-12-05 中电科大数据研究院有限公司 一种基于区块链的数据溯源方法及系统

Families Citing this family (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113537991B (zh) * 2021-09-16 2022-03-01 中国信息通信研究院 一种跨链交易有序执行方法和跨链系统
CN114785853B (zh) * 2022-03-31 2024-04-19 蚂蚁区块链科技(上海)有限公司 在区块链的系统中跨链通信的方法、装置、存储介质及计算设备
CN114612103B (zh) * 2022-05-10 2022-08-02 中国信息通信研究院 跨区块链交易的方法、装置、系统、介质及电子设备
CN117527832A (zh) * 2024-01-03 2024-02-06 杭州趣链科技有限公司 一种区块链的交易排序方法、装置、电子设备和存储介质

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019211225A1 (en) * 2018-05-01 2019-11-07 International Business Machines Corporation Blockchain implementing cross-chain transactions
CN111798316A (zh) * 2020-07-03 2020-10-20 杭州复杂美科技有限公司 平行链共识方法、设备和存储介质
CN112598514A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 基于区块链的跨链交易管理方法、跨链平台及介质
CN113537991A (zh) * 2021-09-16 2021-10-22 中国信息通信研究院 一种跨链交易有序执行方法和跨链系统

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109035016B (zh) * 2018-06-28 2020-10-23 杭州复杂美科技有限公司 一种多链并发交易方法
CN109325762B (zh) * 2018-08-30 2020-07-10 杭州复杂美科技有限公司 平行链跨链交易方法、设备和存储介质
CN109493050B (zh) * 2018-11-21 2021-08-03 北京蓝石环球区块链科技有限公司 基于区块链主链加并行多子链的转账方法
AU2018347203B2 (en) * 2018-12-28 2021-01-21 Advanced New Technologies Co., Ltd. Parallel execution of transactions in a blockchain network
CN110428332A (zh) * 2019-07-29 2019-11-08 杭州复杂美科技有限公司 一种平行链跨链交易方法、设备和存储介质
CN111046109B (zh) * 2019-12-27 2023-09-15 深圳市迅雷网络技术有限公司 一种跨链任务处理方法、装置、设备及可读存储介质
CN111292192A (zh) * 2020-02-18 2020-06-16 杭州复杂美科技有限公司 一种交易并行执行方法、设备及存储介质
CN111861754B (zh) * 2020-07-30 2023-11-28 杭州复杂美科技有限公司 交易打包方法、设备和存储介质

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2019211225A1 (en) * 2018-05-01 2019-11-07 International Business Machines Corporation Blockchain implementing cross-chain transactions
CN111798316A (zh) * 2020-07-03 2020-10-20 杭州复杂美科技有限公司 平行链共识方法、设备和存储介质
CN112598514A (zh) * 2020-12-09 2021-04-02 杭州趣链科技有限公司 基于区块链的跨链交易管理方法、跨链平台及介质
CN113537991A (zh) * 2021-09-16 2021-10-22 中国信息通信研究院 一种跨链交易有序执行方法和跨链系统

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117171236A (zh) * 2023-11-02 2023-12-05 中电科大数据研究院有限公司 一种基于区块链的数据溯源方法及系统
CN117171236B (zh) * 2023-11-02 2024-02-06 中电科大数据研究院有限公司 一种基于区块链的数据溯源方法及系统

Also Published As

Publication number Publication date
CN113537991B (zh) 2022-03-01
CN113537991A (zh) 2021-10-22

Similar Documents

Publication Publication Date Title
WO2023040363A1 (zh) 跨链交易有序执行方法和跨链系统
US11356282B2 (en) Sending cross-chain authenticatable messages
US11336465B2 (en) Sending cross-chain authenticatable messages
WO2020177547A1 (zh) 一种区块链系统及区块链系统的交易处理方法
WO2020082871A1 (zh) 一种并行化执行区块链交易的方法、装置及系统
Daniel et al. A service-oriented perspective on blockchain smart contracts
WO2020258847A1 (zh) 基于处理模块跨链发送可认证消息的方法和装置
CN109815025B (zh) 一种业务模型调用方法、装置及存储介质
JP2014089744A (ja) コマンドライン環境を使用する遠隔システム管理
CN104239555B (zh) 基于mpp的并行数据挖掘系统及其实现方法
US20220129408A1 (en) Data actor and data processing method thereof
CN103116655B (zh) 集群数据查询方法、客户端及系统
CN113067900B (zh) 智能合约的部署方法及装置
US10887235B2 (en) Method of executing a tuple graph program across a network
CN113743944A (zh) 跨链消息可靠传递方法、装置以及电子设备
CN109254854A (zh) 异步调用方法、计算机装置及存储介质
CN111126977A (zh) 一种区块链系统的交易处理方法
WO2023231338A1 (zh) 状态数据的提交方法、节点和区块链系统
CN106874109A (zh) 一种分布式作业分发处理方法及系统
US11429355B2 (en) System of type inference for tuple graph programs
CN114116166A (zh) 基于智能合约的任务执行方法及装置
CN111290965A (zh) 一种测试方法、装置、计算机设备和存储介质
WO2012024435A2 (en) System and method for execution of high performance computing applications
US7944842B2 (en) Opportunistic queueing injection strategy for network load balancing
EP3136251B1 (en) Flit transmission method and device of network on chip

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22868740

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE