WO2021018048A1 - 一种跨链交易方法和装置 - Google Patents

一种跨链交易方法和装置 Download PDF

Info

Publication number
WO2021018048A1
WO2021018048A1 PCT/CN2020/104551 CN2020104551W WO2021018048A1 WO 2021018048 A1 WO2021018048 A1 WO 2021018048A1 CN 2020104551 W CN2020104551 W CN 2020104551W WO 2021018048 A1 WO2021018048 A1 WO 2021018048A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
node
status
hash
chain
Prior art date
Application number
PCT/CN2020/104551
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
Priority claimed from CN201911129391.6A external-priority patent/CN112308713A/zh
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Priority to EP20847049.2A priority Critical patent/EP3996028A4/en
Publication of WO2021018048A1 publication Critical patent/WO2021018048A1/zh
Priority to US17/585,250 priority patent/US11966378B2/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2308Concurrency control
    • G06F16/2315Optimistic concurrency control
    • G06F16/2322Optimistic concurrency control using timestamps
    • 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
    • G06Q30/00Commerce
    • G06Q30/06Buying, selling or leasing transactions
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2379Updates performed during online database operations; commit processing
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • G06F16/275Synchronous replication
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures
    • 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/04Payment circuits
    • G06Q20/06Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
    • G06Q20/065Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
    • 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/381Currency conversion
    • 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/3825Use of electronic signatures
    • 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/3827Use of message hashing
    • 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
    • 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/405Establishing or using transaction specific rules
    • 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/407Cancellation of a transaction
    • 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
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/32Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials
    • H04L9/3236Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions
    • H04L9/3239Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols including means for verifying the identity or authority of a user of the system or for message authentication, e.g. authorization, entity authentication, data integrity or data verification, non-repudiation, key authentication or verification of credentials using cryptographic hash functions involving non-keyed hash functions, e.g. modification detection codes [MDCs], MD5, SHA or RIPEMD
    • 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
    • G06Q2220/00Business processing using cryptography
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L2209/00Additional information or applications relating to cryptographic mechanisms or cryptographic arrangements for secret or secure communication H04L9/00
    • H04L2209/56Financial cryptography, e.g. electronic payment or e-cash
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Definitions

  • This application relates to the field of Internet technology, in particular to a cross-chain transaction method and device.
  • the blockchain system In the Blockchain system, data is stored in blocks, and newly written data forms a new block, which is added to the end of the current blockchain. While storing data in each block, it also saves a number (usually the hash value of all recorded data) uniquely corresponding to all the data recorded in the previous block, thereby forming a chain. Therefore, the blockchain system can be considered as a system in which computers on a distributed network that do not fully trust each other, through consensus rules, jointly maintain a set of traceable and non-tamperable chain data systems.
  • a cross-chain transaction between blockchains can mean that user A uses his assets in blockchain 1 to pay user B in blockchain 2 a number of assets in blockchain 2.
  • the cross-chain transaction may include two cross-chain transactions (the first transaction and the second transaction) that are related to each other, where the first transaction refers to user A deducting several assets, and the second transaction refers to user B adding several assets.
  • the implementation scheme in the prior art is as follows: determine an intermediate chain to play the role of an intermediary, user A initiates a transaction in blockchain 1, and when the intermediate chain determines that the first transaction is successfully executed on blockchain 1, Chain 2 initiates a transaction to execute the second transaction on Blockchain 2. If the second transaction fails for some reason, you need to cancel the successful transaction (first transaction), but the successful transaction may not be canceled , And then only part of the inter-related cross-chain transactions were successfully executed, while the other part was not executed successfully.
  • this application provides a cross-chain transaction method, which includes:
  • the first node determines that the transaction state of the first transaction is the first state, and the first state indicates that the transaction passes the consensus verification;
  • the first node obtains the transaction status of the second transaction
  • the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • obtaining the transaction status of the second transaction by the first node includes:
  • the first node obtains a first block on a third blockchain, wherein the first node and the third node maintain the third blockchain, and the first block includes the second transaction The status of the transaction.
  • the method further includes:
  • the first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
  • the method further includes:
  • the first node sends a fourth transaction to a third node, the fourth transaction includes timeout information, and the first node and the third node maintain the third blockchain;
  • the first node When the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information, the first node does not follow the first The transaction data of the transaction modifies the state machine of the first node.
  • the method further includes:
  • the first node receives transaction data of the first transaction
  • the determining that the transaction status of the first transaction is the first status includes:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the method further includes:
  • the first node determines whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the method further includes:
  • the first node sends a fourth transaction to the third node, and the fourth transaction includes the first transaction identifier of the first transaction.
  • the method further includes:
  • the first node broadcasts synchronization information to the fourth node, where the synchronization information is used to indicate that the first node has updated the state machine of the first node, and the first node and the fourth node belong to the same Node cluster.
  • this application provides a cross-chain transaction method, which includes:
  • the first node determines that the transaction state of the first transaction is the first state, and the first state indicates that the transaction passes the consensus verification;
  • the first node obtains the transaction status of the second transaction
  • the first node When the transaction state of the second transaction is the third state, the first node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the first node acquiring the transaction status of the second transaction includes:
  • the first node obtains a first block on a third blockchain, wherein the first node and the third node maintain the third blockchain, and the first block includes the second transaction The status of the transaction.
  • the method further includes:
  • the first node sends a third transaction to the third node, and the third transaction includes the transaction status of the first transaction.
  • the method further includes:
  • the first node sends a fourth transaction to a third node, the fourth transaction includes timeout information, and the first node and the third node maintain the third blockchain;
  • the first node When the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information, the first node does not follow the first The transaction data of the transaction modifies the state machine of the first node.
  • the method further includes:
  • the first node receives transaction data of the first transaction
  • the determining that the transaction status of the first transaction is the first status includes:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the method further includes:
  • the first node determines whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the method further includes:
  • the first node sends a fourth transaction to the third node, and the fourth transaction includes the first transaction identifier of the first transaction.
  • this application provides a cross-chain transaction device, the cross-chain transaction device includes:
  • a processing module configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification;
  • the obtaining module is used to obtain the transaction status of the second transaction
  • the processing module is further configured to modify the state machine of the first node according to the transaction data of the first transaction when the transaction state of the second transaction is the first state.
  • the acquisition module is specifically used for:
  • the cross-chain transaction device further includes:
  • the sending module is configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • the sending module is further configured to send a fourth transaction to a third node, where the fourth transaction includes timeout information, and the first node and the third node maintain The third blockchain;
  • the processing module is further configured to: when the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information, the first node A node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the device further includes:
  • a receiving module which is used to receive transaction data of the first transaction
  • the processing module is specifically used for:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the acquisition module is further used for:
  • the processing module is also used for:
  • the fourth block determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the acquisition module is further used for:
  • the sending module is also used for:
  • a fourth transaction is sent to the third node, where the fourth transaction includes the first transaction identifier of the first transaction.
  • the sending module is further used for:
  • Broadcast synchronization information to the fourth node where the synchronization information is used to indicate that the first node has updated the state machine of the first node, and the first node and the fourth node belong to the same node cluster.
  • this application provides a cross-chain transaction device, which includes:
  • a processing module configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification;
  • the obtaining module is used to obtain the transaction status of the second transaction
  • the processing module is further configured to: when the transaction state of the second transaction is the third state, the first node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the acquisition module is specifically used for:
  • the first transaction and the second transaction are interrelated cross-chain transactions.
  • the cross-chain transaction device further includes:
  • the sending module is configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • the sending module is further configured to send a fourth transaction to a third node, where the fourth transaction includes timeout information, and the first node and the third node maintain The third blockchain;
  • the processing module is further configured to: when the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information, the first node A node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the device further includes:
  • a receiving module which is used to receive transaction data of the first transaction
  • the processing module is specifically used for:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the acquisition module is further used for:
  • the processing module is also used for:
  • the fourth block determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the acquisition module is further used for:
  • the sending module is also used for:
  • a fourth transaction is sent to the third node, where the fourth transaction includes the first transaction identifier of the first transaction.
  • this application provides a cross-chain transaction method, which includes:
  • the first node obtains the first transaction identifier of the second transaction, the second transaction belongs to a transaction on the second blockchain, the second transaction and the first transaction are interrelated cross-chain transactions, and the first transaction For transactions on the first blockchain, the first node maintains the first blockchain;
  • the first node receives a first block sent by a third node, where the first block includes a second transaction identifier of a second transaction;
  • the first node determines whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the method further includes:
  • the first node sends the first transaction identifier of the second transaction to the third node.
  • the method further includes:
  • the first node sends the first transaction identifier of the first transaction to the third node.
  • the first block further includes a second transaction identifier of the first transaction
  • the method also includes:
  • the first node determines whether the first transaction identifier of the first transaction is equal to the second transaction identifier of the first transaction according to the first block.
  • this application provides a cross-chain transaction method, which includes:
  • the second node receives the second transaction identifier of the second transaction sent by the second node, the second node maintains a second blockchain, the first transaction and the second transaction are interrelated cross-chain transactions, the second The transaction is a transaction on the second blockchain;
  • the method further includes:
  • the second block further includes: a first transaction identifier of the second transaction.
  • the method further includes:
  • the first block further includes: a second transaction identifier of the first transaction.
  • this application provides a cross-chain transaction device, which is a cross-chain transaction device where the first node is located, and includes:
  • the acquiring module is used to acquire the first transaction identifier of the second transaction, the second transaction belongs to the transaction on the second blockchain, the second transaction and the first transaction are interrelated cross-chain transactions, and the first transaction A transaction is a transaction on the first blockchain, and the first node maintains the first blockchain; receiving the first block sent by the third node, the first block includes the second transaction identifier of the second transaction ;
  • the processing module is configured to determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction according to the first block.
  • the sending module is configured to send the first transaction identifier of the second transaction to the third node.
  • the acquisition module is further used for:
  • the sending module is further configured to send the first transaction identifier of the first transaction to the third node.
  • the first block further includes a second transaction identifier of the first transaction
  • the processing module is specifically configured to determine whether the first transaction identifier of the first transaction is equal to the second transaction identifier of the first transaction according to the first block.
  • this application provides a cross-chain transaction device, which is a cross-chain transaction device where a third node is located, and includes:
  • the receiving module is configured to receive the first transaction identifier of the first transaction sent by the first node, the first node maintains the first blockchain, and the first transaction is a transaction on the first blockchain; receiving the second The second transaction identifier of the second transaction sent by the node, the second node maintains a second blockchain, the first transaction and the second transaction are interrelated cross-chain transactions, and the second transaction is the State the transaction on the second blockchain;
  • a processing module configured to generate a first block, the first block including the second transaction identifier of the second transaction; generate a second block, the second block including the first transaction of the first Transaction identifier
  • the sending module is configured to send the first block to the first node; send the second block to the second node.
  • the receiving module is further configured to: receive the first transaction identifier of the second transaction sent by the first node;
  • the second block further includes: a first transaction identifier of the second transaction.
  • the receiving module is further configured to: receive the second transaction identifier of the first transaction sent by the second node;
  • the first block further includes: a second transaction identifier of the first transaction.
  • an embodiment of the present application provides a cross-chain transaction method, including:
  • Receive transaction data of a first transaction where the transaction data of the first transaction includes target transaction parameters.
  • transaction data of the second transaction includes the target transaction parameter, it is determined that the transaction status of the second transaction is invalid.
  • the first transaction and the third transaction are interrelated cross-chain transactions
  • the second transaction and the fourth transaction are interrelated cross-chain transactions
  • the first transaction The second transaction and the second transaction are transactions on the first blockchain
  • the third transaction and the fourth transaction are transactions on the second blockchain.
  • an embodiment of the present application provides a cross-chain transaction device, including:
  • the processing module is configured to determine that the transaction status of the second transaction is invalid if the transaction data of the second transaction includes the target transaction parameter.
  • the first transaction and the third transaction are interrelated cross-chain transactions
  • the second transaction and the fourth transaction are interrelated cross-chain transactions
  • the first transaction The second transaction and the second transaction are transactions on the first blockchain
  • the third transaction and the fourth transaction are transactions on the second blockchain.
  • an embodiment of the present application provides a cross-chain transaction device, including: a memory, a transceiver, a processor, and a bus system; wherein the memory is used to store programs and instructions; the transceiver is used to connect to the processor Receive or send information under the control of the computer; the processor is used to execute the program in the memory; the bus system is used to connect the memory, the transceiver, and the processor so that the memory, the transceiver, and the processor communicate The processor is used to call the program instructions in the memory to execute the method described in the first aspect, the second aspect, the fifth aspect, the sixth aspect, or the ninth aspect.
  • the embodiments of the present application provide a computer-readable storage medium that stores instructions in the computer-readable storage medium, and when it runs on a computer, the computer executes the first, second, and The method of the fifth, sixth or ninth aspect.
  • This application provides a cross-chain transaction method, including: a first node determines that the transaction state of a first transaction is a first state, the first state indicates that the transaction has passed consensus verification; the first node obtains the status of the second transaction Transaction status; when the transaction status of the second transaction is the first state, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • the embodiment of the present application provides a cross-chain transaction method, which can realize the atomic execution of the cross-chain transaction on multiple blockchains.
  • this application provides a cross-chain transaction method, which is applied to a first node, and the first node maintains a first blockchain, a first transaction belongs to the first blockchain, and the first transaction
  • the second transaction is a cross-chain transaction associated with the second transaction, the second transaction belongs to the second blockchain, the second node maintains the second blockchain, and the method includes: the first node determines the first transaction The transaction status of is the first status, and the first status indicates that the transaction passes the consensus verification; the first node obtains the transaction status of the second transaction; when the transaction status of the second transaction is the first status At the time, the first node modifies target data according to the transaction data of the first transaction, and the target data is data related to the first transaction in the state machine of the first node.
  • the node that maintains the blockchain participates in the construction of the blockchain, for example, it can perform at least one of the following actions: transaction generation, transaction data consensus, transaction-related smart contracts For the execution of the transaction-related block generation, and the modification of the target data in the transaction-related state machine, the node can obtain transaction data from the maintained blockchain, where the transaction data can indicate the specific content of the transaction or describe the transaction Details, for example, data that only indicate the status of the transaction, such as whether the transaction is successful, should not be understood as transaction data in this application.
  • the first transaction and the second transaction may be related. For example, the first transaction and the second transaction are different sub-transactions of the same transaction.
  • the transaction data of the first transaction and the second transaction have an identifier indicating that the two are associated, for example, they may have the same or associated identifier ID.
  • the first node can actively initiate the modification of the target data in the state machine of the first node based on the transaction status of the second transaction.
  • the target data can be the state machine of the first node and the first transaction. Fields related to transaction status, for example, target data may include one or more of the transaction data described above.
  • the target data can be the account balance, for example: A transfers X units of currency to B, the first transaction is that the account balance of A decreases by X units of currency, and the second transaction is that the account balance of B increases X units of currency, the target data is A's account balance;
  • the target data can be the invoice amount, for example: A invoices B with an amount of X units, and the first transaction is A to B An invoice with an amount of X units is issued, and the second transaction is that B receives an invoice with an amount of X units issued by A.
  • the target data is the amount invoiced by A to B; in the scenario of currency exchange goods, the target data can be Is the account balance or the quantity of goods, for example: A transfers X units of currency to B, and B transfers Y units of goods to A, then the first transaction is A’s account balance is reduced by X units of currency, and the second transaction To reduce Y units of goods for B, the target data is A's account balance.
  • obtaining the transaction status of the second transaction by the first node includes: obtaining the first block including the transaction status of the second transaction by the first node, so The first block comes from a third node, and the third node does not maintain the first block chain and the second block chain.
  • the third node does not maintain the first block chain and the second block chain, it can be understood that the third node cannot access the first block chain and the second block chain.
  • the third node does not maintain the first blockchain and the second blockchain, it can be understood that the third node cannot obtain data from the first blockchain. And acquiring transaction data of the first transaction and the second transaction from the second blockchain.
  • the third node does not provide hardware resources for the calculation of the first transaction and the calculation of the second transaction. It should be noted that if the third node does not maintain the first block chain and the second block chain, it can be understood that the third node does not perform the following actions: generation of the first transaction, generation of the second transaction, The consensus of the transaction data of the first transaction and the second transaction, the execution of the smart contract related to the first transaction and the second transaction, and the modification of the target data in the state machine related to the first transaction and the second transaction.
  • the method further includes:
  • the first node sends the transaction status of the first transaction to a third node, and the third node does not maintain the first block chain and the second block chain.
  • the sending of the transaction status of the first transaction by the first node to the third node includes:
  • the first node sends a third transaction to a third node, and the third transaction includes the transaction status of the first transaction.
  • the method further includes:
  • the first node sends a fifth transaction to a third node, the fifth transaction includes timeout information, and the timeout information is used to indicate that the third node has not received the second transaction from the second node trading status;
  • the first node When the first node does not obtain the transaction status of the second transaction, and obtains the second block including the timeout information on the third blockchain, the first node does not follow the The transaction data of a transaction modifies the target data related to the first transaction in the state machine of the first node.
  • the first node may not modify the target data related to the first transaction in the state machine of the first node based on the transaction data of the first transaction, and may modify the first transaction based on other information.
  • the target data related to the first transaction in the state machine of a node may also not modify the target data related to the first transaction in the state machine of the first node.
  • the method further includes:
  • the first node calculates the first hash of the second transaction, or receives the first hash of the second transaction sent by the first client, where the first client is the first The originating end of the transaction;
  • the first node receives the second hash of the second transaction sent by the third node;
  • the first hash of the second transaction is equal to the second hash of the second transaction, indicating that the transaction data of the second transaction is correct; the first hash of the second transaction is identical to the first hash of the second transaction.
  • the second hashes of the two transactions are not equal, which means that the transaction data of the second transaction is incorrect.
  • the method further includes:
  • the first node calculates the first hash of the first transaction, or receives the first hash of the first transaction sent by the first client;
  • the first node sends the first hash of the first transaction to the third node.
  • the method After the first node modifies the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction, the method also includes:
  • the first node broadcasts synchronization information to the fourth node, and the synchronization information is used to indicate that the first node has modified the state machine of the first node and the first node according to the transaction data of the first transaction.
  • the first node and the fourth node belong to the same node cluster.
  • this application provides a cross-chain transaction method, which includes:
  • the third node receives the transaction status of the second transaction sent by the second node, the second node maintains a second blockchain, and the second transaction belongs to the second blockchain;
  • the third node sends the transaction status of the second transaction to the first node, so that the first node processes the target data based on the transaction status of the second transaction and the transaction status of the first transaction, wherein the
  • the target data is data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are related cross-chain transactions, and the first transaction belongs to the first zone Block chain, the first node maintains the first block chain, and the third node does not maintain the first block chain and the second block chain.
  • the method further includes:
  • the third node generates a first block including the transaction status of the second transaction.
  • the method further includes:
  • the third node receives a transaction sent by at least one fifth node
  • the generation of the first block including the transaction status of the second transaction by the third node includes:
  • the transaction sent by the at least one fifth node and the transaction status of the second transaction is sorted to generate at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
  • the third node sending the transaction status of the second transaction to the first node includes:
  • the third node sends the first block to the first node.
  • the third node receiving the transaction status of the second transaction sent by the second node includes:
  • the third node receives a fourth transaction sent by the second node, and the fourth transaction includes the transaction status of the second transaction.
  • the method further includes:
  • the third node receives the second hash of the second transaction sent by the second node
  • the third node sends the second hash of the second transaction to the first node, so that the first node determines based on the second hash of the second transaction and the first hash of the second transaction
  • the correctness of the transaction data of the second transaction wherein the first hash of the second transaction is calculated by the first node or comes from the first client, and the first client is the The initiator of the first transaction.
  • this application provides a cross-chain transaction method applied to a cross-chain transaction system.
  • the cross-chain transaction system includes a first node, a second node, and a third node.
  • the first node maintains a first zone.
  • Block chain the first transaction belongs to the first blockchain, the first transaction and the second transaction are related cross-chain transactions, the second transaction belongs to the second blockchain, and the second node maintains the For the second block chain, the third node does not maintain the first block chain and the second block chain, and the method includes:
  • the first node determines that the transaction state of the first transaction is the first state, and the first state indicates that the transaction passes consensus verification;
  • the first node modifies target data according to the transaction data of the first transaction, and the target data is the state machine of the first node and Data related to the first transaction.
  • the method further includes:
  • the third node generates a first block including the transaction status of the second transaction.
  • the method further includes:
  • the third node receives a transaction sent by at least one fourth node
  • the generation of the first block including the transaction status of the second transaction by the third node includes:
  • the transaction sent by the at least one fifth node and the transaction status of the second transaction is sorted to generate at least one block, where the first block is one of the at least one block, and the first block includes the transaction status of the second transaction.
  • the third node sending the transaction status of the second transaction to the first node includes:
  • the third node sends the first block to the first node.
  • the second node sending the transaction status of the second transaction to the third node includes:
  • the second node sends a fourth transaction to the third node, and the fourth transaction includes the transaction status of the second transaction.
  • the first node sending the transaction status of the first transaction to the third node includes:
  • the first node sends a third transaction to a third node, and the third transaction includes the transaction status of the first transaction.
  • the method further includes:
  • the first node calculates the first hash of the second transaction, or receives the first hash of the second transaction sent by the first client, where the first client is the first The originating end of the transaction;
  • the third node receives the second hash of the second transaction sent by the second node
  • the first node receives the second hash of the second transaction sent by the third node;
  • the first hash of the second transaction is equal to the second hash of the second transaction, indicating that the transaction data of the second transaction is correct; the first hash of the second transaction is identical to the first hash of the second transaction.
  • the second hashes of the two transactions are not equal, which means that the transaction data of the second transaction is incorrect.
  • the cross-chain transaction system further includes a fourth node, the first node and the fourth node belong to the same node cluster, and the first node After the transaction data of the transaction modifies the target data related to the first transaction in the state machine of the first node, the method further includes:
  • the first node broadcasts synchronization information to the fourth node, and the synchronization information is used to indicate that the first node has modified the state machine of the first node and the first node according to the transaction data of the first transaction.
  • Target data related to the transaction is used to indicate that the first node has modified the state machine of the first node and the first node according to the transaction data of the first transaction.
  • the present application provides a first node that maintains a first blockchain, a first transaction belongs to the first blockchain, and the first transaction and the second transaction are related The second transaction belongs to the second blockchain, the second node maintains the second blockchain, and the first node includes:
  • a processing module configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification;
  • the processing module is further configured to: when the transaction status of the second transaction is the first status, the first node modifies target data according to the transaction data of the first transaction, and the target data is the Data related to the first transaction in the state machine of the first node.
  • the acquisition module is specifically used for:
  • the first node further includes:
  • the sending module is configured to send the transaction status of the first transaction to a third node, and the third node does not maintain the first block chain and the second block chain.
  • the sending module is specifically used for:
  • the first node sends a third transaction to a third node, and the third transaction includes the transaction status of the first transaction.
  • the processing module is further used for:
  • the first hash of the second transaction is calculated, or the receiving module is specifically configured to receive the first hash of the second transaction sent by the first client, where the first client is the The originating end of the first transaction;
  • the receiving module is specifically configured to receive the second hash of the second transaction sent by the third node;
  • the first hash of the second transaction is equal to the second hash of the second transaction, indicating that the transaction data of the second transaction is correct; the first hash of the second transaction is identical to the first hash of the second transaction.
  • the second hashes of the two transactions are not equal, which means that the transaction data of the second transaction is incorrect.
  • the processing module is further used for:
  • the first hash of the first transaction is calculated, or the receiving module is specifically configured to receive the first hash of the first transaction sent by the first client;
  • the sending module is further configured to send the first hash of the first transaction to the third node.
  • the sending module is further used for:
  • the synchronization information being used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction ,
  • the first node and the fourth node belong to the same node cluster.
  • this application provides a third node, where the third node includes:
  • a receiving module configured to receive the transaction status of a second transaction sent by a second node, the second node maintains a second blockchain, and the second transaction belongs to the second blockchain;
  • the sending module is configured to send the transaction status of the second transaction to the first node, so that the first node processes the target data based on the transaction status of the second transaction and the transaction status of the first transaction, wherein the The target data is data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are related cross-chain transactions, and the first transaction belongs to the first zone Block chain, the first node maintains the first block chain, and the third node does not maintain the first block chain and the second block chain.
  • the third node further includes:
  • the processing module is used to generate the first block including the transaction status of the second transaction.
  • the receiving module is further used for:
  • the processing module is specifically used for:
  • the transaction sent by the at least one fifth node and the transaction status of the second transaction are sorted to generate at least A block, where the first block is one of the at least one block, and the first block includes the transaction state of the second transaction.
  • the sending module is specifically used for:
  • the receiving module is specifically used for:
  • a fourth transaction sent by the second node is received, where the fourth transaction includes the transaction status of the second transaction.
  • the receiving module is further used for:
  • the sending module is also used for:
  • an embodiment of the present application provides a cross-chain transaction device, including: a memory, a transceiver, a processor, and a bus system; wherein, the memory is used to store programs and instructions; the transceiver is used to connect to the processor Receiving or sending information under control; the processor is used to execute the program in the memory; the bus system is used to connect the memory, the transceiver, and the processor, so that the memory, the transceiver, and the processor communicate; The processor is used to call the program instructions in the memory to execute the methods described in the first and second aspects above.
  • the embodiments of the present application provide a computer-readable storage medium that stores instructions in the computer-readable storage medium, which when run on a computer, causes the computer to execute the above-mentioned first and second aspects Methods.
  • This application provides a cross-chain transaction method applied to a first node, the first node maintains a first blockchain, a first transaction belongs to the first blockchain, and the second transaction belongs to a second zone Block chain, the second node maintains the second block chain, the method includes: the first node determines that the transaction status of the first transaction is a first state, and the first state indicates that the transaction passes consensus verification; The first node obtains the transaction status of the second transaction; when the transaction status of the second transaction is the first status, the first node modifies the target data according to the transaction data of the first transaction, so The target data is data related to the first transaction in the state machine of the first node.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • Figure 1 is a schematic diagram of an embodiment of a cross-chain transaction method
  • FIG. 2 is a schematic diagram of the architecture of a blockchain network provided by this application.
  • Figure 3 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • Figure 4 is a schematic diagram of an application example of a cross-chain transaction method
  • FIG. 5 is a schematic diagram of the architecture of a blockchain network according to an embodiment of the application.
  • FIG. 6 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • Figure 7a is a schematic diagram of the dependency relationship of a cross-chain transaction
  • Figure 7b is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • FIG. 8 is a schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the application.
  • FIG. 9 is a schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the application.
  • FIG. 10 is a schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the application.
  • FIG. 11 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • Figure 12a is a schematic diagram of an application example of a cross-chain transaction method
  • Figure 12b is a schematic diagram of an application example of a cross-chain transaction method
  • FIG. 13 is a schematic diagram of the architecture of a blockchain network according to an embodiment of the application.
  • FIG. 14 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • Figure 15a is a schematic diagram of the dependency relationship of a cross-chain transaction
  • Figure 15b is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application.
  • 16 is a schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the application.
  • Figure 17 is a schematic diagram of an embodiment of a cross-chain transaction device in an embodiment of the application.
  • FIG. 18 is a schematic structural diagram of a cross-chain transaction device in an embodiment of the application.
  • FIG. 19 is a schematic diagram of a server structure provided in an embodiment of this application.
  • the embodiments of the present application provide a cross-chain transaction method and device, which can enable cross-chain transactions to be executed atomically on multiple blockchains.
  • Blockchain can specifically refer to a P2P network system with a distributed data storage structure that is reached by each node through a consensus mechanism.
  • the data in the blockchain is distributed in time-connected “blocks" Within “, the next block contains the data summary of the previous block, and according to the specific consensus mechanism (such as POW, POS, DPOS or PBFT, etc.), a full backup of all or part of the node data is achieved.
  • the blockchain can include public chains, alliance chains, private chains, etc. In actual applications, especially for the actual application of the alliance chain, separate blockchains are usually set up for different scenarios, such as the blockchain used to process housing rental business scenarios, and the business scenarios used to process copyright use of music works.
  • Figure 1 is a schematic diagram of an embodiment of a cross-chain transaction method. As shown in Figure 1, the cross-chain transaction method includes:
  • the first blockchain executes the first transaction and generates blocks.
  • the second blockchain verifies the block, and determines whether the first transaction is successfully executed on the first blockchain.
  • the second blockchain triggers the third blockchain to execute the second transaction.
  • the third blockchain executes the second transaction.
  • the third blockchain fails to execute the second transaction for some reasons, the successful transaction (first transaction) needs to be canceled. If the first transaction may not be canceled, there will be interrelated cross-chains. A situation where only part of the transaction (the first transaction and the second transaction) (the first transaction) is successfully executed, and the other part (the second transaction) is not successfully executed.
  • execution success refers to the update of the corresponding state machine based on the transaction data.
  • execution success refers to the update of the corresponding state database based on the transaction data.
  • the embodiment of the present application provides a cross-chain transaction method. After determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state of the first node according to the first state. Instead, it receives the transaction state of the second transaction, and when the transaction state of the second transaction is the first state, modify the state machine of the first node so that the execution of the cross-chain sub-transaction does not only depend on The consensus verification result of the first transaction also needs to consider the consensus verification results of other related cross-chain transactions. There will be no cases where only part of the inter-related cross-chain transactions are successfully executed while the other part is not successfully executed. Cross-chain transactions are executed atomically on multiple blockchains.
  • FIG. 2 is a schematic diagram of the architecture of a blockchain network provided by this application.
  • the blockchain network provided by this application includes: a blockchain 1 network, a blockchain 2 network, a blockchain 3 network 30, a first client 130, and a second client 230.
  • the blockchain 1 network includes a node cluster 110 and a node cluster 120.
  • the node cluster 110 includes multiple node peers
  • the node cluster 120 includes multiple node peers, and these node peers jointly maintain the blockchain 1.
  • the blockchain 2 network includes a node cluster 210 and a node cluster 220, where the node cluster 210 includes multiple node peers, and the node cluster 220 includes multiple node peers, and these node peers jointly maintain the blockchain 2.
  • the blockchain 3 network 30 includes a node cluster 310, a node cluster 110, and a node cluster 210.
  • the node cluster 310 includes multiple node peers
  • the node cluster 110 includes multiple node peers
  • the node cluster 210 includes multiple node peers. Node peers jointly maintain the blockchain 3.
  • the node cluster 110 can maintain either the blockchain 1 or the blockchain 3.
  • the node cluster 210 can maintain both the blockchain 2 and the blockchain 3, which is equivalent to the node cluster 110 and can obtain the block
  • the data contained in the chain 1 can also be obtained from the data contained in the blockchain 3, and the node cluster 210 can obtain the data contained in the blockchain 2 or the data contained in the blockchain 3.
  • the user can initiate a transaction at the first client 130, and the first client 130 can generate corresponding transaction information and send it to the cluster 110 via the network.
  • the cluster 110 includes multiple first nodes, and the first node can serve as an endorsement.
  • the node endorses the transaction information, and sends an endorsement response to the first client 130 via the network.
  • the first client 130 may verify the endorsement response, and send transaction information and endorsement response to the node cluster 120.
  • the cluster 120 may be a sorting cluster, including multiple sorting nodes, and the sorting node may perform global processing on the received transaction data. Sorting, combining a batch of sorted transaction data to generate a block, and transmitting the block to the cluster 110.
  • the first node can determine the validity of the transaction by verifying the block, and send the validity of the transaction to the cluster 310.
  • the user can initiate a transaction on the second client 230, and the second client 230 can generate corresponding transaction information and send it to the cluster 210 via the network.
  • the cluster 210 includes multiple second nodes, which can serve as endorsing nodes. , Endorse the transaction information, and send an endorsement response to the second client 230 via the network.
  • the second client 230 may verify the endorsement response, and send transaction information and endorsement response to the node cluster 220, where the cluster 220 may be a sorting cluster, including multiple sorting nodes, and the sorting node may perform global globalization on the received transaction data Sorting, combining a batch of sorted transaction data to generate a block, and transmitting the block to the cluster 210.
  • the first node can determine the validity of the transaction by verifying the block, and send the validity of the transaction to the cluster 310.
  • the cluster 310 may be a sorting cluster, including multiple third nodes.
  • the third node may be a sorting node.
  • the sorting node may sort the received transaction data globally, combine a batch of sorted transaction data to generate a block, and combine The blocks are transmitted to cluster 110 and cluster 210.
  • the cluster 110 may send the transaction result to the first client 130 via the network, and the cluster 210 may send the transaction result to the second client 230 via the network.
  • the blockchain stores a list of transactions in units of blocks.
  • the blocks in the blockchain are generated in chronological order, and each block is used to record a list of transactions generated within a period of time.
  • the list of all transactions recorded on the blockchain is the ledger.
  • the ledger recorded on blockchain 1 is ledger 1
  • the ledger recorded on blockchain 2 is ledger 2
  • the ledger recorded on blockchain 3 is ledger3, in this application, without causing ambiguity, ledger and blockchain are equivalent concepts that can replace each other.
  • one node in the blockchain network is on one physical machine (server), or more than one node in multiple blockchain networks
  • Nodes are on the same server.
  • a node can specifically refer to a process or a series of processes running in the server.
  • a node in the blockchain 1 network and a node in the blockchain 2 network can run on the same server Two processes.
  • the node described in this application may refer to the server where the node is located.
  • the blockchain network includes a cluster of ordering nodes and a maintainable area.
  • the cross-chain transaction method provided in this application can be applied to a multi-chain system composed of multiple blockchains.
  • the multi-chain system of each embodiment of this specification may include multiple homogeneous blockchains that follow the same basic blockchain protocol, or may include heterogeneous blockchains that follow different basic blockchain protocols.
  • the architecture of the above multiple blockchains is not limited to the main chain-side chain architecture, the main chain-multi-sub-chain architecture or the parallel multi-chain architecture.
  • Fig. 3 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application. As shown in Fig. 3, the cross-chain transaction method includes:
  • the first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes consensus verification.
  • the first transaction and the second transaction are interrelated cross-chain transactions, where the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain .
  • the cross-chain transaction when a user initiates a cross-chain transaction at the first client, the cross-chain transaction includes two cross-chain sub-transactions (the first transaction and the second transaction) that are related to each other.
  • the user can implement transaction operations through the first client terminal.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation.
  • the transaction operation may be an operation that causes the ledger status of the first blockchain and the second blockchain to change.
  • Transaction data may include, but is not limited to, user identification, transaction parameters (for example, transaction amount), transaction time, and the like.
  • the first client terminal may generate transaction information of the first transaction based on transaction data corresponding to the first transaction.
  • the transaction information may include a transaction identifier, a contract identifier of a contract to be invoked by the transaction, contract method, transaction data, and client signature.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client.
  • the transaction information of the second transaction may be generated based on the transaction data corresponding to the second transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, transaction data, and client signature.
  • the above transaction identification can be generated by the client.
  • the transaction identifier can be used to distinguish and determine the operations performed on the transaction account.
  • the above transaction identification may be a string composed of numbers and letters.
  • a hash function can be used to process the operations performed on the account book corresponding to the exchange, the transaction data, etc., and the obtained hash value is used as the transaction identifier of the transaction.
  • the first client may use a hash function to process information such as operations performed on the account book corresponding to the first exchange, transaction data of the first transaction, and other information, and use the obtained hash value as the transaction of the first transaction.
  • a hash function to process information such as operations performed on the account book corresponding to the first exchange, transaction data of the first transaction, and other information, and use the obtained hash value as the transaction of the first transaction.
  • the second client can perform the same or similar actions as the first client, and the repetition will not be repeated.
  • the above client signature may be a signature generated by the first client using its own private key.
  • the private key of the first client can be a hash value generated using a hash algorithm, or a random number generated using a random number function.
  • the above-mentioned contract identifier refers to the identifier of the smart contract that each node in the blockchain complies with.
  • the aforementioned smart contract may be an application running on the blockchain network.
  • the above smart contracts are also called chain codes.
  • Chain code includes system chain code and user chain code.
  • System chain code is used to implement system-level functions, including system configuration, user chain code deployment and upgrade, user transaction signature and verification strategy, etc.
  • the user chain code realizes the user's application function.
  • the chain code can be compiled into a standalone application.
  • the transaction data indicated by the transaction information initiated by the client needs to be verified by one or more endorsing nodes.
  • the first client may send the transaction information to the endorsing node in the first node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the first transaction.
  • the foregoing endorsement node may be preset by the first client.
  • the first client before sending the transaction information of the first transaction to the endorsing node, the first client can call the endorsement strategy in the smart contract to determine the transaction of the first transaction from the nodes included in the first node cluster At least one endorsement node where the information is endorsed. That is, in these application scenarios, the above-mentioned endorsement node may be selected by the first client from the nodes included in the first node cluster based on a preset endorsement strategy.
  • the endorsing node After the endorsing node receives the transaction information of the first transaction sent by the first client, it will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates the transaction result including the execution return value, the read operation set and the write operation set.
  • the endorsement node may package the read operation set and write operation set, the endorsement result (pass or fail), and the endorsement signature of the endorsement node to generate an endorsement response.
  • the endorsement response may also include the identification of the client corresponding to the transaction information and the transaction identification.
  • the endorsement signature of the aforementioned endorsing node can be generated by the endorsing node according to its corresponding private key.
  • the private key of the endorsing node may be a hash value generated by a hash algorithm, or a random number generated by a random number generation function.
  • the endorsement node may send multiple endorsement responses to the client.
  • the first client can receive the endorsement response sent by each endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the above-mentioned first client may combine the client identifier and transaction identifier included in the transaction information generated according to the user operation with the client in the received endorsement response sent by the preset endorsement node The identification and the transaction identification are matched, and if the matching is successful, it is further determined whether the endorsement response meets the preset rules.
  • the first client may determine whether the endorsement response includes information that the endorsement result of the transaction information of the first transaction by the endorsing node is passed, and if it is determined that the endorsement response includes a preset endorsement node pair If the endorsement result of the transaction information of the first transaction is passed information, it is determined that the endorsement response conforms to the preset rule; or it is determined whether the number of endorsement nodes corresponding to the endorsement response received and the indicated endorsement result passed is greater than or equal to the expected endorsement response. Set a threshold.
  • the endorsement response is whether the endorsement node corresponding to the passed endorsement response includes the endorsement node whose weight is greater than the preset weight threshold; if it is determined that the received endorsement result is passed, the endorsement node corresponding to the endorsement response includes the weight greater than The endorsement node with the preset weight threshold determines that the endorsement response meets the preset rules.
  • each endorsement response includes an endorsement signature of an endorsement node, that is, the first client can receive multiple endorsement signatures .
  • the first client may send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster.
  • the nodes included in the second node cluster maintain the first blockchain
  • the second node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server.
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the multiple sorting nodes included in the second node cluster can globally sort the received transaction data, and combine a batch of sorted transaction data to generate a block structure.
  • the above-mentioned block structure may include but is not limited to the following data: the hash value corresponding to the current block number and obtained according to the hash algorithm, the hash value corresponding to the previous block number, the timestamp, and Multiple transaction data.
  • one or more ordering nodes in the second node cluster When one or more ordering nodes in the second node cluster receive N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, it can At least one sorting node generates corresponding M blocks and sorts the M blocks, and transmits the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and passes the verification The blocks of are added to the corresponding blockchain in turn.
  • the nodes in the first node cluster may receive the third block, and the third block includes transaction data of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that, for the convenience of description, the nodes in the first node cluster are described as the first node below.
  • the first node receives the transaction data including the first transaction and the blocks with multiple endorsement signatures corresponding to the first transaction, and can perform consensus verification on the third block. Specifically, the first node may verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the transaction state of the first transaction is the first state, and the first state indicates that the transaction passes the consensus verification.
  • the transaction state that can be determined is the third state, and the third state indicates that the transaction fails the consensus verification.
  • the first node may add the third block to the first block chain, and mark the transaction status of the first transaction in the third block.
  • the third block is added to the corresponding blockchain, So that it will not block the execution of subsequent transactions.
  • the first node if the first node passes the consensus verification of the block, it will be marked as valid in the field related to the transaction status of the first transaction in the block, and the first transaction will be executed. , The first node can update the state database corresponding to the first transaction (for example, account balance and transaction time, etc.). At this time, if the transaction status of the subsequent second transaction is invalid, since the data related to the first transaction in the state database corresponding to the first transaction has been updated and effective, the first transaction has been executed at this time, but the second transaction has not carried out.
  • the state database corresponding to the first transaction for example, account balance and transaction time, etc.
  • the first node when the first node determines that the first transaction passes the consensus verification, it can mark the field related to the transaction status of the first transaction as valid pending pending in the third block, and the first node is not modified State machine.
  • the first node determines that the transaction status of the first transaction is the third state (for example: invalid), it can be in the field related to the transaction status of the first transaction in the third block It is marked as invalid.
  • the first node may send a third transaction to a third node of the third node cluster, and the third transaction includes the transaction status of the first transaction.
  • the third transaction may include transaction status indication information, and the transaction status indication information may indicate the transaction status of the first transaction.
  • the transaction status indication information may be a character string.
  • the transaction status indication information can be pending or other character strings that can indicate that the consensus verification is passed.
  • the validity indication information can be invalid or Other strings that can indicate that the consensus check fails.
  • the nodes included in the third node cluster maintain the third blockchain
  • the third node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the third node cluster may also receive the transaction status of the second transaction sent by the second node, where the transaction status of the second transaction is determined by the second node and sent to the third node cluster.
  • multiple sorting nodes included in the third node cluster can perform a global sorting for the received transactions, and combine a batch of sorted transaction data to generate a block structure.
  • the third node cluster may generate a second block, and the second block includes the transaction status of the first transaction and the transaction status of the second transaction.
  • transaction status of the first transaction and the transaction status of the second transaction can be on the same block or on different blocks, which is not limited here.
  • the first node obtains the transaction status of the second transaction.
  • the first node may obtain the first block on the third blockchain, wherein the first node and the third node maintain the third blockchain, and the first block includes The transaction status of the second transaction.
  • the transaction state of the second transaction may be the first state or the third state, where the first state indicates that the transaction passes the consensus verification, and the third state indicates that the transaction fails the consensus verification.
  • the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the first node obtains the transaction status of the second transaction, and can then determine whether the transaction status of the second transaction is the first state or the third state, and when the transaction status of the second transaction is the first state In the state, modify the state machine of the first node according to the transaction data of the first transaction.
  • the first node can determine that the transaction status of the first transaction is the first state. For example, the transaction status of the first transaction can be marked as pending.
  • the first node determines that the transaction status of the second transaction is also pending, it can update the block of the first transaction to mark its transaction status as valid, and modify the transaction data of the first node according to the transaction data of the first transaction. state machine.
  • the first node obtains the transaction status of the second transaction, and can then determine whether the transaction status of the second transaction is the first state or the third state, and when the transaction status of the second transaction is the third In the state, the state machine of the first node is not modified according to the transaction data of the first transaction.
  • the first node can determine that the transaction status of the first transaction is the first state. For example, the transaction status of the first transaction can be marked as pending.
  • the first node determines that the transaction status of the second transaction is invalid, it can update the block of the first transaction marking its transaction status as invalid, and at the same time, it does not modify the first transaction based on the transaction data of the first transaction.
  • the state machine of the node can update the block of the first transaction marking its transaction status as invalid, and at the same time, it does not modify the first transaction based on the transaction data of the first transaction.
  • cross-chain transaction including the first transaction and the second transaction is used as an example for description.
  • the cross-chain transaction may also include more than two transactions.
  • the specific embodiment mode can refer to the above-mentioned embodiment, which will not be repeated here.
  • ordinary transactions and cross-chain transactions may have a certain dependency relationship. Specifically, there may be a certain dependency relationship between the transaction data of ordinary transactions and cross-chain transactions, which needs to be pointed out.
  • the ordinary transaction in this embodiment is a transaction that can be executed independently.
  • cross-chain transaction A there is a cross-chain transaction: cross-chain transaction A and ordinary transaction A, and cross-chain transaction A includes the first transaction and the second transaction.
  • the first transaction needs to update the balance of the A account, and the ordinary transaction A also needs to update the balance of the A account.
  • the first transaction is before the third transaction in sequence.
  • the ordinary transaction A can only be executed after the first transaction is completed.
  • the execution of the first transaction depends on the results of the first transaction and the second transaction.
  • the transaction time may be very long, so the waiting time of ordinary transaction A may be very long. long.
  • the third transaction is a normal transaction, that is, a transaction that can be completed independently, rather than a cross-chain transaction.
  • the transaction data includes the target transaction parameters.
  • the transaction data of the first transaction also includes the target transaction parameters, and the execution sequence corresponding to the third transaction is after the execution sequence of the first transaction. Change the expression method.
  • the node first receives the block in which the first transaction is located, or, if the block in which the first transaction and the third transaction are in the same block, the third transaction is after the first transaction in this block.
  • the waiting time for the third transaction may be very long.
  • the first node can directly determine that the transaction status of the third transaction is the third status.
  • the method further includes:
  • the first node broadcasts synchronization information to the fourth node, where the synchronization information is used to indicate that the first node has updated the state machine of the first node, and the first node and the fourth node belong to the same Node cluster.
  • the first node determines the transaction status of the first transaction, and executes or does not execute the first transaction according to the transaction status of the first transaction (modify the first node according to the transaction data of the first transaction)
  • the synchronization information of the first node completing the first transaction can be sent to the second node cluster, and the second node cluster can generate synchronization information including
  • nodes in the first node cluster except the first node (fourth node) can receive the block including synchronization information sent by the second node cluster.
  • a node (fourth node) in the first node cluster other than the first node may also send the synchronization information of the first node completing the first transaction to the second node cluster, and the second node cluster may generate the synchronization information including the synchronization information. Blocks, and sort the blocks.
  • the first node determines the transaction status of the first transaction, executes or does not execute the first transaction according to the transaction status of the first transaction, and receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can determine The first transaction has been completed in other nodes, and it can be considered that the first transaction does not affect the third transaction and the third transaction can be performed normally.
  • the first node has not yet determined the transaction status of the first transaction, but receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has been completed in other nodes, and then it can be considered as the first transaction.
  • the first transaction does not affect the third transaction, and the third transaction can be carried out normally.
  • the first node determines the transaction status of the first transaction, but does not receive the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed in other nodes, and then it can be considered as the first transaction.
  • the transaction may affect the third transaction, and the first node can directly determine that the transaction status of the third transaction is the third state.
  • the first node has not determined the transaction status of the first transaction, and has not received the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed in other nodes, and then it can be considered as the first transaction.
  • a transaction may affect the third transaction, and the first node can directly determine that the transaction status of the third transaction is the third state.
  • This application provides a cross-chain transaction method, including: a first node determines that the transaction state of a first transaction is a first state, the first state indicates that the transaction has passed consensus verification; the first node obtains the status of the second transaction Transaction status; when the transaction status of the second transaction is the first state, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • Figure 4 is a schematic diagram of an application example of a cross-chain transaction method. Specifically, the cross-chain transaction method includes:
  • the first client terminal receives a user's transaction operation.
  • the transaction operation may be an operation that causes the state of the ledger of the first blockchain and the second blockchain to change.
  • the first client terminal generates transaction data.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation, where the transaction data may include, but is not limited to, user identification, transaction parameters (such as transaction amount), transaction time, etc.
  • the first client sends the transaction data to the second client.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client
  • the first client terminal generates transaction information.
  • the first client may generate transaction information of the first transaction based on transaction data corresponding to the first transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, the transaction data, and Client signature, etc.
  • the second client terminal generates transaction information.
  • the second client may generate transaction information of the second transaction based on the transaction data corresponding to the second transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, the transaction data, and Client signature, etc.
  • the first client sends a transaction request to the first endorsement node.
  • the first endorsing node may be a part or all of the nodes in the first node cluster.
  • the first client can send the transaction information to the endorsing node in the first node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the first transaction.
  • the second client sends a transaction request to the second endorsement node.
  • the second endorsing node may be a part or all of the nodes in the second node cluster.
  • the second client can send the transaction information to the endorsing node in the second node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the second transaction.
  • the first endorsement node performs endorsement.
  • the first endorsing node after receiving the transaction information of the first transaction sent by the first client, the first endorsing node will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the first endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates a transaction result including the execution return value, read operation set and write operation set.
  • the first endorsement node can package the foregoing read operation set and write operation set, endorsement result (pass or fail), and endorsement signature of the endorsement node to generate an endorsement response.
  • the second endorsement node performs endorsement.
  • the second endorsing node after the second endorsing node receives the transaction information of the second transaction sent by the second client, it will call the relevant code in the smart contract to simulate and execute the second transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the second transaction as input, simulates the execution of the second transaction on its corresponding ledger, and generates the transaction result including the execution return value, read operation set and write operation set.
  • the second endorsement node can package the foregoing read operation set and write operation set, endorsement result (pass or fail), and endorsement signature of the endorsement node to generate an endorsement response.
  • the first endorsement node sends an endorsement response to the first client.
  • the second endorsement node sends an endorsement response to the first client.
  • the first client passes the verification.
  • the first client may receive the endorsement response sent by the first endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the second client passes the verification.
  • the second client may receive the endorsement response sent by the second endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the first client sends the transaction information and signature to the first ordering node.
  • the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses may be sent to the first order node.
  • the second client sends the transaction information and signature to the second ordering node.
  • the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses may be sent to the second Sort node.
  • the first ordering node generates a block.
  • the second ordering node generates a block.
  • the first ordering node sends the block to the first node.
  • the A sorting node when the first ordering node receives N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, the A sorting node generates corresponding M blocks, sorts the M blocks, and transmits the M blocks to the first node.
  • the second ordering node sends the block to the second node.
  • the second ordering node when the second ordering node receives the N transaction information (including at least the transaction information of the second transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the second client, the second ordering node can be The second sorting node generates corresponding M blocks, sorts the M blocks, and transmits the M blocks to the second node.
  • the first node verifies the block and determines the transaction status of the first transaction.
  • the first node receives the transaction information including the first transaction and the block with multiple endorsement signatures corresponding to the first transaction, and can verify the block. Specifically, the first node may verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the second node verifies the block and determines the transaction status of the second transaction.
  • the second node receives the transaction information including the second transaction and the block with multiple endorsement signatures corresponding to the second transaction, and can verify the block. Specifically, the second node can verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the first node sends the transaction status of the first transaction to the third node.
  • the second node sends the transaction status of the second transaction to the third node.
  • the third node generates blocks and sorts them.
  • the third node sends the block to the first node.
  • the third node sends the block to the second node.
  • the third node cluster when the first ordering node receives N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the endorsement responses of multiple first transactions) transmitted by the first client, and After the transaction information of the second transaction and the multiple endorsement signatures included in the endorsement responses of multiple second transactions), the third node cluster can generate corresponding M blocks and sort the M blocks, and then M The block is transmitted to the first node and the second node.
  • N transaction information including at least the transaction information of the first transaction and the multiple endorsement signatures included in the endorsement responses of multiple first transactions
  • the third node cluster can generate corresponding M blocks and sort the M blocks, and then M The block is transmitted to the first node and the second node.
  • the first node determines the transaction status of the first transaction according to the transaction status of the first transaction and the transaction status of the second transaction.
  • the second node determines the transaction status of the second transaction according to the transaction status of the first transaction and the transaction status of the second transaction.
  • the first node determines whether to execute or not execute the first transaction according to the transaction status of the first transaction.
  • the second node determines whether to execute or not execute the second transaction according to the transaction status of the second transaction.
  • the first node sends the execution result to the first client.
  • the second node sends the execution result to the second client.
  • the first node determines the execution or non-execution of the first transaction according to the transaction status of the first transaction
  • the second node determines the execution or non-execution of the first transaction according to the transaction status of the second transaction
  • the first blockchain can be the Ethereum chain.
  • the first node can deploy the first node on the Ethereum chain after determining that the transaction status of the first transaction is the first state. A transaction, and lock the first transaction. After receiving the transaction status of the second transaction sent by the third node cluster, when the transaction status of the second transaction is the first status, determine the first transaction The transaction status of is in the second state, and when the first transaction is in the second state, the first transaction is executed.
  • the first node in this application may not belong to the Ethereum chain, but a node of a newly-added distributed node cluster.
  • the first node may instruct the Ethereum chain to perform a rollback on the first transaction, that is, instruct The Ethereum chain does not execute the first transaction.
  • the first transaction is executed.
  • the first node may instruct the Ethereum chain to unlock the first transaction, that is, instruct the Ethereum chain to execute The first transaction.
  • first block chain is the fabric chain and the second block chain is the Ethereum chain
  • first block chain executes the execution steps of the fabric chain in the above embodiment
  • second block chain executes the above The implementation steps of the Ethereum chain in the embodiment.
  • the first blockchain or the second blockchain may also be a Bitcoin chain, which is not limited here.
  • FIG. 5 is a schematic diagram of the architecture of a blockchain network according to an embodiment of the application.
  • the blockchain network includes: a blockchain 4 network 40 and a blockchain 2 network 20 , Blockchain 3 network 30, first client 130, second client 230, and node cluster 510, where the blockchain corresponding to blockchain 4 network 40 is the Ethereum chain.
  • the specific description of the blockchain 2 network 20 and the second client 230 can refer to the description of the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the blockchain 4 network 40 includes a node cluster 410, and the node cluster 410 includes multiple node peers, and these node peers jointly maintain the Ethereum chain.
  • the node cluster 510 includes multiple node peers. Unlike the architecture shown in FIG. 1, the blockchain 3 network 30 does not include the node cluster 110. At this time, the node cluster 510 can complete the function of the node cluster 110, that is, the node cluster 510 The function of the node cluster 110 can be provided as an adapter.
  • the user can initiate a transaction at the first client 130, and the first client 130 can generate corresponding transaction information and send it to the cluster 510 via the network.
  • the cluster 510 includes multiple first nodes, and the first node is determining the transaction. After the transaction status of is in the first state, the first node can deploy the transaction on the node cluster 410, and accordingly, the node cluster 410 can lock the transaction. The first node may also send the transaction status of the first transaction to the cluster 310.
  • the second node may send the transaction status of the second transaction to the cluster 310.
  • the cluster 310 may be a sorting cluster, including multiple third nodes.
  • the third node may be a sorting node.
  • the sorting node may sort the received transaction data globally, combine a batch of sorted transaction data to generate a block, and combine The blocks are transmitted to cluster 510 and cluster 210.
  • the cluster 510 may determine the transaction status of the transaction according to the received block, and when the transaction status is the second state, instruct the node cluster 410 to execute the transaction, and when the transaction status is the third state, instruct the node cluster 410 to execute the transaction rollback. That is, the transaction is not executed.
  • the cross-chain transaction includes multiple related cross-chain sub-transactions, such as the first transaction and the second transaction. If the first transaction is the transfer of 10 units of currency from user A to user B, then the first transaction Subtract 10 units of currency from the balance of account A on the first blockchain, and the second transaction is the balance of account B on the second blockchain plus 10 units of currency.
  • the transaction initiated by the first client and the second client may be untrue, for example, the transaction initiated by the first client is the first blockchain The balance of the upper account A minus 10 units of currency, and the second transaction is the balance of the account B on the second blockchain plus 20 units of currency, which will destroy the existing data logical relationship and is unacceptable.
  • this application provides a cross-chain transaction method.
  • Fig. 6 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application. As shown in Fig. 6, the cross-chain transaction method includes:
  • the first node obtains the first transaction identifier of the second transaction.
  • the first transaction and the second transaction are interrelated cross-chain transactions, where the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain .
  • the cross-chain transaction when a user initiates a cross-chain transaction at the first client, the cross-chain transaction includes two cross-chain sub-transactions (the first transaction and the second transaction) that are related to each other.
  • the user can implement transaction operations through the first client terminal.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation.
  • the transaction operation may be an operation that causes the ledger status of the first blockchain and the second blockchain to change.
  • Transaction data may include, but is not limited to, user identification, transaction parameters (for example, transaction amount), transaction time, and the like.
  • the first client terminal may generate transaction information of the first transaction based on transaction data corresponding to the first transaction, and the transaction information may include the first transaction identifier hash (tx1) of the first transaction.
  • the transaction identifier can be used to distinguish and determine the operations performed on the transaction account.
  • the first transaction identifier hash (tx1) of the first transaction described above may be a character string composed of numbers and letters.
  • a hash function can be used to process the operations performed on the account book corresponding to the exchange, the transaction data, etc., and the obtained hash value is used as the transaction identifier of the transaction.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client.
  • the transaction information of the second transaction may be generated based on the transaction data corresponding to the second transaction.
  • the transaction information may include the second transaction identifier hash (tx2) of the second transaction. Since the transaction identifier can distinguish and determine the operations performed on the transaction account, Therefore, the second transaction identifier hash (tx2) of the second transaction generated by the second client can uniquely indicate the content of the second transaction execution.
  • the first client generates the first transaction identifier exp_hash (tx2) of the second transaction in addition to the first transaction identifier hash (tx1) of the first transaction.
  • the first client may obtain the first transaction identifier exp_hash(tx2) of the second transaction "supposedly" generated by the second client by calling the helper chain code.
  • the first client after the first client generates transaction data corresponding to the second transaction according to the user's transaction operation, it can use the transaction data as input to generate the first transaction identifier exp_hash(tx2) of the second transaction by calling the assistant chain code,
  • the first transaction identifier exp_hash(tx2) of the second transaction may indicate the transaction identifier uniquely corresponding to the second transaction that the second client should execute.
  • the first client may not obtain the first transaction identifier exp_hash(tx2) of the second transaction by querying the assistant chain code, but obtain the second transaction identifier exp_hash(tx2) by communicating with the second client
  • the client should execute the chain code and parameters, and calculate the first transaction identifier exp_hash(tx2) of the second transaction.
  • the first client may send the transaction information to the endorsing node in the first node cluster.
  • the transaction information of the first transaction includes the first transaction identifier exp_hash (tx2) and the first transaction identifier hash (tx1) of the first transaction.
  • the endorsing node After the endorsing node receives the transaction information of the first transaction sent by the first client, it will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates the transaction result including the execution return value, the read operation set and the write operation set.
  • the endorsement node may package the read operation set and write operation set, the endorsement result (pass or fail), and the endorsement signature of the endorsement node to generate an endorsement response.
  • the endorsement response may also include the identifier of the client corresponding to the transaction information, the first transaction identifier exp_hash (tx2) and the first transaction identifier hash (tx1) of the first transaction.
  • the endorsement node may send multiple endorsement responses to the client.
  • the first client can receive the endorsement response sent by each endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the first client after the first client determines that the endorsement response meets the preset rules, it can send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster, where the first transaction
  • the transaction information includes the first transaction identifier exp_hash (tx2) and the first transaction identifier hash (tx1) of the first transaction.
  • the nodes included in the second node cluster maintain the first blockchain
  • the second node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server.
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the multiple sorting nodes included in the second node cluster can globally sort the received transaction data, and combine a batch of sorted transaction data to generate a block structure.
  • one or more ordering nodes in the second node cluster When one or more ordering nodes in the second node cluster receive N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, it can At least one sorting node generates corresponding M blocks and sorts the M blocks, and transmits the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and passes the verification The blocks of are added to the corresponding blockchain in turn.
  • the nodes in the first node cluster may receive a block including transaction information of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that, for the convenience of description, the node in the first node cluster is described as the first node below.
  • the first node receives the transaction information including the first transaction and the block with multiple endorsement signatures corresponding to the first transaction, and can verify the block. Regarding how the first node verifies the block, refer to the above-mentioned embodiment, which will not be repeated here.
  • the first node may send a fourth transaction to the third node.
  • the fourth transaction includes the first transaction identifier hash (tx1) of the first transaction.
  • the fourth transaction includes the first transaction of the second transaction.
  • the nodes included in the third node cluster maintain the third blockchain
  • the third node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the third node cluster may also receive the second transaction identifier hash (tx2) of the second transaction and the second transaction identifier exp_hash (tx1) of the first transaction sent by the second node.
  • the third node cluster may also receive the fifth transaction sent by the second node, and the fifth transaction may include the second transaction identifier hash(tx2) of the second transaction and the second transaction identifier exp_hash(tx1 ).
  • the multiple sorting nodes included in the third node cluster can perform global sorting for the received transactions, and combine a batch of sorted transaction data to generate a block structure.
  • the third node cluster can generate a fourth block.
  • the fourth block includes the second transaction identifier hash (tx2) of the second transaction and the second transaction identifier exp_hash (tx1) of the first transaction.
  • the fourth block also It may include the first transaction identifier exp_hash (tx2) of the second transaction and the first transaction identifier hash (tx1) of the first transaction.
  • the second transaction identifier hash (tx2) of the second transaction can be in the same block or in different blocks, which is not limited here.
  • the first node obtains a fourth block on the third blockchain, where the fourth block includes a second transaction identifier of a second transaction.
  • the first node may obtain the fourth block on the third blockchain, and the fourth block may include the second transaction identifier hash (tx2) of the second transaction, and the second transaction
  • the second transaction identifier hash (tx2) is the transaction identifier corresponding to the actual execution of the second transaction, which can uniquely indicate the transaction data of the second transaction in specific execution.
  • the fourth block may also include the second transaction identifier exp_hash(tx1) of the first transaction.
  • the second node may receive the fifth block sent by the third node cluster, and the fifth block may include the first transaction identifier hash (tx1) of the first transaction, where the first transaction identifier hash of the first transaction (tx1) is the transaction identifier corresponding to the actual execution of the first transaction, which can uniquely indicate the transaction data of the first transaction in specific execution.
  • the fifth block may also include the first transaction identifier exp_hash(tx2) of the second transaction.
  • the first node can receive the block sent by the third node cluster, and the block includes the first node.
  • the first node determines whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction according to the fourth block.
  • the first node can determine whether the second transaction identifier hash (tx2) of the second transaction is equal to the first transaction identifier exp_hash (tx2) of the second transaction, and then determine whether the second transaction is in accordance with the correct transaction Data execution.
  • the first transaction identifier exp_hash(tx2) of the second transaction is generated by the first client through the transaction data of the second transaction, it can represent the transaction data that the first client thinks that the second transaction should be executed.
  • the second transaction identifier hash (tx2) of the second transaction indicates the transaction data of the actual execution of the second transaction.
  • the second node can determine whether the first transaction identifier hash (tx1) of the first transaction is equal to the second transaction identifier exp_hash (tx1) of the first transaction to determine whether the first transaction is executed according to the correct transaction data.
  • the second transaction identifier exp_hash(tx1) of the first transaction is generated by the second client through the transaction data of the first transaction, it can represent transaction data that the second client thinks that the first transaction should be executed.
  • the first transaction identifier hash (tx1) of the first transaction represents the transaction data of the first transaction actually executed.
  • the first node can determine the first transaction identifier hash(tx1) of the first transaction and the second transaction of the first transaction Identify whether exp_hash(tx1) is equal, and then obtain the judgment result of the second node.
  • the second node can determine the second transaction identifier hash(tx2) of the second transaction and the first transaction identifier exp_hash(tx2) of the second transaction. ) Is equal, and then the judgment result of the first node is obtained.
  • the first node determines that the second transaction identifier hash (tx2) of the second transaction is equal to the first transaction identifier exp_hash (tx2) of the second transaction, the first node can determine that the second transaction is in accordance with the correct Transaction data execution.
  • the second node determines that the first transaction identifier hash (tx1) of the first transaction is equal to the second transaction identifier exp_hash (tx1) of the first transaction, the second node can determine that the first transaction is in accordance with the correct Transaction data execution.
  • the first transaction can be executed.
  • the first node determines that the first transaction is not executed according to correct transaction data, and the second transaction is executed according to correct transaction data, the first transaction is not executed.
  • the first node determines that the first transaction is executed according to the correct transaction data, and the second transaction is not executed according to the correct transaction data, the first transaction is not executed.
  • the second transaction can be executed.
  • the second node determines that the first transaction is not executed according to correct transaction data, and the second transaction is executed according to correct transaction data, the second transaction is not executed.
  • the second node determines that the first transaction is executed according to the correct transaction data, and the second transaction is not executed according to the correct transaction data, the second transaction is not executed.
  • the first transaction is the transfer of 10 units of currency from user A to user B
  • the first transaction is the balance of account A on the first blockchain minus 10 units of currency
  • the second transaction is the first transaction. 2.
  • the first client generates the first transaction identifier hash (tx1) of the first transaction based on the transaction data of the first transaction (including the balance of the A account on the first blockchain minus 10 units of currency), and based on The transaction data of the second transaction (including the balance of the B account on the second blockchain plus 10 units of currency) generates the first transaction identifier exp_hash(tx2) of the second transaction.
  • the second client generates the second transaction identifier exp_hash(tx1) of the first transaction based on the transaction data of the first transaction (including the balance of the A account on the first blockchain minus 10 units of currency), and based on the first transaction
  • the transaction data of the second transaction (including the balance of the B account on the second blockchain plus 20 units of currency) generates the second transaction identifier hash (tx2) of the second transaction, that is, the second client wants to add to the B account More currencies.
  • the first node will receive the second transaction identifier hash (tx2) of the second transaction sent by the third node, because the second transaction identifier hash (tx2) is different from the first transaction identifier exp_hash (tx2) of the second transaction , The first node will determine that the transaction data executed by the second transaction is incorrect, that is, if the second client is fraudulent, the first transaction will not be executed.
  • the embodiment of the application provides a cross-chain transaction method, including: the first node obtains the first transaction identifier of the second transaction; the first node obtains the fourth area on the third blockchain Block, the fourth block includes the second transaction identifier of the second transaction; the first node determines the first transaction identifier of the second transaction and the first transaction identifier of the second transaction according to the fourth block 2. Whether the transaction identifiers are equal.
  • the first node can determine whether the second transaction is executed according to the correct transaction data by determining whether the second transaction identifier of the second transaction is equal to the first transaction identifier of the second transaction, and the second transaction If it is not executed according to the correct transaction data, the first transaction will not be executed.
  • each cross-chain transaction may have a certain dependency relationship. Specifically, there is a certain dependency relationship between the transaction data of each cross-chain transaction. For example, there are two cross-chain transactions.
  • Chain transaction cross-chain transaction A and cross-chain transaction B
  • cross-chain transaction A includes the first transaction and second transaction
  • cross-chain transaction B includes the third transaction and fourth transaction
  • the first transaction and the third transaction are the first area
  • the transactions on the blockchain the second transaction and the fourth transaction are transactions on the second blockchain.
  • the first transaction needs to update the balance of the A account
  • the third transaction also needs to update the balance of the A account.
  • the first transaction is before the third transaction in time sequence.
  • the second transaction needs to update the balance of the B account, and the fourth transaction also needs to update the balance of the B account.
  • the second transaction is after the fourth transaction in time sequence.
  • the third transaction can only be executed after the first transaction is completed.
  • the first transaction and the second transaction belong to the same cross-chain transaction, and the execution of the first transaction needs to depend on the execution result of the second transaction.
  • the second transaction can only be executed after the fourth transaction is completed.
  • the fourth transaction and the third transaction belong to the same cross-chain transaction, and the execution of the fourth transaction needs to depend on the execution result of the third transaction.
  • Figure 7a is a schematic diagram of a cross-chain transaction dependency relationship.
  • the first transaction A1 and the second transaction B1 belong to the same cross-chain transaction
  • the third transaction A2 and the fourth transaction B2 belongs to the same cross-chain transaction.
  • the first transaction A1 and the third transaction A2 have a timing dependency, that is, the third transaction A2 can be executed after the first transaction A1 is executed
  • the fourth transaction B2 and the second transaction B1 have a timing dependency Relationship, that is, the second transaction B1 can be executed after the execution of the fourth transaction B2 is completed.
  • the first transaction A1, the second transaction B1, the third transaction A2, and the fourth transaction B2 have the problem of transaction deadlock.
  • FIG. 7b is a schematic diagram of an embodiment of a cross-chain transaction method provided by an embodiment of the application.
  • the cross-chain transaction method provided in this embodiment includes:
  • the first node receives transaction data of a first transaction, where the transaction data of the first transaction includes target transaction parameters.
  • the first node receives transaction data of the second transaction.
  • transaction data of the second transaction includes the target transaction parameter, determine that the transaction status of the second transaction is invalid.
  • the first transaction and the third transaction are interrelated cross-chain transactions
  • the second transaction and the fourth transaction are interrelated cross-chain transactions
  • the first transaction and The second transaction is a transaction on the first blockchain
  • the third transaction and the fourth transaction are transactions on the second blockchain.
  • the first transaction is the balance of account A minus 5 units of currency
  • the second transaction is the balance of account A minus 10 units of currency
  • the third transaction is the balance of account B plus 5 units of currency
  • the fourth transaction Add 10 units of currency to the balance of account B.
  • the transaction data of the first transaction includes the target transaction parameter "A account”
  • the transaction data of the second transaction includes the target transaction parameter "A account”
  • the first node can directly determine that the transaction status of the second transaction is invalid, and proceed The second transaction is not executed, that is, the state database corresponding to the second transaction is not updated.
  • FIG. 8 is a schematic diagram of an embodiment of the cross-chain transaction device in the embodiment of the application.
  • the cross-chain transaction device 800 in the embodiment of the present application includes:
  • the processing module 801 is configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes consensus verification;
  • the obtaining module 802 is used to obtain the transaction status of the second transaction
  • the processing module 801 is further configured to: when the transaction status of the second transaction is the first state, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the processing module 801 determines that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification; the acquisition module 802 acquires the transaction status of the second transaction; the processing module 801 is When the transaction state of the second transaction is the first state, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • the obtaining module 802 is specifically configured to obtain the first block on the third blockchain, wherein the first node and the third node maintain the third blockchain, and the first block The block includes the transaction status of the second transaction.
  • the cross-chain transaction device further includes: a sending module 803, configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • a sending module 803 configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • the sending module 803 is further configured to send a fourth transaction to a third node, where the fourth transaction includes timeout information, and the first node and the third node maintain the third blockchain;
  • the processing module 801 is further configured to: when the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information When the first node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the cross-chain transaction device further includes: a receiving module 804, specifically used for:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the obtaining module 802 is also used for:
  • the processing module 801 is also used for:
  • the fourth block determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the obtaining module 802 is also used for:
  • the sending module 803 is also used for:
  • a fourth transaction is sent to the third node, where the fourth transaction includes the first transaction identifier of the first transaction.
  • the sending module 803 is further configured to:
  • Broadcast synchronization information to the fourth node where the synchronization information is used to indicate that the first node has updated the state machine of the first node, and the first node and the fourth node belong to the same node cluster.
  • FIG. 8 is a schematic diagram of an embodiment of the cross-chain transaction device in the embodiment of the application.
  • the cross-chain transaction device 800 in the embodiment of the present application includes:
  • the processing module 801 is configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification;
  • the obtaining module 802 is used to obtain the transaction status of the second transaction
  • the processing module 801 is further configured to: when the transaction state of the second transaction is the third state, the first node does not modify the state machine of the first node according to the transaction data of the first transaction .
  • the obtaining module 802 is specifically configured to obtain the first block on the third blockchain, wherein the first node and the third node maintain the third blockchain, and the first block The block includes the transaction status of the second transaction.
  • the cross-chain transaction device further includes: a sending module 803, configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • a sending module 803 configured to send a third transaction to the third node, where the third transaction includes the transaction status of the first transaction.
  • the sending module 803 is further configured to send a fourth transaction to a third node, where the fourth transaction includes timeout information, and the first node and the third node maintain the third blockchain;
  • the processing module 801 is further configured to: when the first node does not obtain the transaction status of the second transaction, and obtains the second block on the third blockchain that includes the timeout information , The first node does not modify the state machine of the first node according to the transaction data of the first transaction.
  • the cross-chain transaction device further includes: a receiving module 804, specifically used for:
  • the first node performs consensus verification on the first transaction
  • the first node determines that the transaction state of the first transaction is the first state
  • the first node adds a third block to the first block chain, where the third block includes transaction data of the first transaction, and the first node maintains the first block chain .
  • the obtaining module 802 is also used for:
  • the processing module 801 is also used for:
  • the fourth block determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction.
  • the obtaining module 802 is also used for:
  • the sending module 803 is also used for:
  • a fourth transaction is sent to the third node, where the fourth transaction includes the first transaction identifier of the first transaction.
  • FIG. 9 is a schematic diagram of an embodiment of the cross-chain transaction device in an embodiment of the application.
  • the cross-chain transaction device 900 in the embodiment of the present application includes:
  • the obtaining module 901 is configured to obtain a first transaction identifier of a second transaction, the second transaction belongs to a transaction on a second blockchain, and the second transaction and the first transaction are interrelated cross-chain transactions, the The first transaction is a transaction on the first blockchain, and the first node maintains the first blockchain; receiving the first block sent by the third node, and the first block includes the second transaction of the second transaction Logo
  • the processing module 902 is configured to determine whether the first transaction identifier of the second transaction is equal to the second transaction identifier of the second transaction according to the first block.
  • the cross-chain transaction device 900 further includes: a sending module 903, configured to send the first transaction identifier of the second transaction to the third node.
  • the obtaining module 901 is further configured to: obtain a first transaction identifier of the first transaction;
  • the sending module 903 is further configured to send the first transaction identifier of the first transaction to the third node.
  • the first block further includes a second transaction identifier of the first transaction
  • the processing module 902 is specifically configured to determine whether the first transaction identifier of the first transaction is equal to the second transaction identifier of the first transaction according to the first block.
  • FIG. 10 is a schematic diagram of an embodiment of the cross-chain transaction device in the embodiment of the application.
  • the cross-chain transaction device 1000 in the embodiment of the present application includes:
  • the receiving module 1001 is configured to receive a first transaction identifier of a first transaction sent by a first node, the first node maintains a first blockchain, and the first transaction is a transaction on the first blockchain;
  • the processing module 1002 is configured to generate a first block, the first block including the second transaction identifier of the second transaction; generate a second block, the second block including the first transaction 1. Transaction identification;
  • the sending module 1003 is configured to send the first block to the first node; send the second block to the second node.
  • the receiving module 1001 is further configured to: receive the first transaction identifier of the second transaction sent by the first node;
  • the second block further includes: a first transaction identifier of the second transaction.
  • the receiving module 1001 is further configured to: receive the second transaction identifier of the first transaction sent by the second node;
  • the first block further includes: a second transaction identifier of the first transaction.
  • Figure 11 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application. As shown in Figure 11, the cross-chain transaction method includes:
  • the first node determines that the transaction status of the first transaction is a first status, and the first status indicates that the transaction passes consensus verification.
  • the first transaction and the second transaction are interrelated cross-chain transactions, where the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain .
  • the first transaction is a transaction belonging to the first blockchain, which can be understood as a transaction operation of the first transaction that can cause a change in the ledger status of the first blockchain.
  • the second transaction is a transaction on the second blockchain, it can be understood that the transaction operation of the second transaction can lead to a change in the ledger status of the second blockchain.
  • the cross-chain transaction when a user initiates a cross-chain transaction at the first client, the cross-chain transaction includes two cross-chain sub-transactions (the first transaction and the second transaction) that are related to each other.
  • the user can implement transaction operations through the first client terminal.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation.
  • the transaction operation may be an operation that causes the ledger status of the first blockchain and the second blockchain to change.
  • Transaction data may include, but is not limited to, user identification, transaction parameters (for example, transaction amount), transaction time, and the like.
  • the first client terminal may generate transaction information of the first transaction based on transaction data corresponding to the first transaction.
  • the transaction information may include a transaction identifier, a contract identifier of a contract to be invoked by the transaction, contract method, transaction data, and client signature.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client.
  • the transaction information of the second transaction may be generated based on the transaction data corresponding to the second transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, transaction data, and client signature.
  • the above transaction identification can be generated by the client.
  • the transaction identifier can be used to distinguish and determine the operations performed on the transaction account.
  • the above transaction identification may be a string composed of numbers and letters.
  • a hash function can be used to process the operations performed on the account book corresponding to the exchange, the transaction data, etc., and the obtained hash value is used as the transaction identifier of the transaction.
  • the first client may use a hash function to process information such as operations performed on the account book corresponding to the first exchange, transaction data of the first transaction, and other information, and use the obtained hash value as the transaction of the first transaction.
  • a hash function to process information such as operations performed on the account book corresponding to the first exchange, transaction data of the first transaction, and other information, and use the obtained hash value as the transaction of the first transaction.
  • the second client can perform the same or similar actions as the first client, and the repetition will not be repeated.
  • the above client signature may be a signature generated by the first client using its own private key.
  • the private key of the first client can be a hash value generated using a hash algorithm, or a random number generated using a random number function.
  • the above-mentioned contract identifier refers to the identifier of the smart contract that each node in the blockchain complies with.
  • the aforementioned smart contract may be an application running on the blockchain network.
  • the above smart contracts are also called chain codes.
  • Chain code includes system chain code and user chain code.
  • System chain code is used to implement system-level functions, including system configuration, user chain code deployment and upgrade, user transaction signature and verification strategy, etc.
  • the user chain code realizes the user's application function.
  • the chain code can be compiled into a standalone application.
  • the transaction data indicated by the transaction information initiated by the client needs to be verified by one or more endorsing nodes.
  • the first client may send the transaction information to the endorsing node in the first node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the first transaction.
  • the foregoing endorsement node may be preset by the first client.
  • the first client before sending the transaction information of the first transaction to the endorsing node, the first client can call the endorsement strategy in the smart contract to determine the transaction of the first transaction from the nodes included in the first node cluster At least one endorsement node where the information is endorsed. That is to say, in these application scenarios, the aforementioned endorsement node can be selected by the first client from the nodes included in the first node cluster based on a preset endorsement strategy.
  • the endorsing node After the endorsing node receives the transaction information of the first transaction sent by the first client, it will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates the transaction result including the execution return value, the read operation set and the write operation set.
  • the endorsement node may package the read operation set and write operation set, the endorsement result (pass or fail), and the endorsement signature of the endorsement node to generate an endorsement response.
  • the endorsement response may also include the identification of the client corresponding to the transaction information and the transaction identification.
  • the endorsement signature of the aforementioned endorsing node can be generated by the endorsing node according to its corresponding private key.
  • the private key of the endorsing node may be a hash value generated by a hash algorithm, or a random number generated by a random number generation function.
  • the endorsement node may send multiple endorsement responses to the client.
  • the first client can receive the endorsement response sent by each endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the above-mentioned first client may combine the client identifier and transaction identifier included in the transaction information generated according to the user operation with the client in the received endorsement response sent by the preset endorsement node The identification and the transaction identification are matched, and if the matching is successful, it is further determined whether the endorsement response meets the preset rules.
  • the first client may determine whether the endorsement response includes information that the endorsement result of the transaction information of the first transaction by the endorsing node is passed, and if it is determined that the endorsement response includes a preset endorsement node pair If the endorsement result of the transaction information of the first transaction is passed information, it is determined that the endorsement response conforms to the preset rule; or it is determined whether the number of endorsement nodes corresponding to the endorsement response received and the indicated endorsement result passed is greater than or equal to the expected endorsement response. Set a threshold.
  • the endorsement response is whether the endorsement node corresponding to the passed endorsement response includes the endorsement node whose weight is greater than the preset weight threshold; if it is determined that the received endorsement result is passed, the endorsement node corresponding to the endorsement response includes the weight greater than The endorsement node with the preset weight threshold determines that the endorsement response meets the preset rules.
  • each endorsement response includes an endorsement signature of an endorsement node, that is, the first client can receive multiple endorsement signatures .
  • the first client may send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster.
  • the nodes included in the second node cluster maintain the first blockchain
  • the second node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server.
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the multiple sorting nodes included in the second node cluster can globally sort the received transaction data, and combine a batch of sorted transaction data to generate a block structure.
  • the above-mentioned block structure may include but is not limited to the following data: the hash value corresponding to the current block number and obtained according to the hash algorithm, the hash value corresponding to the previous block number, the timestamp, and Multiple transaction data.
  • one or more ordering nodes in the second node cluster When one or more ordering nodes in the second node cluster receive N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, it can At least one sorting node generates corresponding M blocks and sorts the M blocks, and transmits the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and passes the verification The blocks of are added to the corresponding blockchain in turn.
  • the nodes in the first node cluster may receive the third block, and the third block includes transaction data of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that, for the convenience of description, the nodes in the first node cluster are described as the first node below.
  • the first node receives the transaction data including the first transaction and the blocks with multiple endorsement signatures corresponding to the first transaction, and can perform consensus verification on the third block. Specifically, the first node may verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the transaction state of the first transaction is the first state, and the first state indicates that the transaction passes the consensus verification.
  • the transaction state that can be determined is the third state, and the third state indicates that the transaction fails the consensus verification.
  • the first node may add the third block to the first block chain, and mark the transaction status of the first transaction in the third block.
  • the third block is added to the corresponding blockchain, So that it will not block the execution of subsequent transactions.
  • the first node if the first node passes the consensus verification of the block, it will be marked as valid in the field related to the transaction status of the first transaction in the block, and the first transaction will be executed. , The first node can update the state database corresponding to the first transaction (for example, account balance and transaction time, etc.). At this time, if the transaction status of the subsequent second transaction is invalid, since the data related to the first transaction in the state database corresponding to the first transaction has been updated and effective, the first transaction has been executed at this time, but the second transaction has not carried out.
  • the state database corresponding to the first transaction for example, account balance and transaction time, etc.
  • the first node when the first node determines that the first transaction passes the consensus verification, it can mark the field related to the transaction status of the first transaction as valid pending pending in the third block, and the first node is not modified State machine.
  • the first node determines that the transaction status of the first transaction is the third state (for example: invalid), it can be in the field related to the transaction status of the first transaction in the third block It is marked as invalid.
  • the first node may send a third transaction to a third node of the third node cluster, and the third transaction includes the transaction status of the first transaction.
  • the third transaction may include transaction status indication information, and the transaction status indication information may indicate the transaction status of the first transaction.
  • the transaction status indication information may be a character string.
  • the transaction status indication information can be pending or other character strings that can indicate that the consensus verification is passed.
  • the validity indication information can be invalid or Other strings that can indicate that the consensus check fails.
  • the nodes included in the third node cluster maintain the third blockchain
  • the third node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the third node cluster may also receive the transaction status of the second transaction sent by the second node, where the transaction status of the second transaction is determined by the second node and sent to the third node cluster.
  • multiple sorting nodes included in the third node cluster can perform a global sorting for the received transactions, and combine a batch of sorted transaction data to generate a block structure.
  • the third node cluster may generate the first block, and the first block includes the transaction status of the first transaction and the transaction status of the second transaction.
  • transaction status of the first transaction and the transaction status of the second transaction can be on the same block or on different blocks, which is not limited here.
  • the first node obtains the transaction status of the second transaction.
  • the first node may obtain the first block on the third blockchain, and the first block includes the transaction status of the second transaction.
  • the transaction state of the second transaction may be the first state or the third state, where the first state indicates that the transaction passes the consensus verification, and the third state indicates that the transaction fails the consensus verification.
  • the first node may receive the first block including the transaction status of the second transaction sent by the third node.
  • the first node modifies target data according to the transaction data of the first transaction, and the target data is the state machine of the first node Data related to the first transaction.
  • the first node obtains the transaction status of the second transaction, and can then determine whether the transaction status of the second transaction is the first state or the third state, and when the transaction status of the second transaction is the first state In the state, modify the state machine of the first node according to the transaction data of the first transaction.
  • the first node can determine that the transaction status of the first transaction is the first state. For example, the transaction status of the first transaction can be marked as pending.
  • the first node determines that the transaction status of the second transaction is also pending, it can update the block of the first transaction to mark its transaction status as valid, and modify the transaction data of the first node according to the transaction data of the first transaction. state machine.
  • the first node obtains the transaction status of the second transaction, and can then determine whether the transaction status of the second transaction is the first state or the third state, and when the transaction status of the second transaction is the third In the state, the state machine of the first node is not modified according to the transaction data of the first transaction.
  • the first node can determine that the transaction status of the first transaction is the first state. For example, the transaction status of the first transaction can be marked as pending.
  • the first node determines that the transaction status of the second transaction is invalid, it can update the block of the first transaction marking its transaction status as invalid, and at the same time, it does not modify the first transaction based on the transaction data of the first transaction.
  • the state machine of the node can update the block of the first transaction marking its transaction status as invalid, and at the same time, it does not modify the first transaction based on the transaction data of the first transaction.
  • cross-chain transaction including the first transaction and the second transaction is used as an example for description.
  • the cross-chain transaction may also include more than two transactions.
  • the specific embodiment mode can refer to the above-mentioned embodiment, which will not be repeated here.
  • ordinary transactions and cross-chain transactions may have a certain dependency relationship. Specifically, there may be a certain dependency relationship between the transaction data of ordinary transactions and cross-chain transactions, which needs to be pointed out.
  • the ordinary transaction in this embodiment is a transaction that can be executed independently.
  • cross-chain transaction A there is a cross-chain transaction: cross-chain transaction A and ordinary transaction A, and cross-chain transaction A includes the first transaction and the second transaction.
  • the first transaction needs to update the balance of the A account, and the ordinary transaction A also needs to update the balance of the A account.
  • the first transaction is before the third transaction in sequence.
  • the ordinary transaction A can only be executed after the first transaction is completed.
  • the execution of the first transaction depends on the results of the first transaction and the second transaction.
  • the transaction time may be very long, so the waiting time of ordinary transaction A may be very long. long.
  • the third transaction is a normal transaction, that is, a transaction that can be completed independently, rather than a cross-chain transaction.
  • the transaction data includes the target transaction parameters.
  • the transaction data of the first transaction also includes the target transaction parameters, and the execution sequence corresponding to the third transaction is after the execution sequence of the first transaction. Change the expression method.
  • the node first receives the block in which the first transaction is located, or, if the block in which the first transaction and the third transaction are in the same block, the third transaction is after the first transaction in this block.
  • the waiting time for the third transaction may be very long.
  • the first node can directly determine that the transaction status of the third transaction is the third status.
  • the method further includes:
  • the first node broadcasts synchronization information to the fourth node, where the synchronization information is used to indicate that the first node has updated the state machine of the first node, and the first node and the fourth node belong to the same Node cluster.
  • the first node determines the transaction status of the first transaction, and executes or does not execute the first transaction according to the transaction status of the first transaction (modify the first node according to the transaction data of the first transaction)
  • the synchronization information of the first node completing the first transaction can be sent to the second node cluster, and the second node cluster can generate synchronization information including
  • nodes in the first node cluster except the first node (fourth node) can receive the block including synchronization information sent by the second node cluster.
  • a node (fourth node) in the first node cluster other than the first node may also send the synchronization information of the first node completing the first transaction to the second node cluster, and the second node cluster may generate the synchronization information including the synchronization information. Blocks, and sort the blocks.
  • the first node determines the transaction status of the first transaction, executes or does not execute the first transaction according to the transaction status of the first transaction, and receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can determine The first transaction has been completed in other nodes, and it can be considered that the first transaction does not affect the third transaction and the third transaction can be performed normally.
  • the first node has not yet determined the transaction status of the first transaction, but receives the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has been completed in other nodes, and then it can be considered as the first transaction.
  • the first transaction does not affect the third transaction, and the third transaction can be carried out normally.
  • the first node determines the transaction status of the first transaction, but does not receive the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed in other nodes, and then it can be considered as the first transaction.
  • the transaction may affect the third transaction, and the first node can directly determine that the transaction status of the third transaction is the third state.
  • the first node has not determined the transaction status of the first transaction, and has not received the synchronization information of the first transaction sent by other nodes in the first node cluster, it can be determined that the first transaction has not been completed in other nodes, and then it can be considered as the first transaction.
  • a transaction may affect the third transaction, and the first node can directly determine that the transaction status of the third transaction is the third state.
  • This application provides a cross-chain transaction method, including: a first node determines that the transaction state of a first transaction is a first state, the first state indicates that the transaction has passed consensus verification; the first node obtains the status of the second transaction Transaction status; when the transaction status of the second transaction is the first state, the first node modifies the state machine of the first node according to the transaction data of the first transaction.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • Figure 12a is a schematic diagram of an application example of a cross-chain transaction method.
  • the cross-chain transaction method includes:
  • the first node determines that the transaction state of the first transaction is the first state
  • the second node determines that the transaction status of the second transaction is the first status
  • the first node sends the transaction status of the second transaction.
  • the second node sends the transaction status of the second transaction.
  • the third node generates a block including the transaction status of the first transaction.
  • the third node generates a block including the transaction status of the second transaction.
  • the third node sends the transaction status of the second transaction
  • the third node sends the transaction status of the first transaction.
  • the first node modifies the target data according to the transaction data of the first transaction
  • the second node modifies the target data according to the transaction data of the first transaction.
  • steps 4011 to 4052 reference may be made to the above-mentioned embodiment, which will not be repeated here.
  • Figure 12b is a schematic diagram of an application example of a cross-chain transaction method.
  • the cross-chain transaction method includes:
  • the first client terminal receives a user's transaction operation.
  • the transaction operation may be an operation that causes the state of the ledger of the first blockchain and the second blockchain to change.
  • the first client terminal generates transaction data.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation, where the transaction data may include, but is not limited to, user identification, transaction parameters (such as transaction amount), transaction time, etc.
  • the first client sends the transaction data to the second client.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client
  • the first client terminal generates transaction information.
  • the first client may generate transaction information of the first transaction based on transaction data corresponding to the first transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, the transaction data, and Client signature, etc.
  • the second client terminal generates transaction information.
  • the second client may generate transaction information of the second transaction based on the transaction data corresponding to the second transaction.
  • the transaction information may include the transaction identifier, the contract identifier of the contract to be invoked by the transaction, the contract method, the transaction data, and Client signature, etc.
  • the first client sends a transaction request to the first endorsement node.
  • the first endorsing node may be a part or all of the nodes in the first node cluster.
  • the first client can send the transaction information to the endorsing node in the first node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the first transaction.
  • the second client sends a transaction request to the second endorsement node.
  • the second endorsing node may be a part or all of the nodes in the second node cluster.
  • the second client can send the transaction information to the endorsing node in the second node cluster.
  • smart contracts can be pre-installed on each endorsing node.
  • the endorsing node can call the smart contract to verify the second transaction.
  • the first endorsement node performs endorsement.
  • the first endorsing node after receiving the transaction information of the first transaction sent by the first client, the first endorsing node will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the first endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates a transaction result including the execution return value, read operation set and write operation set.
  • the first endorsement node can package the foregoing read operation set and write operation set, endorsement result (pass or fail), and endorsement signature of the endorsement node to generate an endorsement response.
  • the second endorsement node performs endorsement.
  • the second endorsing node after the second endorsing node receives the transaction information of the second transaction sent by the second client, it will call the relevant code in the smart contract to simulate and execute the second transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the second transaction as input, simulates the execution of the second transaction on its corresponding ledger, and generates the transaction result including the execution return value, read operation set and write operation set.
  • the second endorsement node can package the foregoing read operation set and write operation set, endorsement result (pass or fail), and endorsement signature of the endorsement node to generate an endorsement response.
  • the first endorsement node sends an endorsement response to the first client.
  • the second endorsement node sends an endorsement response to the first client.
  • the first client passes the verification.
  • the first client may receive the endorsement response sent by the first endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the second client passes the verification.
  • the second client may receive the endorsement response sent by the second endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the first client sends the transaction information and signature to the first ordering node.
  • the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses may be sent to the first order node.
  • the second client sends the transaction information and signature to the second ordering node.
  • the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses may be sent to the second Sort node.
  • the first ordering node generates a block.
  • the second ordering node generates a block.
  • the first ordering node sends the block to the first node.
  • the A sorting node when the first ordering node receives N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, the A sorting node generates corresponding M blocks, sorts the M blocks, and transmits the M blocks to the first node.
  • the second ordering node sends the block to the second node.
  • the second ordering node when the second ordering node receives the N transaction information (including at least the transaction information of the second transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the second client, the second ordering node can be The second sorting node generates corresponding M blocks, sorts the M blocks, and transmits the M blocks to the second node.
  • the first node verifies the block and determines the transaction status of the first transaction.
  • the first node receives the transaction information including the first transaction and the block with multiple endorsement signatures corresponding to the first transaction, and can verify the block. Specifically, the first node may verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the second node verifies the block and determines the transaction status of the second transaction.
  • the second node receives the transaction information including the second transaction and the block with multiple endorsement signatures corresponding to the second transaction, and can verify the block. Specifically, the second node can verify multiple endorsement signatures, verify the transaction structure in the transaction information, and perform multi-version concurrency control (mvcc) verification on the block.
  • mvcc multi-version concurrency control
  • the first node sends the transaction status of the first transaction to the third node.
  • the second node sends the transaction status of the second transaction to the third node.
  • the third node generates blocks and sorts them.
  • the third node sends the block to the first node.
  • the third node sends the block to the second node.
  • the third node cluster when the first ordering node receives N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the endorsement responses of multiple first transactions) transmitted by the first client, and After the transaction information of the second transaction and the multiple endorsement signatures included in the endorsement responses of multiple second transactions), the third node cluster can generate corresponding M blocks and sort the M blocks, and then M The block is transmitted to the first node and the second node.
  • N transaction information including at least the transaction information of the first transaction and the multiple endorsement signatures included in the endorsement responses of multiple first transactions
  • the third node cluster can generate corresponding M blocks and sort the M blocks, and then M The block is transmitted to the first node and the second node.
  • the first node determines the transaction status of the first transaction according to the transaction status of the first transaction and the transaction status of the second transaction.
  • the second node determines the transaction status of the second transaction according to the transaction status of the first transaction and the transaction status of the second transaction.
  • the first node determines whether to execute or not execute the first transaction according to the transaction status of the first transaction.
  • the second node determines whether to execute or not execute the second transaction according to the transaction status of the second transaction.
  • the first node sends the execution result to the first client.
  • the second node sends the execution result to the second client.
  • the first node determines the execution or non-execution of the first transaction according to the transaction status of the first transaction
  • the second node determines the execution or non-execution of the first transaction according to the transaction status of the second transaction
  • the first blockchain can be the Ethereum chain.
  • the first node can deploy the first node on the Ethereum chain after determining that the transaction status of the first transaction is the first state. A transaction, and lock the first transaction. After receiving the transaction status of the second transaction sent by the third node cluster, when the transaction status of the second transaction is the first status, determine the first transaction The transaction status of is in the second state, and when the first transaction is in the second state, the first transaction is executed.
  • the first node in this application may not belong to the Ethereum chain, but a node of a newly-added distributed node cluster.
  • the first node may instruct the Ethereum chain to perform a rollback on the first transaction, that is, instruct The Ethereum chain does not execute the first transaction.
  • the first transaction is executed.
  • the first node may instruct the Ethereum chain to unlock the first transaction, that is, instruct the Ethereum chain to execute The first transaction.
  • first block chain is the fabric chain and the second block chain is the Ethereum chain
  • first block chain executes the execution steps of the fabric chain in the above embodiment
  • second block chain executes the above The implementation steps of the Ethereum chain in the embodiment.
  • the first blockchain or the second blockchain may also be a Bitcoin chain, which is not limited here.
  • FIG. 13 is a schematic diagram of the architecture of a blockchain network according to an embodiment of the application.
  • the blockchain network includes: a blockchain 4 network 40, a blockchain 2 network, The blockchain 3 network 30, the first client 130, the second client 230, and the node cluster 510, wherein the blockchain corresponding to the blockchain 4 network 40 is the Ethereum chain.
  • the specific description of the blockchain 2 network and the second client 230 can refer to the description of the embodiment corresponding to FIG. 2, which will not be repeated here.
  • the blockchain 4 network 40 includes a node cluster 410, and the node cluster 410 includes multiple node peers, and these node peers jointly maintain the Ethereum chain.
  • the node cluster 510 includes multiple node peers. Unlike the architecture shown in FIG. 1, the blockchain 3 network 30 does not include the node cluster 110. At this time, the node cluster 510 can complete the function of the node cluster 110, that is, the node cluster 510 The function of the node cluster 110 can be provided as an adapter.
  • the user can initiate a transaction at the first client 130, and the first client 130 can generate corresponding transaction information and send it to the cluster 510 via the network.
  • the cluster 510 includes multiple first nodes, and the first node is determining the transaction. After the transaction status of is in the first state, the first node can deploy the transaction on the node cluster 410, and accordingly, the node cluster 410 can lock the transaction. The first node may also send the transaction status of the first transaction to the cluster 310.
  • the second node may send the transaction status of the second transaction to the cluster 310.
  • the cluster 310 may be a sorting cluster, including multiple third nodes.
  • the third node may be a sorting node.
  • the sorting node may sort the received transaction data globally, combine a batch of sorted transaction data to generate a block, and combine The blocks are transmitted to cluster 510 and cluster 210.
  • the cluster 510 may determine the transaction status of the transaction according to the received block, and when the transaction status is the second state, instruct the node cluster 410 to execute the transaction, and when the transaction status is the third state, instruct the node cluster 410 to execute the transaction rollback. That is, the transaction is not executed.
  • the cross-chain transaction includes multiple related cross-chain sub-transactions, such as the first transaction and the second transaction. If the first transaction is the transfer of 10 units of currency from user A to user B, then the first transaction Subtract 10 units of currency from the balance of account A on the first blockchain, and the second transaction is the balance of account B on the second blockchain plus 10 units of currency.
  • the transaction initiated by the first client and the second client may be untrue, for example, the transaction initiated by the first client is the first blockchain The balance of the upper account A minus 10 units of currency, and the second transaction is the balance of the account B on the second blockchain plus 20 units of currency, which will destroy the existing data logical relationship and is unacceptable.
  • this application provides a cross-chain transaction method.
  • FIG. 14 is a schematic diagram of a cross-chain transaction method provided by an embodiment of the application. As shown in FIG. 14, the cross-chain transaction method includes:
  • the first node calculates the first hash of the second transaction, or receives the first hash of the second transaction sent by the first client, where the first client is the The initiator of the first transaction.
  • the first transaction and the second transaction are interrelated cross-chain transactions, where the first transaction is a transaction belonging to the first blockchain, and the second transaction is a transaction belonging to the second blockchain .
  • the cross-chain transaction when a user initiates a cross-chain transaction at the first client, the cross-chain transaction includes two cross-chain sub-transactions (the first transaction and the second transaction) that are related to each other.
  • the user can implement transaction operations through the first client terminal.
  • the first client terminal may generate transaction data corresponding to the first transaction according to the user's transaction operation.
  • the transaction operation may be an operation that causes the ledger status of the first blockchain and the second blockchain to change.
  • Transaction data may include, but is not limited to, user identification, transaction parameters (for example, transaction amount), transaction time, and the like.
  • the first client terminal may generate transaction information of the first transaction based on transaction data corresponding to the first transaction, and the transaction information may include the first hash (tx1) of the first transaction.
  • the transaction identifier can be used to distinguish and determine the operations performed on the transaction account.
  • the first hash (tx1) of the above first transaction may be a string composed of numbers and letters.
  • a hash function can be used to process the operations performed on the account book corresponding to the exchange, the transaction data, etc., and the obtained hash value is used as the transaction identifier of the transaction.
  • the first client may also generate transaction data corresponding to the second transaction according to the user's transaction operation, and send transaction data corresponding to the second transaction to the second client.
  • the transaction information of the second transaction can be generated based on the transaction data corresponding to the second transaction.
  • the transaction information can include the second hash (tx2) of the second transaction. Since the transaction identifier can distinguish and determine the operations performed on the transaction against the ledger, Therefore, the second hash (tx2) of the second transaction generated by the second client can uniquely represent the content of the second transaction execution.
  • the first client in addition to generating the first hash hash (tx1) of the first transaction, the first client also generates the first hash exp_hash (tx2) of the second transaction.
  • the first client may obtain the first hash exp_hash(tx2) of the second transaction that the second client "should” generate by calling the helper chain code.
  • the first client after the first client generates transaction data corresponding to the second transaction according to the user's transaction operation, it can use the transaction data as input to generate the first hash exp_hash(tx2) of the second transaction by calling the assistant chain code,
  • the first hash exp_hash(tx2) of the second transaction may indicate the unique transaction identifier corresponding to the second transaction that the second client should execute.
  • the first client may not obtain the first hash exp_hash(tx2) of the second transaction by querying the helper chain code, but obtain the second hash exp_hash(tx2) by communicating with the second client
  • the client should execute the chain code and parameters, and calculate the first hash exp_hash(tx2) of the second transaction.
  • the first client may send the transaction information to the endorsing node in the first node cluster.
  • the transaction information of the first transaction includes the first hash exp_hash (tx2) and the first hash hash (tx1) of the first transaction.
  • the endorsing node After the endorsing node receives the transaction information of the first transaction sent by the first client, it will call the relevant code in the smart contract to simulate and execute the first transaction indicated by the transaction information.
  • the endorsement node takes the transaction data in the transaction information of the first transaction as input, simulates the execution of the first transaction on its corresponding ledger, and generates the transaction result including the execution return value, the read operation set and the write operation set.
  • the endorsement node may package the read operation set and write operation set, the endorsement result (pass or fail), and the endorsement signature of the endorsement node to generate an endorsement response.
  • the endorsement response may also include the identification of the client corresponding to the transaction information, and the first hash exp_hash (tx2) and the first hash hash (tx1) of the first transaction.
  • the endorsement node may send multiple endorsement responses to the client.
  • the first client can receive the endorsement response sent by each endorsement node, and then determine whether the endorsement response meets the preset rule.
  • the first client after the first client determines that the endorsement response meets the preset rules, it can send the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses to the second node cluster, where the first transaction
  • the transaction information includes the first hash exp_hash(tx2) and the first hash hash(tx1) of the first transaction.
  • the nodes included in the second node cluster maintain the first blockchain
  • the second node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server.
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the multiple sorting nodes included in the second node cluster can globally sort the received transaction data, and combine a batch of sorted transaction data to generate a block structure.
  • one or more ordering nodes in the second node cluster When one or more ordering nodes in the second node cluster receive N transaction information (including at least the transaction information of the first transaction and the multiple endorsement signatures included in the multiple endorsement responses) transmitted by the first client, it can At least one sorting node generates corresponding M blocks and sorts the M blocks, and transmits the M blocks to the first node cluster, so that the first node cluster verifies the M blocks and passes the verification The blocks of are added to the corresponding blockchain in turn.
  • the nodes in the first node cluster may receive a block including transaction information of the first transaction and multiple endorsement signatures corresponding to the first transaction. It should be noted that, for the convenience of description, the nodes in the first node cluster are described as the first node below.
  • the first node receives the transaction information including the first transaction and the block with multiple endorsement signatures corresponding to the first transaction, and can verify the block. Regarding how the first node verifies the block, refer to the above-mentioned embodiment, which will not be repeated here.
  • the first node may send a sixth transaction to the third node.
  • the sixth transaction includes the first hash (tx1) of the first transaction.
  • the fourth transaction includes the first transaction of the second transaction. Hash exp_hash(tx2).
  • the nodes included in the third node cluster maintain the third blockchain
  • the third node cluster is an orderer group, which includes multiple ordering nodes, and each ordering node can be deployed on a server
  • Each sorting node can be used to provide sorting services in blockchain technology.
  • the third node cluster may also receive the second hash (tx2) of the second transaction and the second hash exp_hash (tx1) of the first transaction sent by the second node.
  • the third node cluster may also receive the fifth transaction sent by the second node, and the fifth transaction may include the second hash (tx2) of the second transaction and the second hash exp_hash(tx1) of the first transaction. ).
  • the multiple sorting nodes included in the third node cluster can perform global sorting for the received transactions, and combine a batch of sorted transaction data to generate a block structure.
  • the third node cluster can generate a fourth block.
  • the fourth block includes the second hash (tx2) of the second transaction and the second hash exp_hash(tx1) of the first transaction.
  • the fourth block also It may include the first hash exp_hash (tx2) of the second transaction and the first hash hash (tx1) of the first transaction.
  • the second hash of the second transaction (tx2), the second hash of the first transaction exp_hash (tx1), the first hash of the second transaction exp_hash (tx2), and the first transaction of the first The hash (tx1) can be in the same block or in different blocks, and it is not limited here.
  • the first node receives the second hash of the second transaction sent by the third node, where the first hash of the second transaction is equal to the second hash of the second transaction, indicating that the The transaction data of the second transaction is correct; the first hash of the second transaction is not equal to the second hash of the second transaction, indicating that the transaction data of the second transaction is incorrect.
  • the first node may obtain the fourth block on the third blockchain, and the fourth block may include the second hash (tx2) of the second transaction, and the second transaction
  • the second hash (tx2) is the transaction identifier corresponding to the actual execution of the second transaction, which can uniquely indicate the transaction data of the second transaction in specific execution.
  • the fourth block may also include the second hash exp_hash(tx1) of the first transaction.
  • the second node may receive the fifth block sent by the third node cluster, and the fifth block may include the first hash hash (tx1) of the first transaction, and the first hash hash of the first transaction (tx1) is the transaction identifier corresponding to the actual execution of the first transaction, which can uniquely indicate the transaction data of the first transaction in specific execution.
  • the fifth block may also include the first hash exp_hash(tx2) of the second transaction.
  • the first node can receive the block sent by the third node cluster, and the block includes the first node.
  • the first node can determine whether the second transaction’s second hash (tx2) is equal to the second transaction’s first hash exp_hash (tx2), and then determine whether the second transaction is in accordance with the correct transaction Data execution.
  • the first hash exp_hash(tx2) of the second transaction is generated by the first client through the transaction data of the second transaction, it can represent the transaction data that the first client thinks that the second transaction should be executed.
  • the second hash (tx2) of the second transaction represents the transaction data of the actual execution of the second transaction.
  • the second node may determine whether the first hash (tx1) of the first transaction is equal to the second hash exp_hash (tx1) of the first transaction to determine whether the first transaction is executed according to the correct transaction data.
  • the second hash exp_hash (tx1) of the first transaction is generated by the second client through the transaction data of the first transaction, it can represent transaction data that the second client thinks that the first transaction should be executed.
  • the first hash (tx1) of the first transaction represents the transaction data of the actual execution of the first transaction.
  • the first node can determine the first hash (tx1) of the first transaction and the second hash of the first transaction. See if exp_hash(tx1) is equal, and then obtain the judgment result of the second node.
  • the second node can determine the second hash (tx2) of the second transaction and the first hash exp_hash(tx2) of the second transaction. ) Is equal, and then the judgment result of the first node is obtained.
  • the first node can determine that the second transaction is in accordance with the correct Transaction data execution.
  • the second node determines that the first hash (tx1) of the first transaction is equal to the second hash exp_hash (tx1) of the first transaction, the second node can determine that the first transaction is in accordance with the correct Transaction data execution.
  • the first transaction can be executed.
  • the first node determines that the first transaction is not executed according to correct transaction data, and the second transaction is executed according to correct transaction data, the first transaction is not executed.
  • the first node determines that the first transaction is executed according to the correct transaction data, and the second transaction is not executed according to the correct transaction data, the first transaction is not executed.
  • the second transaction can be executed.
  • the second node determines that the first transaction is not executed according to correct transaction data, and the second transaction is executed according to correct transaction data, the second transaction is not executed.
  • the second node determines that the first transaction is executed according to the correct transaction data, and the second transaction is not executed according to the correct transaction data, the second transaction is not executed.
  • the first transaction is the transfer of 10 units of currency from user A to user B
  • the first transaction is the balance of account A on the first blockchain minus 10 units of currency
  • the second transaction is the first transaction. 2.
  • the first client generates the first hash (tx1) of the first transaction based on the transaction data of the first transaction (including the balance of account A on the first blockchain minus 10 units of currency), and based on The transaction data of the second transaction (including the balance of the B account on the second blockchain plus 10 units of currency) generates the first hash exp_hash(tx2) of the second transaction.
  • the second client generates the second hash exp_hash(tx1) of the first transaction based on the transaction data of the first transaction (including the balance of the A account on the first blockchain minus 10 units of currency), and based on the first transaction
  • the transaction data of the second transaction (including the balance of account B on the second blockchain plus 20 units of currency) generates the second hash (tx2) of the second transaction, that is, the second client wants to add to the B account More currencies.
  • the first node will receive the second hash (tx2) of the second transaction sent by the third node, because the second hash (tx2) is different from the first hash exp_hash (tx2) of the second transaction .
  • the first node will determine that the transaction data executed by the second transaction is incorrect, that is, if the second client is fraudulent, the first transaction will not be executed.
  • the embodiment of the application provides a cross-chain transaction method, including: the first node obtains the first hash of the second transaction; the first node obtains the fourth area on the third blockchain Block, the fourth block includes the second hash of the second transaction; the first node judges the first hash of the second transaction and the first hash of the second transaction according to the fourth block Whether the two hashes are equal.
  • the first node can determine whether the second transaction is executed according to the correct transaction data by judging whether the second hash of the second transaction is equal to the first hash of the second transaction. If it is not executed according to the correct transaction data, the first transaction will not be executed.
  • each cross-chain transaction may have a certain dependency relationship. Specifically, there is a certain dependency relationship between the transaction data of each cross-chain transaction. For example, there are two cross-chain transactions.
  • Chain transaction cross-chain transaction A and cross-chain transaction B
  • cross-chain transaction A includes the first transaction and second transaction
  • cross-chain transaction B includes the third transaction and fourth transaction
  • the first transaction and the third transaction are the first area
  • the transactions on the blockchain the second transaction and the fourth transaction are transactions on the second blockchain.
  • the first transaction needs to update the balance of the A account
  • the third transaction also needs to update the balance of the A account.
  • the first transaction is before the third transaction in time sequence.
  • the second transaction needs to update the balance of the B account, and the fourth transaction also needs to update the balance of the B account.
  • the second transaction is after the fourth transaction in time sequence.
  • the third transaction can only be executed after the first transaction is completed.
  • the first transaction and the second transaction belong to the same cross-chain transaction, and the execution of the first transaction needs to depend on the execution result of the second transaction.
  • the second transaction can only be executed after the fourth transaction is completed.
  • the fourth transaction and the third transaction belong to the same cross-chain transaction, and the execution of the fourth transaction needs to depend on the execution result of the third transaction.
  • Figure 15a is a schematic diagram of the dependency relationship of a cross-chain transaction.
  • the first transaction A1 and the second transaction B1 belong to the same cross-chain transaction
  • the third transaction A2 and the fourth transaction B2 belongs to the same cross-chain transaction.
  • the first transaction A1 and the third transaction A2 have a timing dependency, that is, the third transaction A2 can be executed after the first transaction A1 is executed
  • the fourth transaction B2 and the second transaction B1 have a timing dependency Relationship, that is, the second transaction B1 can be executed after the execution of the fourth transaction B2 is completed.
  • the first transaction A1, the second transaction B1, the third transaction A2, and the fourth transaction B2 have the problem of transaction deadlock.
  • FIG. 15b is a schematic diagram of an embodiment of a cross-chain transaction method provided by an embodiment of the application.
  • the cross-chain transaction method provided in this embodiment includes:
  • the first node receives transaction data of a first transaction, where the transaction data of the first transaction includes target transaction parameters.
  • the first node receives transaction data of the second transaction.
  • transaction data of the second transaction includes the target transaction parameter, determine that the transaction status of the second transaction is invalid.
  • the first transaction and the third transaction are interrelated cross-chain transactions
  • the second transaction and the fourth transaction are interrelated cross-chain transactions
  • the first transaction and The second transaction is a transaction on the first blockchain
  • the third transaction and the fourth transaction are transactions on the second blockchain.
  • the first transaction is the balance of account A minus 5 units of currency
  • the second transaction is the balance of account A minus 10 units of currency
  • the third transaction is the balance of account B plus 5 units of currency
  • the fourth transaction Add 10 units of currency to the balance of account B.
  • the transaction data of the first transaction includes the target transaction parameter "A account”
  • the transaction data of the second transaction includes the target transaction parameter "A account”
  • the first node can directly determine that the transaction status of the second transaction is invalid, and proceed The second transaction is not executed, that is, the state database corresponding to the second transaction is not updated.
  • the first node 800 in the embodiment of the present application includes:
  • the processing module 801 is configured to determine that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes consensus verification;
  • the obtaining module 802 is used to obtain the transaction status of the second transaction
  • the processing module 801 is further configured to: when the transaction status of the second transaction is the first state, the first node modifies target data according to the transaction data of the first transaction, and the target data is Data related to the first transaction in the state machine of the first node.
  • the processing module 801 determines that the transaction status of the first transaction is the first status, and the first status indicates that the transaction passes the consensus verification; the acquisition module 802 acquires the transaction status of the second transaction; the processing module 801 is When the transaction state of the second transaction is the first state, the first node modifies target data according to the transaction data of the first transaction, and the target data is the state machine of the first node. State the data related to the first transaction.
  • the first node after determining that the transaction state of the first transaction is the first state, the first node does not directly determine whether to modify the state machine of the first node according to the first state, but receives the transaction state of the second transaction, and When the transaction state of the second transaction is the first state, modify the state machine of the first node, so that the execution of the cross-chain sub-transaction depends not only on the consensus verification result of the first transaction, but also other related factors. Consensus verification results of inter-linked cross-chain transactions will not appear that only part of the inter-related cross-chain transactions are successfully executed, while the other part is not successfully executed, which realizes the atomic execution of cross-chain transactions on multiple blockchains .
  • the acquiring module 802 is specifically configured to: receive the transaction status of the second transaction sent by a third node, and the third node does not maintain the first blockchain and the second blockchain.
  • the first node further includes:
  • the sending module 803 is configured to send the transaction status of the first transaction to a third node, and the third node does not maintain the first block chain and the second block chain.
  • the sending module 803 is specifically configured to:
  • the first node sends a third transaction to a third node, and the third transaction includes the transaction status of the first transaction.
  • the first node 800 in the embodiment of the present application includes:
  • the processing module 801 is used to:
  • the first hash of the second transaction is calculated, or the receiving module is specifically configured to receive the first hash of the second transaction sent by the first client, where the first client is the The originating end of the first transaction;
  • the receiving module 804 is configured to receive the second hash of the second transaction sent by the third node;
  • the first hash of the second transaction is equal to the second hash of the second transaction, indicating that the transaction data of the second transaction is correct; the first hash of the second transaction is identical to the first hash of the second transaction.
  • the second hashes of the two transactions are not equal, which means that the transaction data of the second transaction is incorrect.
  • processing module 801 is further configured to:
  • the first hash of the first transaction is calculated, or the receiving module is specifically configured to receive the first hash of the first transaction sent by the first client;
  • the sending module 803 is further configured to send the first hash of the first transaction to the third node.
  • the sending module 803 is also used for:
  • the synchronization information being used to indicate that the first node has modified the target data related to the first transaction in the state machine of the first node according to the transaction data of the first transaction ,
  • the first node and the fourth node belong to the same node cluster.
  • FIG. 17 is a schematic diagram of an embodiment of the third node in an embodiment of the present application.
  • the third node 900 in the embodiment of the present application includes:
  • An obtaining module 901 configured to receive the transaction status of a second transaction sent by a second node, the second node maintaining a second blockchain, and the second transaction belongs to the second blockchain;
  • the sending module 903 is configured to send the transaction status of the second transaction to the first node, so that the first node processes the target data based on the transaction status of the second transaction and the transaction status of the first transaction, wherein
  • the target data is data related to the first transaction in the state machine of the first node, the second transaction and the first transaction are related cross-chain transactions, and the first transaction belongs to the first transaction.
  • the first node maintains the first block chain, and the third node does not maintain the first block chain and the second block chain.
  • the third node further includes:
  • the processing module 902 is configured to generate a first block including the transaction status of the second transaction.
  • the receiving module is further used for:
  • the processing module is specifically used for:
  • the transaction sent by the at least one fifth node and the transaction status of the second transaction are sorted to generate at least A block, where the first block is one of the at least one block, and the first block includes the transaction state of the second transaction.
  • the sending module 903 is specifically configured to:
  • the receiving module is specifically used for:
  • a fourth transaction sent by the second node is received, where the fourth transaction includes the transaction status of the second transaction.
  • the receiving module is further used for:
  • the sending module is also used for:
  • the embodiment of the present application also provides a cross-chain transaction device, as shown in FIG. 18, which is a schematic structural diagram of the cross-chain transaction device in the embodiment of this application.
  • FIG. 18 is a schematic structural diagram of the cross-chain transaction device in the embodiment of this application.
  • the cross-chain transaction device runs on the terminal.
  • the terminal can be any terminal equipment including mobile phones, tablet computers, personal digital assistants (PDAs), point of sales (POS), car computers, etc.
  • PDAs personal digital assistants
  • POS point of sales
  • the terminal is a mobile phone
  • the terminal is a mobile phone
  • PDAs personal digital assistants
  • POS point of sales
  • the mobile phone includes: a radio frequency (RF) circuit 1110, a memory 1120, an input unit 1130, a display unit 1140, a sensor 1150, an audio circuit 1160, a wireless fidelity (WiFi) module 1170, a processor 1180, and a power supply 1190 And other parts.
  • RF radio frequency
  • the RF circuit 1110 can be used for receiving and sending signals during the process of sending and receiving information or talking. In particular, after receiving the downlink information of the base station, it is processed by the processor 1180; in addition, the designed uplink data is sent to the base station.
  • the RF circuit 1110 includes but is not limited to an antenna, at least one amplifier, a transceiver, a coupler, a low noise amplifier (LNA), a duplexer, and the like.
  • the RF circuit 1110 can also communicate with the network and other devices through wireless communication.
  • the above wireless communication can use any communication standard or protocol, including but not limited to the global system of mobile communication (GSM), general packet radio service (GPRS), code division multiple access (code division multiple access, GSM) Multiple access, CDMA), wideband code division multiple access (WCDMA), long term evolution (LTE), email, short messaging service (SMS), etc.
  • GSM global system of mobile communication
  • GPRS general packet radio service
  • code division multiple access code division multiple access
  • GSM Code division multiple access
  • CDMA code division multiple access
  • WCDMA wideband code division multiple access
  • LTE long term evolution
  • email short messaging service
  • the memory 1120 can be used to store software programs and modules.
  • the processor 1180 executes various functional applications and data processing of the mobile phone by running the software programs and modules stored in the memory 1120.
  • the memory 1120 may mainly include a program storage area and a data storage area.
  • the program storage area may store an operating system, an application program required by at least one function (such as a sound playback function, an image playback function, etc.), etc.; Data (such as audio data, phone book, etc.) created by the use of mobile phones.
  • the memory 1120 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one magnetic disk storage device, a flash memory device, or other volatile solid-state storage devices.
  • the input unit 1130 can be used to receive input digital or character information, and generate key signal input related to user settings and function control of the mobile phone.
  • the input unit 1130 may include a touch panel 1131 and other input devices 1132.
  • the touch panel 1131 also called a touch screen, can collect user touch operations on or near it (for example, the user uses any suitable objects or accessories such as fingers, stylus, etc.) on the touch panel 1131 or near the touch panel 1131. Operation), and drive the corresponding connection device according to the preset program.
  • the touch panel 1131 may include two parts: a touch detection device and a touch controller.
  • the touch detection device detects the user's touch position, detects the signal brought by the touch operation, and transmits the signal to the touch controller; the touch controller receives the touch information from the touch detection device, converts it into contact coordinates, and then sends it To the processor 1180, and can receive and execute commands sent by the processor 1180.
  • the touch panel 1131 can be implemented in multiple types such as resistive, capacitive, infrared, and surface acoustic wave.
  • the input unit 1130 may also include other input devices 1132.
  • other input devices 1132 may include, but are not limited to, one or more of a physical keyboard, function keys (such as volume control buttons, switch buttons, etc.), trackball, mouse, and joystick.
  • the display unit 1140 may be used to display information input by the user or information provided to the user and various menus of the mobile phone.
  • the display unit 1140 may include a display panel 1141.
  • the display panel 1141 may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), etc.
  • the touch panel 1131 can cover the display panel 1141. When the touch panel 1131 detects a touch operation on or near it, it transmits it to the processor 1180 to determine the type of the touch event, and then the processor 1180 responds to the touch event. Type provides corresponding visual output on the display panel 1141.
  • the touch panel 1181 and the display panel 1141 are used as two independent components to realize the input and input functions of the mobile phone, but in some embodiments, the touch panel 1131 and the display panel 1141 can be integrated. Realize the input and output functions of mobile phones.
  • the mobile phone may also include at least one sensor 1150, such as a light sensor, a motion sensor, and other sensors.
  • the light sensor may include an ambient light sensor and a proximity sensor.
  • the ambient light sensor can adjust the brightness of the display panel 1141 according to the brightness of the ambient light.
  • the proximity sensor can close the display panel 1141 and/or when the mobile phone is moved to the ear. Or backlight.
  • the accelerometer sensor can detect the magnitude of acceleration in various directions (usually three-axis), and can detect the magnitude and direction of gravity when stationary, and can be used to identify mobile phone posture applications (such as horizontal and vertical screen switching, related Games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, percussion), etc.; as for other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which can be configured in mobile phones, we will not here Repeat.
  • mobile phone posture applications such as horizontal and vertical screen switching, related Games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, percussion), etc.
  • vibration recognition related functions such as pedometer, percussion
  • other sensors such as gyroscopes, barometers, hygrometers, thermometers, infrared sensors, etc., which can be configured in mobile phones, we will not here Repeat.
  • the audio circuit 1160, the speaker 1161, and the microphone 1162 can provide an audio interface between the user and the mobile phone.
  • the audio circuit 1160 can transmit the electric signal after the conversion of the received audio data to the speaker 1161, which is converted into a sound signal by the speaker 1161 for output; on the other hand, the microphone 1162 converts the collected sound signal into an electric signal, and the audio circuit 1160 After being received, it is converted into audio data, processed by the audio data output processor 1180, and sent to another mobile phone via the RF circuit 1110, or the audio data is output to the memory 1120 for further processing.
  • WiFi is a short-distance wireless transmission technology.
  • the mobile phone can help users send and receive e-mails, browse web pages, and access streaming media through the WiFi module 1170. It provides users with wireless broadband Internet access.
  • FIG. 18 shows the WiFi module 1170, it is understandable that it is not a necessary component of the mobile phone, and can be omitted as needed without changing the essence of the application.
  • the processor 1180 is the control center of the mobile phone. It uses various interfaces and lines to connect various parts of the entire mobile phone. It executes by running or executing software programs and/or modules stored in the memory 1120, and calling data stored in the memory 1120. Various functions and processing data of the mobile phone can be used to monitor the mobile phone as a whole.
  • the processor 1180 may include one or more processing units; optionally, the processor 1180 may integrate an application processor and a modem processor, where the application processor mainly processes the operating system, user interface, and application programs. And so on, the modem processor mainly deals with wireless communication. It can be understood that the foregoing modem processor may not be integrated into the processor 1180.
  • the mobile phone also includes a power supply 1190 (such as a battery) for supplying power to various components.
  • a power supply 1190 (such as a battery) for supplying power to various components.
  • the power supply can be logically connected to the processor 1180 through a power management system, so that the power management system can manage charging, discharging, and power consumption management functions.
  • the mobile phone may also include a camera, a Bluetooth module, etc., which will not be repeated here.
  • the processor 1180 included in the terminal can execute the steps described in the corresponding embodiments of FIG. 3, FIG. 4, FIG. 6, FIG. 11, FIG. 12a, FIG. 12b, FIG. 14 and FIG. 15b.
  • the cross-chain transaction device provided by the embodiment of the present application may also be deployed in a server, and the server may be a single server or a server cluster composed of multiple servers. In the following, a single server is described.
  • FIG. 19, is a schematic diagram of a server structure provided in an embodiment of the application.
  • the server 1200 may have relatively large differences due to different configurations or performances, and may include one or more central processing units (central processing units). , CPU) 1222 (for example, one or more processors) and memory 1232, one or more storage media 1230 for storing application programs 1242 or data 1244 (for example, one or one storage device with a large amount).
  • the memory 1232 and the storage medium 1230 may be short-term storage or persistent storage.
  • the program stored in the storage medium 1230 may include one or more modules (not shown in the figure), and each module may include a series of command operations on the server. Further, the central processing unit 1222 may be configured to communicate with the storage medium 1230, and execute a series of instruction operations in the storage medium 1230 on the server 1200.
  • the server 1200 may also include one or more power supplies 1226, one or more wired or wireless network interfaces 1250, one or more input and output interfaces 1258, and/or one or more operating systems 1241, such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
  • operating systems 1241 such as Windows ServerTM, Mac OS XTM, UnixTM, LinuxTM, FreeBSDTM, etc.
  • the steps performed by the server in the above embodiment may be based on the server structure shown in FIG. 19.
  • the CPU 1222 can execute the steps described in the embodiments corresponding to FIGS. 3, 4, 6, 11, 12a, 12b, 14 and 15b.
  • the computer program product includes one or more computer instructions.
  • the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.
  • the computer instructions may be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium.
  • the computer instructions may be transmitted from a website, computer, server, or data center. Transmission to another website, computer, server, or data center via wired (for example, coaxial cable, optical fiber, Digital Subscriber Line (DSL)) or wireless (for example, infrared, wireless, microwave, etc.).
  • wired for example, coaxial cable, optical fiber, Digital Subscriber Line (DSL)
  • wireless for example, infrared, wireless, microwave, etc.
  • the computer-readable storage medium may be any available medium that can be stored by a computer or a data storage device such as a server or data center integrated with one or more available media.
  • the usable medium may be a magnetic medium (for example, a floppy disk, a hard disk, a magnetic tape), an optical medium (for example, a DVD), or a semiconductor medium (for example, a solid state disk (SSD)).
  • the disclosed system, device, and method can be implemented in other ways.
  • the device embodiments described above are only illustrative.
  • the division of the units is only a logical function division, and there may be other divisions in actual implementation, for example, multiple units or components can be combined or It can be integrated into another system, or some features can be ignored or not implemented.
  • the displayed or discussed mutual coupling or direct coupling or communication connection may be indirect coupling or communication connection through some interfaces, devices or units, and may be in electrical, mechanical or other forms.
  • the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the objectives of the solutions of the embodiments.
  • each unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units may be integrated into one unit.
  • the above-mentioned integrated unit can be implemented in the form of hardware or software functional unit.
  • the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium.
  • the technical solution of this application essentially or the part that contributes to the existing technology or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium , Including several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in each embodiment of the present application.
  • the aforementioned storage media include: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), magnetic disk or optical disk and other media that can store program code .

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Finance (AREA)
  • Computer Security & Cryptography (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Data Mining & Analysis (AREA)
  • Marketing (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Computing Systems (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • General Health & Medical Sciences (AREA)
  • Technology Law (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

本申请实施例提供了一种跨链交易方法和装置,其中,跨链交易方法包括:第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取所述第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。本申请中,跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,因此不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。

Description

一种跨链交易方法和装置
本申请要求于2019年07月26日提交中国国家知识产权局、申请号为201910683735.1、发明名称为“一种跨链交易方法和装置”的中国专利申请的优先权;以及本申请要求于2019年11月18日提交中国国家知识产权局、申请号为201911129391.6、发明名称为“一种跨链交易方法和装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及互联网技术领域,尤其涉及一种跨链交易方法和装置。
背景技术
区块链(Blockchain)系统中,数据均保存在区块中,新写入的数据组成新的区块,添加在当前区块链的末端。每个区块在保存数据的同时,还要保存前一个区块中所有记录的数据唯一对应的一个数(往往是所有记录的数据的哈希值),从而形成链。因此,区块链系统可以认为是由分布式网络上的互相不完全信任的计算机,通过共识规则,共同维护一套可追溯、不可篡改的链式数据的系统。
在一种场景中,区块链间的跨链交易可以指用户A使用其在区块链1中的资产,向在区块链2中的用户B支付若干区块链2中的资产。此时,跨链交易可以包括相互关联的两个跨链交易(第一交易和第二交易),其中,第一交易指用户A扣除若干资产,第二交易指用户B增加若干资产。
现有技术中的实现方案为:确定一个中间链来扮演中间人的角色,用户A在区块链1中发起交易,当中间链确定第一交易在区块链1上执行成功后,向区块链2发起交易,使区块链2上执行第二交易,如果因为某些原因而导致第二交易失败,则需要撤销已经成功的交易(第一交易),然而已经成功的交易可能会无法撤销,进而出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行。
综上,目前亟需一种跨链交易方法,用于解决相互关联的跨链交易在多个区块链上进行原子性执行的问题。
发明内容
第一方面,本申请提供了一种跨链交易方法,所述方法包括:
第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
所述第一节点获取第二交易的交易状态;
当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。
在第一方面的一种可能设计中,所述第一节点获取第二交易的交易状态,包括:
所述第一节点获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点接收所述第一交易的交易数据;
所述确定第一交易的交易状态为第一状态,包括:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点获取第二交易的第一交易标识;
所述第一节点获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述第一节点根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点获取所述第一交易的第一交易标识;
所述第一节点向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
在第一方面的一种可能设计中,所述第一节点根据所述第一交易的交易数据更新所述第一节点的状态机之后,所述方法还包括:
所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已更新所述第一节点的状态机,所述第一节点和所述第四节点属于同一个节点集群。
第二方面,本申请提供了一种跨链交易方法,所述方法包括:
第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
所述第一节点获取第二交易的交易状态;
当所述第二交易的交易状态为所述第三状态时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第二方面的一种可能设计中,所述第一节点获取第二交易的交易状态,包括:
所述第一节点获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
在第二方面的一种可能设计中,所述方法还包括:
所述第一节点向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第二方面的一种可能设计中,所述方法还包括:
所述第一节点向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第二方面的一种可能设计中,所述方法还包括:
所述第一节点接收所述第一交易的交易数据;
所述确定第一交易的交易状态为第一状态,包括:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
在第二方面的一种可能设计中,所述方法还包括:
所述第一节点获取第二交易的第一交易标识;
所述第一节点获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述第一节点根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第二方面的一种可能设计中,所述方法还包括:
所述第一节点获取所述第一交易的第一交易标识;
所述第一节点向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
第三方面,本申请提供了一种跨链交易装置,所述跨链交易装置包括:
处理模块,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块,用于获取第二交易的交易状态;
所述处理模块,还用于当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。
在第三方面的一种可能设计中,所述获取模块,具体用于:
获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链, 所述第一区块包括所述第二交易的交易状态。
在第三方面的一种可能设计中,所述跨链交易装置还包括:
发送模块,用于向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第三方面的一种可能设计中,所述发送模块,还用于:向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
所述处理模块,还用于当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第三方面的一种可能设计中,所述装置还包括:
接收模块,所述接收模块用于接收所述第一交易的交易数据;
所述处理模块具体用于:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
在第三方面的一种可能设计中,所述获取模块,还用于:
获取第二交易的第一交易标识;
获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述处理模块还用于:
根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第三方面的一种可能设计中,所述获取模块,还用于:
获取所述第一交易的第一交易标识;
所述发送模块,还用于:
向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
在第三方面的一种可能设计中,所述发送模块还用于:
向第四节点广播同步信息,所述同步信息用于表示所述第一节点已更新所述第一节点的状态机,所述第一节点和所述第四节点属于同一个节点集群。
第四方面,本申请提供了一种跨链交易装置,所述跨链交易装置包括:
处理模块,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块,用于获取第二交易的交易状态;
所述处理模块,还用于当所述第二交易的交易状态为所述第三状态时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第四方面的一种可能设计中,所述获取模块,具体用于:
获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
在第四方面的一种可能设计中,所述第一交易与所述第二交易为相互关联的跨链交易。
在第四方面的一种可能设计中,所述跨链交易装置还包括:
发送模块,用于向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第四方面的一种可能设计中,所述发送模块,还用于:向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
所述处理模块,还用于当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
在第四方面的一种可能设计中,所述装置还包括:
接收模块,所述接收模块用于接收所述第一交易的交易数据;
所述处理模块具体用于:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
在第四方面的一种可能设计中,所述获取模块,还用于:
获取第二交易的第一交易标识;
获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述处理模块还用于:
根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第四方面的一种可能设计中,所述获取模块,还用于:
获取所述第一交易的第一交易标识;
所述发送模块,还用于:
向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
第五方面,本申请提供了一种跨链交易方法,所述方法包括:
第一节点获取第二交易的第一交易标识,所述第二交易属于第二区块链上的交易,所述第二交易与第一交易为相互关联的跨链交易,所述第一交易为第一区块链上的交易,所述第一节点维护第一区块链;
所述第一节点接收第三节点发送的第一区块,所述第一区块包括第二交易的第二交易标识;
所述第一节点根据所述第一区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第五方面的一种可能设计中,所述方法还包括:
所述第一节点向所述第三节点发送所述第二交易的第一交易标识。
在第五方面的一种可能设计中,所述方法还包括:
所述第一节点获取所述第一交易的第一交易标识;
所述第一节点向所述第三节点发送所述第一交易的第一交易标识。
在第五方面的一种可能设计中,所述第一区块还包括第一交易的第二交易标识;
所述方法还包括:
所述第一节点根据所述第一区块,判断所述第一交易的第一交易标识与所述第一交易的第二交易标识是否相等。
第六方面,本申请提供了一种跨链交易方法,所述方法包括:
接收第一节点发送的第一交易的第一交易标识,所述第一节点维护第一区块链,所述第一交易为第一区块链上的交易;
接收第二节点发送的第二交易的第二交易标识,所述第二节点维护第二区块链,所述第一交易与所述第二交易为相互关联的跨链交易,所述第二交易为所述第二区块链上的交易;
生成第一区块,所述第一区块包括所述第二交易的第二交易标识;
生成第二区块,所述第二区块包括所述第一交易的第一交易标识;
向所述第一节点发送所述第一区块;
向所述第二节点发送所述第二区块。
在第六方面的一种可能设计中,所述方法还包括:
接收第一节点发送的第二交易的第一交易标识;
所述第二区块还包括:所述第二交易的第一交易标识。
在第六方面的一种可能设计中,所述方法还包括:
接收第二节点发送的第一交易的第二交易标识;
所述第一区块还包括:所述第一交易的第二交易标识。
第七方面,本申请提供了一种跨链交易装置,所述跨链交易装置为第一节点所在的跨链交易装置,包括:
获取模块,用于获取第二交易的第一交易标识,所述第二交易属于第二区块链上的交易,所述第二交易与第一交易为相互关联的跨链交易,所述第一交易为第一区块链上的交易,所述第一节点维护第一区块链;接收第三节点发送的第一区块,所述第一区块包括第二交易的第二交易标识;
处理模块,用于根据所述第一区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
在第七方面的一种可能设计中,还包括:
发送模块,用于向所述第三节点发送所述第二交易的第一交易标识。
在第七方面的一种可能设计中,所述获取模块,还用于:
获取所述第一交易的第一交易标识;
所述发送模块,还用于向所述第三节点发送所述第一交易的第一交易标识。
在第七方面的一种可能设计中,所述第一区块还包括第一交易的第二交易标识;
所述处理模块,具体用于根据所述第一区块,判断所述第一交易的第一交易标识与所述第一交易的第二交易标识是否相等。
第八方面,本申请提供了一种跨链交易装置,所述跨链交易装置为第三节点所在的跨链交易装置,包括:
接收模块,用于接收第一节点发送的第一交易的第一交易标识,所述第一节点维护第一区块链,所述第一交易为第一区块链上的交易;接收第二节点发送的第二交易的第二交易标识,所述第二节点维护第二区块链,所述第一交易与所述第二交易为相互关联的跨链交易,所述第二交易为所述第二区块链上的交易;
处理模块,用于生成第一区块,所述第一区块包括所述第二交易的第二交易标识;生成第二区块,所述第二区块包括所述第一交易的第一交易标识;
发送模块,用于向所述第一节点发送所述第一区块;向所述第二节点发送所述第二区块。
在第八方面的一种可能设计中,所述接收模块,还用于:接收第一节点发送的第二交易的第一交易标识;
所述第二区块还包括:所述第二交易的第一交易标识。
在第八方面的一种可能设计中,所述接收模块,还用于:接收第二节点发送的第一交易的第二交易标识;
所述第一区块还包括:所述第一交易的第二交易标识。
第九方面,本申请实施例提供了一种跨链交易方法,包括:
接收第一交易的交易数据,所述第一交易的交易数据包括目标交易参数。
接收第二交易的交易数据。
若所述第二交易的交易数据包括所述目标交易参数,则确定所述第二交易的交易状态为无效。
在第九方面的一种可能设计中,所述第一交易和第三交易为相互关联的跨链交易,所述第二交易和第四交易为相互关联的跨链交易,所述第一交易和所述第二交易为第一区块链上的交易,所述第三交易和所述第四交易为第二区块链上的交易。
第十方面,本申请实施例提供了一种跨链交易装置,包括:
接收模块,用于接收第一交易的交易数据,所述第一交易的交易数据包括目标交易参数;接收第二交易的交易数据;
处理模块,用于若所述第二交易的交易数据包括所述目标交易参数,则确定所述第二交易的交易状态为无效。
在第十方面的一种可能设计中,所述第一交易和第三交易为相互关联的跨链交易,所述第二交易和第四交易为相互关联的跨链交易,所述第一交易和所述第二交易为第一区块链上的交易,所述第三交易和所述第四交易为第二区块链上的交易。
第十一方面,本申请实施例提供了一种跨链交易装置,包括:存储器、收发器、处理 器以及总线系统;其中,该存储器用于存储程序和指令;该收发器用于在该处理器的控制下接收或发送信息;该处理器用于执行该存储器中的程序;该总线系统用于连接该存储器、该收发器以及该处理器,以使该存储器、该收发器以及该处理器进行通信;该处理器用于调用该存储器中的程序指令,执行如上述第一方面、第二方面、第五方面、第六方面或第九方面所述的方法。
第十二方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面、第二方面、第五方面、第六方面或第九方面所述的方法。
本申请提供了一种跨链交易方法,包括:第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
以及,本申请实施例提供了一种跨链交易方法,可以使得跨链交易实现在多个区块链上进行原子性执行。
第一方面,本申请提供了一种跨链交易方法,应用于第一节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第一交易与第二交易为相关联的跨链交易,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述方法包括:所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取所述第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。本实施例中,交易属于区块链,则维护该区块链的节点参与该区块链的建设,例如可以执行至少以下一种行为:交易的生成、交易数据的共识、交易相关的智能合约的执行、交易相关的区块生成、以及交易相关的状态机中的目标数据的修改,节点可以从维护的区块链中获取交易数据,其中,交易数据可以指示交易的具体内容或者描述交易的细节,例如,仅指示交易状态,如交易是否成功的数据,在本申请中,不应理解为交易数据。第一交易和第二交易可以是相关联的。例如,第一交易和第二交易为同一笔交易的不同子交易。具体的,第一交易和第二交易的交易数据中,具有表示两者相关联的标识,例如可以具有相同或相关联的的标识ID。本实施例中,第一节点可以主动基于第二交易的交易状态,去发起所述第一节点的状态机中目标数据的修改,目标数据可以是第一节点的状态机中与第一交易的交易状态相关的字段,例如,目标数据可能 包括一种或几种前文描述的交易数据。在金融转账的场景中,目标数据可以是账户余额,例如:A向B转账X个单位的货币,第一交易为A的账户余额减少X个单位的货币,第二交易为B的账户余额增加X个单位的货币,则目标数据为A的账户余额;在开发票的场景中,目标数据可以是发票金额,例如:A向B开金额为X个单位的发票,第一交易为A向B开金额为X个单位的发票,第二交易为B接收到A开的金额为X个单位的发票,则目标数据为A向B开发票的金额;在货币兑换货物的场景中,目标数据可以是账户余额或者是货物的数量,例如:A向B转账X个单位的货币,B向A转账Y个单位的货物,则第一交易为A的账户余额减少X个单位的货币,第二交易为B减少Y个单位的货物,则目标数据为A的账户余额。
在第一方面的一种可能设计中,所述第一节点获取所述第二交易的交易状态,包括:所述第一节点获取包括所述第二交易的交易状态的第一区块,所述第一区块来自第三节点,所述第三节点不维护所述第一区块链和所述第二区块链。本实施例中,所述第三节点不维护所述第一区块链和所述第二区块链可以理解为所述第三节点不能从所述第一区块链和所述第二区块链中获取数据;应当说明的是,所述第三节点不维护所述第一区块链和所述第二区块链可以理解为所述第三节点不能从所述第一区块链和所述第二区块链中获取第一交易和第二交易的交易数据。从另一个角度讲,第三节点不为第一交易的计算以及第二交易的计算提供硬件资源。应当说明的是,所述第三节点不维护所述第一区块链和所述第二区块链可以理解为第三节点不执行如下行为:第一交易的生成、第二交易的生成、第一交易和第二交易的交易数据的共识、第一交易和第二交易相关的智能合约的执行、以及第一交易和第二交易相关的状态机中的目标数据的修改。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点向第三节点发送所述第一交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
在第一方面的一种可能设计中,所述第一节点向第三节点发送所述第一交易的交易状态,包括:
所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点向第三节点发送第五交易,所述第五交易包括超时信息,所述超时信息用于指示所述第三节点未从所述第二节点接收到所述第二交易的交易状态;
当所述第一节点未获取到所述第二交易的交易状态,且得到获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据。本实施例中,所述第一节点可以不根据述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,可以根据其他信息的修改所述第一节点的状态机中与所述第一交易相关的目标数据,也可以不修改所述第一节点的状态机中与所述第一交易相关的目标数据。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点计算得到所述第二交易的第一哈希,或接收到第一客户端发送的所述第 二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
所述第一节点接收第三节点发送第二交易的第二哈希;
其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
在第一方面的一种可能设计中,所述方法还包括:
所述第一节点计算得到所述第一交易的第一哈希,或接收到第一客户端发送的所述第一交易的第一哈希;
所述第一节点向所述第三节点发送所述第一交易的第一哈希。
在第一方面的一种可能设计中,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据之后,所述方法还包括:
所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,所述第一节点和所述第四节点属于同一个节点集群。
第二方面,本申请提供了一种跨链交易方法,所述方法包括:
第三节点接收第二节点发送的第二交易的交易状态,所述第二节点维护第二区块链,所述第二交易属于所述第二区块链;
所述第三节点向所述第一节点发送所述第二交易的交易状态,以便所述第一节点基于所述第二交易的交易状态和第一交易的交易状态处理目标数据,其中所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据,所述第二交易与所述第一交易为相关联的跨链交易,所述第一交易属于第一区块链,第一节点维护所述第一区块链,所述第三节点不维护所述第一区块链和所述第二区块链。
在第二方面的一种可能设计中,所述方法还包括:
所述第三节点生成包括所述第二交易的交易状态的第一区块。
在第二方面的一种可能设计中,所述方法还包括:
所述第三节点接收至少一个第五节点发送的交易;
所述第三节点生成包括所述第二交易的交易状态的第一区块,包括:
所述第三节点基于接收所述至少一个第五节点发送的交易的时间以及接收所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
在第二方面的一种可能设计中,所述第三节点向所述第一节点发送第二交易的交易状态,包括:
所述第三节点向所述第一节点发送所述第一区块。
在第二方面的一种可能设计中,所述第三节点接收第二节点发送的第二交易的交易状态,包括:
所述第三节点接收所述第二节点发送的第四交易,所述第四交易包括所述第二交易的交易状态。
在第二方面的一种可能设计中,所述方法还包括:
所述第三节点接收所述第二节点发送的第二交易的第二哈希;
所述第三节点向所述第一节点发送所述第二交易的第二哈希,以便所述第一节点基于所述第二交易的第二哈希与第二交易的第一哈希确定所述第二交易的交易数据的正确性,其中,所述第二交易的第一哈希为所述第一节点计算得到,或来自于第一客户端,所述第一客户端为所述第一交易的发起端。
第三方面,本申请提供了一种跨链交易方法,应用于跨链交易系统,所述跨链交易系统包括第一节点、第二节点和第三节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第一交易与第二交易为相关联的跨链交易,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述第三节点不维护所述第一区块链和所述第二区块链,所述方法包括:
所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
所述第二节点向所述第三节点发送所述第二交易的交易状态;
所述第三节点向所述第一节点发送所述第二交易的交易状态;
当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
在第三方面的一种可能设计中,所述方法还包括:
所述第三节点生成包括所述第二交易的交易状态的第一区块。
在第三方面的一种可能设计中,所述方法还包括:
所述第三节点接收至少一个第四节点发送的交易;
所述第三节点生成包括所述第二交易的交易状态的第一区块,包括:
所述第三节点基于接收所述至少一个第五节点发送的交易的时间以及接收所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
在第三方面的一种可能设计中,所述第三节点向所述第一节点发送第二交易的交易状态,包括:
所述第三节点向所述第一节点发送所述第一区块。
在第三方面的一种可能设计中,所述第二节点向所述第三节点发送所述第二交易的交易状态,包括:
所述第二节点向所述第三节点发送第四交易,所述第四交易包括所述第二交易的交易状态。
在第三方面的一种可能设计中,所述第一节点向第三节点发送所述第一交易的交易状态,包括:
所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第三方面的一种可能设计中,所述方法还包括:
所述第一节点计算得到所述第二交易的第一哈希,或接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
所述第三节点接收所述第二节点发送的第二交易的第二哈希;
所述第一节点接收所述第三节点发送的所述第二交易的第二哈希;
其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
在第三方面的一种可能设计中,所述跨链交易系统还包括第四节点,所述第一节点和所述第四节点属于同一个节点集群,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据之后,所述方法还包括:
所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据。
第四方面,本申请提供了一种第一节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第一交易与第二交易为相关联的跨链交易,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述第一节点包括:
处理模块,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块,用于获取所述第二交易的交易状态;
所述处理模块,还用于当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
在第四方面的一种可能设计中,所述获取模块,具体用于:
接收第三节点发送的所述第二交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
在第四方面的一种可能设计中,所述第一节点还包括:
发送模块,用于点向第三节点发送所述第一交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
在第四方面的一种可能设计中,所述发送模块,具体用于:
所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
在第四方面的一种可能设计中,所述处理模块,还用于:
计算得到所述第二交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
所述接收模块,具体用于接收第三节点发送第二交易的第二哈希;
其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
在第四方面的一种可能设计中,所述处理模块,还用于:
计算得到所述第一交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第一交易的第一哈希;
所述发送模块,还用于向所述第三节点发送所述第一交易的第一哈希。
在第四方面的一种可能设计中,所述发送模块,还用于:
向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,所述第一节点和所述第四节点属于同一个节点集群。
第五方面,本申请提供了一种第三节点,所述第三节点包括:
接收模块,用于接收第二节点发送的第二交易的交易状态,所述第二节点维护第二区块链,所述第二交易属于所述第二区块链;
发送模块,用于向所述第一节点发送所述第二交易的交易状态,以便所述第一节点基于所述第二交易的交易状态和第一交易的交易状态处理目标数据,其中所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据,所述第二交易与所述第一交易为相关联的跨链交易,所述第一交易属于第一区块链,第一节点维护所述第一区块链,所述第三节点不维护所述第一区块链和所述第二区块链。
在第五方面的一种可能设计中,所述第三节点还包括:
处理模块,用于生成包括所述第二交易的交易状态的第一区块。
在第五方面的一种可能设计中,所述接收模块,还用于:
接收至少一个第五节点发送的交易;
所述处理模块,具体用于:
基于接收到所述至少一个第五节点发送的交易以及所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
在第五方面的一种可能设计中,所述发送模块,具体用于:
向所述第一节点发送所述第一区块。
在第五方面的一种可能设计中,所述接收模块,具体用于:
接收所述第二节点发送的第四交易,所述第四交易包括所述第二交易的交易状态。
在第五方面的一种可能设计中,所述接收模块,还用于:
接收所述第二节点发送的第二交易的第二哈希;
所述发送模块,还用于:
向所述第一节点发送所述第二交易的第二哈希,以便所述第一节点基于所述第二交易的第二哈希与第二交易的第一哈希确定所述第二交易的交易数据的正确性,其中,所述第二交易的第一哈希为所述第一节点计算得到,或来自于第一客户端,所述第一客户端为所述第一交易的发起端。
第六方面,本申请实施例提供了一种跨链交易装置,包括:存储器、收发器、处理器以及总线系统;其中,该存储器用于存储程序和指令;该收发器用于在该处理器的控制下接收或发送信息;该处理器用于执行该存储器中的程序;该总线系统用于连接该存储器、该收发器以及该处理器,以使该存储器、该收发器以及该处理器进行通信;该处理器用于调用该存储器中的程序指令,执行如上述第一方面、第二方面所述的方法。
第七方面,本申请实施例提供了一种计算机可读存储介质,该计算机可读存储介质中存储有指令,当其在计算机上运行时,使得计算机执行上述第一方面、第二方面所述的方法。
本申请提供了一种跨链交易方法,应用于第一节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述方法包括:所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取所述第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
附图说明
图1为一种跨链交易方法的实施例示意图;
图2为本申请提供的一种区块链网络的架构示意图;
图3为本申请实施例提供的一种跨链交易方法的示意图;
图4为一种跨链交易方法的应用例示意图;
图5为本申请实施例的一种区块链网络的架构示意图;
图6为本申请实施例提供的一种跨链交易方法的示意图;
图7a为一种跨链交易的依赖关系示意图;
图7b为本申请实施例提供的一种跨链交易方法的示意图;
图8为本申请实施例中跨链交易装置的实施例示意图;
图9为本申请实施例中跨链交易装置的实施例示意图;
图10为本申请实施例中跨链交易装置的实施例示意图;
图11为本申请实施例提供的一种跨链交易方法的示意图;
图12a为一种跨链交易方法的应用例示意图;
图12b为一种跨链交易方法的应用例示意图;
图13为本申请实施例的一种区块链网络的架构示意图;
图14为本申请实施例提供的一种跨链交易方法的示意图;
图15a为一种跨链交易的依赖关系示意图;
图15b为本申请实施例提供的一种跨链交易方法的示意图;
图16为本申请实施例中跨链交易装置的实施例示意图;
图17为本申请实施例中跨链交易装置的实施例示意图;
图18为本申请实施例中跨链交易装置的一种结构示意图;
图19为本申请实施例中提供的一种服务器结构示意图。
具体实施方式
本申请实施例提供了一种跨链交易方法和装置,可以使得跨链交易实现在多个区块链上进行原子性执行。
本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,以便这里描述的本申请的实施例例如能够以除了在这里图示或描述的那些以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,意图在于覆盖不排他的包括,例如,包括了一系列步骤或单元的过程、方法、系统、产品或设备不必限于清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。
“区块链”,具体可指一个各节点通过共识机制达成的、具有分布式数据存储结构的P2P网络系统,该区块链内的数据分布在时间上相连的一个个“区块(block)”之内,后一区块包含前一区块的数据摘要,且根据具体的共识机制(如POW、POS、DPOS或PBFT等)的不同,达成全部或部分节点的数据全备份。区块链根据其网络节点的分布形式,可包括公有链、联盟链、私有链等。在实际的应用中,尤其是对联盟链的实际应用中,通常为不同的场景设置单独的区块链,例如用于处理房屋租赁业务场景的区块链、用于处理音乐作品版权使用业务场景的区块链等;而且对于在一个较大的应用场景中设置的区块链,还会为其开发相关的业务细化子链,例如用于处理房屋租赁业务场景的区块链主链,可以下挂多条房屋租赁下多种细分业务的区块链子链,如专门用于收录房屋租赁订单的区块链子链,专门用于收录可供租赁的房屋详情的区块链子链等,上述子链即为遵循上述区块链主链协议的多个实例。为实现可价值互连、信息互连的多区块链网络生态,跨区块链的数据访问或操作成为解决该问题的关键之道。
参照图1,图1为一种跨链交易方法的实施例示意图,如图1中示出的那样,跨链交 易方法,包括:
101、第一区块链执行第一交易,并生成区块。
102、将生成的区块发送到第二区块链。
103、第二区块链验证区块,并确定第一交易在第一区块链上是否执行成功。
104、若第一交易在第一区块链上执行成功,则第二区块链触发第三区块链执行第二交易。
105、第三区块链执行第二交易。
然而,如果因为某些原因而导致第三区块链执行第二交易失败,则需要撤销已经成功的交易(第一交易),若第一交易可能会无法撤销,则会出现相互关联的跨链交易(第一交易和第二交易)只有一部分(第一交易)成功执行,而另一部分(第二交易)未成功执行的情况。
需要说明的是,上述执行成功指的是根据交易数据更新了相应的状态机,换一种表述方式,上述执行成功指的是根据交易数据更新了相应的状态数据库。
为了解决上述问题,本申请实施例提供了一种跨链交易方法,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
参照图2,图2为本申请提供的一种区块链网络的架构示意图。
如图1所示,本申请提供的区块链网络包括:区块链1网络、区块链2网络、区块链3网络30、第一客户端130和第二客户端230。
其中,区块链1网络中包括节点集群110和节点集群120,其中,节点集群110包括多个节点peer,节点集群120包括多个节点peer,这些节点peer共同维护区块链1。
区块链2网络中包括节点集群210和节点集群220,其中,节点集群210包括多个节点peer,节点集群220包括多个节点peer,这些节点peer共同维护区块链2。
区块链3网络30中包括节点集群310、节点集群110和节点集群210,其中,节点集群310包括多个节点peer,节点集群110包括多个节点peer,节点集群210包括多个节点peer,这些节点peer共同维护区块链3。
其中,节点集群110既可以维护区块链1,也可以维护区块链3,节点集群210既可以维护区块链2,也可以维护区块链3,相当于节点集群110即可以获取区块链1包含的数据,也可以获取区块链3包含的数据,节点集群210即可以获取区块链2包含的数据,也可以获取区块链3包含的数据。
示例性的,用户可以在第一客户端130发起交易,第一客户端130可以生成相应的交易信息,并通过网络发送到集群110,集群110包括多个第一节点,第一节点可以作为背书节 点,对交易信息进行背书,并通过网络向第一客户端130发送背书响应。
第一客户端130可以对背书响应进行验证,并向节点集群120发送交易信息和背书响应,其中,集群120可以为排序集群,包括多个排序节点,排序节点可以对接收到的交易数据进行全局排序,将一批排序后的交易数据组合生成区块,并将区块传输到集群110。第一节点可以通过对区块进行验证进而确定交易的有效性,并将交易的有效性发送到集群310。
类似的,用户可以在第二客户端230发起交易,第二客户端230可以生成相应的交易信息,并通过网络发送到集群210,集群210包括多个第二节点,第二节点可以作为背书节点,对交易信息进行背书,并通过网络向第二客户端230发送背书响应。
第二客户端230可以对背书响应进行验证,并向节点集群220发送交易信息和背书响应,其中,集群220可以为排序集群,包括多个排序节点,排序节点可以对接收到的交易数据进行全局排序,将一批排序后的交易数据组合生成区块,并将区块传输到集群210。第一节点可以通过对区块进行验证进而确定交易的有效性,并将交易的有效性发送到集群310。
集群310可以为排序集群,包括多个第三节点,第三节点可以是排序节点,排序节点可以对接收到的交易数据进行全局排序,将一批排序后的交易数据组合生成区块,并将区块传输到集群110和集群210。
集群110可以将交易结果通过网络发送到第一客户端130,集群210可以将交易结果通过网络发送到第二客户端230。
需要说明的是,区块链是以区块为单位存储交易清单,区块链中的区块按照时间顺序生成,每个区块用于记录一段时间内产生的交易清单。区块链上所记录的所有交易清单即为账本(ledger),例如,区块链1上记录的账本为ledger1,区块链2上记录的账本为ledger2,区块链3上记录的账本为ledger3,本申请中,在不引起歧义的情况下,账本和区块链是可以互相替代的同等概念。
需要说明的是,上述系统架构仅为一种逻辑上的示意;在物理上,区块链网络中的一个节点在一台物理机(服务器)上,或者,多个区块链网络中的多个节点在同一个服务器上,一个节点具体可以是指服务器中运行的一个进程或者一系列进程,例如,区块链1网络中的节点和区块链2网络中的节点可以为一个服务器上运行的两个进程。
本申请中所描述的节点可以是指节点所在的服务器。
需要说明的是,图2中示出的区块链网络的架构示意图仅为一种示意,实际应用中还可以包括其他区块链网络,该区块链网络包括排序节点集群,以及可以维护区块链3的节点集群。
需要说明的是,本申请提供的跨链交易方法,可以应用于由多条区块链构成的多链系统。其中,本说明书各实施例的多链系统,可以包括多个遵循相同的区块链基础协议的同构区块链,也可包括遵循不同的区块链基础协议的异构区块链。上述多条区块链的架构不限于主链-侧链架构、主链-多子链架构或并行多链架构。
参照图3,图3为本申请实施例提供的一种跨链交易方法的示意图,如图3中示出的那样,跨链交易方法,包括:
301、第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验。
本申请实施例中,第一交易和第二交易为相互关联的跨链交易,其中,第一交易为属于第一区块链上的交易,第二交易为属于第二区块链上的交易。
接下来以第一区块链和第二区块链为联盟链fabric链为例进行说明。
示例性的,当用户在第一客户端发起跨链交易,该跨链交易包括相互关联的两个跨链子交易(第一交易和第二交易)。具体的,用户可以通过第一客户端实施交易操作。第一客户端可以根据用户的交易操作生成第一交易对应的交易数据。该交易操作可以是导致第一区块链和第二区块链的账本状态改变的操作。交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
需要说明的是,本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
上述交易标识可以是由客户端生成的。交易标识可以用于区分和确定交易对账本所执行的操作。上述交易标识可以是一个由数字和字母所构成的字符串。在一些应用场景中,对于每一个交易,可以使用哈希函数对该交易所对应的对账本所执行的操作、上述交易数据等进行处理,将所得到的哈希值作为该交易的交易标识。
具体的,第一客户端可以使用哈希函数对第一交易所对应的对账本所执行的操作、第一交易的交易数据等信息进行处理,将所得到的哈希值作为第一交易的交易标识。
需要说明的是,第二客户端可以执行与第一客户端相同或相似的动作,重复之处不再赘述。
上述客户端签名可以是第一客户端使用自身的私钥生成的签名。上述第一客户端的私钥可以是使用哈希算法生成的哈希值,也可以是使用随机数函数生成的随机数等。
上述合约标识是指区块链中的各节点共同遵守的智能合约的标识。上述智能合约可以是运行于区块链网络上的应用程序。在一些应用场景中,上述智能合约又称为链码。链码包括系统链码和用户链码,系统链码用来实现系统层面的功能,包括系统的配置,用户链码的部署、升级,用户交易的签名和验证策略等。用户链码实现用户的应用功能。链码可以被编译成一个独立的应用程序。
在区块链网络中,客户端发起的交易信息所指示的交易数据需要由一个或多个背书节点进行验证。
本申请实施例中,第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。
其中,每一个背书节点上可以预先安装智能合约。对于第一交易的交易信息,背书节点可以调用智能合约对第一交易进行验证。
可选的,在一种实施例中,上述背书节点可以是由第一客户端预先设定的。在一些应用场景中,第一客户端在向背书节点发送第一交易的交易信息之前,可以调用智能合约中的背书策略以从第一节点集群包含的节点中确定出为上述第一交易的交易信息进行背书的至少一个背书节点。也就是说,在这些应用场景中,上述背书节点可以由第一客户端基于预设背书策略,从第一节点集群包含的节点中选取。
上述背书节点收到第一客户端发送的上述第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。上述背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。此外,上述背书响应还可以包括上述交易信息对应的客户端的标识、以及交易标识。
上述背书节点的背书签名可以由背书节点根据其对应的私钥生成。上述背书节点的私钥可以是由哈希算法生成的哈希值,或者是由随机数生成函数生成的随机数。
本申请实施例中,背书节点可以将多个背书响应发送给客户端。
第一客户端可以接收各背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
可选的,在一种实施例中,上述第一客户端可以将根据用户操作生成的交易信息包括的客户端标识、交易标识,与接收到的预设背书节点发送的背书响应中的客户端标识以及交易标识进行匹配,若匹配成功,则进一步确定背书响应是否符合预设规则。
可选的,在一种实施例中,第一客户端可以确定上述背书响应是否包括背书节点对上述第一交易的交易信息的背书结果为通过的信息,若确定背书响应包括预设背书节点对第一交易的交易信息的背书结果为通过的信息,则确定背书响应符合预设规则;或者确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点的数量是否大于等于预设阈值,若确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点的数量大于等于预设阈值,则确定背书响应符合预设规则;或者确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点中是否包括权重大于预设权重阈值的背书节点;若确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点中包括权重大于预设权重阈值的背书节点,则确定背书响应符合预设规则。
需要说明的是,上述确定背书节点的方法,以及背书节点对第一交易的交易信息进行验证的方法是目前广泛研究和应用的公知技术,在此不再赘述。
需要说明的是,背书节点的数量可以为多个,则相应的背书响应也可以为多个,每个背书响应中包括一个背书节点的背书签名,即第一客户端可以接收到多个背书签名。
本申请实施例中,第一客户端确定背书响应符合预设规则之后,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二节点集群。
本申请实施例中,第二节点集群中包含的节点维护第一区块链,第二节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
第二节点集群中包含的多个排序节点可以为接收到的交易数据进行全局排序,并将一批排序后的交易数据组合生成区块结构。
在本实施例中,上述区块结构可以包括但不限于如下数据:当前区块号对应的、根据哈希算法得到的哈希值,上一区块号对应的哈希值,时间戳,以及多条交易数据。
当第二节点集群中的一个或多个排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由至少一个排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点集群,使得第一节点集群对M个区块进行验证,并将验证通过的区块依次添加到对应的区块链中。
本申请实施例中,第一节点集群中的节点可以接收到第三区块,该第三区块包括第一交易的交易数据以及与第一交易对应的多个背书签名。需要说明的是,为了方便描述,以下将第一节点集群中的节点描述为第一节点。
第一节点接收到包括第一交易的交易数据以及与第一交易对应的多个背书签名的区块,可以对该第三区块进行共识校验。具体的,第一节点可以对多个背书签名进行校验、对交易信息中的交易结构进行校验,以及对区块进行多版本并发控(multi version concurrency control,mvcc)校验等。
若第一节点对该第三区块的共识校验通过,则可以确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验。
若第一节点对该第三区块的共识校验不通过,则可以确定的交易状态为第三状态,所述第三状态表示交易未通过共识校验。
可选的,第一节点可以将该第三区块添加到第一区块链中,并在该第三区块中标注第一交易的交易状态。
本申请实施例中,第一节点在确定第一交易的交易状态为第一状态之后,即使未确定第二交易的交易状态,也将所述第三区块加到对应的区块链中,使得不会阻塞后续交易的执行。
在现有技术中,若第一节点对该区块的共识校验通过,则会在区块中与第一交易的交易状态相关的字段中标注为有效valid,并执行第一交易,具体的,第一节点可以更新第一交易对应的状态数据库(例如,账户余额以及交易时间等)。此时,若后续第二交易的交易状态为无效invalid时,由于第一交易对应的状态数据库中与第一交易相关的数据已经更新生效,此时第一交易已经执行,而第二交易并没有执行。
本申请实施例中,第一节点在确定第一交易通过共识校验时,可以在第三区块中与第一交易的交易状态相关的字段中标注为有效待定pending,且不修改第一节点的状态机。
需要说明的是,可选的,若第一节点确定第一交易的交易状态为第三状态(例如:无效invalid),则可以在第三区块中与第一交易的交易状态相关的字段中标注为无效invalid。
可选的,在一种实施例中,第一节点可以向第三节点集群的第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
可选的,在一种实施例中,第三交易可以包括交易状态指示信息,该交易状态指示信 息可以指示第一交易的交易状态,例如,交易状态指示信息可以是一个字符串,当第一交易的交易状态为第一状态时,交易状态指示信息可以为pending或其他可以指示共识校验通过的字符串,当第一交易的交易状态为第三状态时,有效性指示信息可以为invalid或其他可以指示共识校验不通过的字符串。
本申请实施例中,第三节点集群中包含的节点维护第三区块链,第三节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
本申请实施例中,第三节点集群还可以接收到第二节点发送的第二交易的交易状态,其中,第二交易的交易状态为第二节点确定,并向第三节点集群发送的。
在本实施例中,第三节点集群中包含的多个排序节点可以为接收到的交易进行全局排序,并将一批排序后的交易数据组合生成区块结构。
具体的,第三节点集群可以生成第二区块,第二区块包括第一交易的交易状态以及第二交易的交易状态。
需要说明的是,第一交易的交易状态和第二交易的交易状态可以在同一个区块上,也可以在不同的区块上,这里并不限定。
302、第一节点获取第二交易的交易状态。
本申请实施例中,第一节点可以获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
具体的,第二交易的交易状态可以为第一状态或第三状态,其中,第一状态表示交易通过共识校验,第三状态表示交易未通过共识校验。
303、当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。
本申请实施例中,第一节点获取第二交易的交易状态,进而可以确定第二交易的交易状态为第一状态还是第三状态,并当所述第二交易的交易状态为所述第一状态时,根据所述第一交易的交易数据修改所述第一节点的状态机。
例如,第一节点在确定第一交易的共识验证通过后,可以确定第一交易的交易状态为第一状态,示例性的,可以在第一交易的区块中标注其交易状态为待定pending,当第一节点确定第二交易的交易状态也为待定时,可以更新第一交易的区块中标注其交易状态为有效valid,并根据所述第一交易的交易数据修改所述第一节点的状态机。
本申请实施例中,第一节点获取第二交易的交易状态,进而可以确定第二交易的交易状态为第一状态还是第三状态,并当所述第二交易的交易状态为所述第三状态时,不根据所述第一交易的交易数据修改所述第一节点的状态机。
例如,第一节点在确定第一交易的共识验证通过后,可以确定第一交易的交易状态为第一状态,示例性的,可以在第一交易的区块中标注其交易状态为待定pending,当第一节点确定第二交易的交易状态为无效invalid时,可以更新第一交易的区块中标注其交易状态为无效invalid,同时,不根据所述第一交易的交易数据修改所述第一节点的状态机。
需要说明的是,上述实施例中,仅以跨链交易包括第一交易和第二交易为例进行了说 明,在实际应用中,跨链交易也可以包括超过两个的交易,本申请并不限定,具体实施例方式可参照上述实施例,这里不再赘述。
需要说明的是,在一种应用场景中,普通交易和跨链交易可能会存在一定的依赖关系,具体的,普通交易和跨链交易的交易数据之间可能存在一定的依赖关系,需要指出的是,本实施例中的普通交易为可以独立执行的交易。
例如,有一个跨链交易:跨链交易A和普通交易A,跨链交易A包括第一交易和第二交易。
第一交易需要更新A账户的余额,而普通交易A也需要更新A账户的余额,第一交易在时序上在第三交易之前。
此时,普通交易A需要第一交易完成之后,才能执行。
而由于第一交易属于跨链交易,因此第一交易的执行与否取决于第一交易和第二交易的交易结果,交易时间可能会很长,因此会使得普通交易A的等待时间可能会很长。
本实施例中,若第一节点除了处理第一交易之外,还需要处理第三交易,其中,第三交易为普通交易,即可以独立完成的交易,而不是跨链子交易,第三交易的交易数据中包括目标交易参数,相应的,第一交易的交易数据中也包括目标交易参数,且第三交易对应的执行时序在第一交易的执行时序之后,换一种表述方式,若第一节点先接收到第一交易所在的区块,或者,若第一交易和第三交易所在的区块为同一个区块,在该区块上,第三交易在第一交易之后。
此时,如果第一节点确定第一交易的交易状态之后,才确定第三交易的交易状态,则第三交易的等待时间可能会很长。
本申请实施例中,第一节点可以直接确定第三交易的交易状态为第三状态。
可选的,所述第一节点根据所述第一交易的交易数据更新所述第一节点的状态机之后,所述方法还包括:
所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已更新所述第一节点的状态机,所述第一节点和所述第四节点属于同一个节点集群。
可选的,在一种实施例中,第一节点在确定第一交易的交易状态,并根据第一交易的交易状态执行或不执行第一交易(根据第一交易的交易数据修改第一节点的状态机或者不根据第一交易的交易数据修改第一节点的状态机)之后,可以将第一节点完成第一交易的同步信息发送到第二节点集群,第二节点集群可以生成包括同步信息的区块,并进行排序出块,相应的,第一节点集群中除了第一节点之外的节点(第四节点)可以接受到第二节点集群发送的包括同步信息的区块。类似的,第一节点集群中除了第一节点之外的节点(第四节点)也可以将第一节点完成第一交易的同步信息发送到第二节点集群,第二节点集群可以生成包括同步信息的区块,并进行排序出块。
如果第一节点确定第一交易的交易状态,并根据第一交易的交易状态执行或不执行第一交易,且接收到了第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点已经完成,进而可以认为第一交易对第三交易不产生影响,可以正常进行第三交易。
如果第一节点还未确定第一交易的交易状态,但接收到了第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点已经完成,进而可以认为第一交易对第三交易不产生影响,可以正常进行第三交易。
如果第一节点确定第一交易的交易状态,但未接收到第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点没有完成,进而可以认为第一交易可能会对第三交易产生影响,第一节点可以直接确定第三交易的交易状态为第三状态。
如果第一节点未确定第一交易的交易状态,且未接收到第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点没有完成,进而可以认为第一交易可能会对第三交易产生影响,第一节点可以直接确定第三交易的交易状态为第三状态。
本申请提供了一种跨链交易方法,包括:第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
参照图4,图4为一种跨链交易方法的应用例示意图,具体的,跨链交易方法包括:
401、第一客户端接收用户的交易操作。
本申请实施例中,该交易操作可以是导致第一区块链和第二区块链的账本状态改变的操作。
402、第一客户端生成交易数据。
本申请实施例中,第一客户端可以根据用户的交易操作生成第一交易对应的交易数据,其中,交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。
403、第一客户端将交易数据发送到第二客户端。
本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据
4041、第一客户端生成交易信息。
本申请实施例中,第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
4042、第二客户端生成交易信息。
本申请实施例中,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
4051、第一客户端向第一背书节点发送交易请求。
本申请实施例中,第一背书节点可以是第一节点集群中的一部分或全部节点。第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。其中,每一个背书节点上可以预先安装智能合约。对于第一交易的交易信息,背书节点可以调用智能合约对第一交易进行验证。
4052、第二客户端向第二背书节点发送交易请求。
本申请实施例中,第二背书节点可以是第二节点集群中的一部分或全部节点。第二客户端在生成第二交易的交易信息之后,可以将该交易信息发送到第二节点集群中的背书节点。其中,每一个背书节点上可以预先安装智能合约。对于第二交易的交易信息,背书节点可以调用智能合约对第二交易进行验证。
4061、第一背书节点进行背书。
本申请实施例中,第一背书节点收到第一客户端发送的第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如第一背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。第一背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。
4062、第二背书节点进行背书。
本申请实施例中,第二背书节点收到第二客户端发送的第二交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第二交易。例如背书节点将第二交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第二交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。第二背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。
4071、第一背书节点向第一客户端发送背书响应。
4072、第二背书节点向第一客户端发送背书响应。
4081、第一客户端验证通过。
本申请实施例中,第一客户端可以接收第一背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
4082、第二客户端验证通过。
本申请实施例中,第二客户端可以接收第二背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
4091、第一客户端将交易信息和签名发送到第一排序节点。
本申请实施例中,若第一客户端确定第一背书节点发送的背书响应符合预设规则,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第一排序节点。
4092、第二客户端将交易信息和签名发送到第二排序节点。
本申请实施例中,若第二客户端确定第二背书节点发送的背书响应符合预设规则,则 可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二排序节点。
4101、第一排序节点生成区块。
4102、第二排序节点生成区块。
4111、第一排序节点将区块发送到第一节点。
本申请实施例中,当第一排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由第一排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点。
4112、第二排序节点将区块发送到第二节点。
本申请实施例中,当第二排序节点收到第二客户端传输的N个交易信息(至少包括第二交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由第二排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第二节点。
4121、第一节点验证区块,确定第一交易的交易状态。
本申请实施例中,第一节点接收到包括第一交易的交易信息以及与第一交易对应的多个背书签名的区块,可以对该区块进行验证。具体的,第一节点可以对多个背书签名进行验证、对交易信息中的交易结构进行验证,以及对区块进行多版本并发控(multi version concurrency control,mvcc)验证等。
4122、第二节点验证区块,确定第二交易的交易状态。
本申请实施例中,第二节点接收到包括第二交易的交易信息以及与第二交易对应的多个背书签名的区块,可以对该区块进行验证。具体的,第二节点可以对多个背书签名进行验证、对交易信息中的交易结构进行验证,以及对区块进行多版本并发控(multi version concurrency control,mvcc)验证等。
4131、第一节点将第一交易的交易状态发送到第三节点。
4132、第二节点将第二交易的交易状态发送到第三节点。
414、第三节点生成区块,并排序。
4151、第三节点将区块发送到第一节点。
4152、第三节点将区块发送到第二节点。
本申请实施例中,当第一排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个第一交易的背书响应中包括的多个背书签名,以及第二交易的交易信息以及多个第二交易的背书响应中包括的多个背书签名)后,可以由第三节点集群生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点和第二节点。
4161、第一节点根据第一交易的交易状态和第二交易的交易状态确定第一交易的交易状态。
4162、第二节点根据第一交易的交易状态和第二交易的交易状态确定第二交易的交易状态。
4171、第一节点根据第一交易的交易状态确定第一交易执行或不执行。
4172、第二节点根据第二交易的交易状态确定第二交易执行或不执行。
4181、第一节点将执行结果发送到第一客户端。
4182、第二节点将执行结果发送到第二客户端。
关于,第一节点如何根据第一交易的交易状态确定第一交易执行或不执行,以及第二节点如何根据第二交易的交易状态确定第一交易执行或不执行,可参照上述实施例的描述,这里不再赘述。
需要说明的是,以上为以第一区块链和第二区块链为联盟链fabric链为例进行的说明,当第一区块链和第二区块链为遵循不同的区块链基础协议的异构区块链时,例如,第一区块链可以是以太坊链,此时,第一节点在确定第一交易的交易状态为第一状态之后,可以在以太坊链上部署第一交易,并锁定第一交易,在接收到由第三节点集群发送的第二交易的交易状态之后,当所述第二交易的交易状态为所述第一状态时,确定所述第一交易的交易状态为第二状态,且当所述第一交易处于第二状态时,执行所述第一交易。
需要说明的是,本申请中的第一节点可以不属于以太坊链,而是新增的分布式节点集群的节点。
本申请实施例中,若所述第一交易的交易状态为第三状态,则不执行所述第一交易,具体的,第一节点可以指示以太坊链对第一交易执行回退,即指示以太坊链不执行第一交易。
本申请实施例中,若所述第一交易的交易状态为第二状态,则执行所述第一交易,具体的,第一节点可以指示以太坊链解锁第一交易,即指示以太坊链执行第一交易。
需要说明的是,若第一区块链为fabric链,第二区块链为以太坊链,则第一区块链执行上述实施例中关于fabric链的执行步骤,第二区块链执行上述实施例中关于以太坊链的执行步骤。
需要说明的是,在其他应用场景中,第一区块链或第二区块链还可以是比特币链,此处并不限定。
参照图5,图5为本申请实施例的一种区块链网络的架构示意图,如图5中示出的那样,区块链网络包括:区块链4网络40、区块链2网络20、区块链3网络30、第一客户端130、第二客户端230和节点集群510,其中,区块链4网络40对应的区块链为以太坊链。
本申请实施例中,区块链2网络20和第二客户端230的具体描述可参照图2对应的实施例的描述,这里不再赘述。
本申请实施例中,区块链4网络40中包括节点集群410,节点集群410包括多个节点peer,这些节点peer共同维护以太坊链。
节点集群510包括多个节点peer,和图1的架构示意不同的是,区块链3网络30不包括节点集群110,此时可以由节点集群510来完成节点集群110的功能,即节点集群510可以作为适配器提供节点集群110的功能。
示例性的,用户可以在第一客户端130发起交易,第一客户端130可以生成相应的交易信息,并通过网络发送到集群510,集群510包括多个第一节点,第一节点在确定交易的交易状态为第一状态之后,第一节点可以在节点集群410上部署交易,相应的,节点集群410可以锁定该交易。第一节点还可以将第一交易的交易状态发送到集群310。
类似的,第二节点可以将第二交易的交易状态发送到集群310。
集群310可以为排序集群,包括多个第三节点,第三节点可以是排序节点,排序节点可以对接收到的交易数据进行全局排序,将一批排序后的交易数据组合生成区块,并将区块传输到集群510和集群210。
集群510可以根据接收到的区块确定交易的交易状态,并当交易状态为第二状态时,指示节点集群410执行交易,当交易状态为第三状态时,指示节点集群410执行交易回退,即不执行交易。
在一些场景中,跨链交易包括多个相关联的跨链子交易,例如第一交易和第二交易,若第一交易为A用户向B用户转10个单位的货币,此时,第一交易为第一区块链上A账户的余额减10个单位的货币,第二交易为第二区块链上B账户的余额加10个单位的货币。
然而,由于客户端可能是不可信的,存在一定的欺诈风险,第一客户端和第二客户端发起的交易可能是不真实的,例如,第一客户端发起的交易为第一区块链上A账户的余额减10个单位的货币,而第二交易为第二区块链上B账户的余额加20个单位的货币,这会破坏既有的数据逻辑关系,是不可接受的。
为了解决上述技术问题,本申请提供了一种跨链交易方法。
参照图6,图6为本申请实施例提供的一种跨链交易方法的示意图,如图6中示出的那样,跨链交易方法包括:
601、第一节点获取第二交易的第一交易标识。
本申请实施例中,第一交易和第二交易为相互关联的跨链交易,其中,第一交易为属于第一区块链上的交易,第二交易为属于第二区块链上的交易。
示例性的,当用户在第一客户端发起跨链交易,该跨链交易包括相互关联的两个跨链子交易(第一交易和第二交易)。具体的,用户可以通过第一客户端实施交易操作。第一客户端可以根据用户的交易操作生成第一交易对应的交易数据。该交易操作可以是导致第一区块链和第二区块链的账本状态改变的操作。交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括第一交易的第一交易标识hash(tx1)。
其中,交易标识可以用于区分和确定交易对账本所执行的操作。上述第一交易的第一交易标识hash(tx1)可以是一个由数字和字母所构成的字符串。在一些应用场景中,对于每一个交易,可以使用哈希函数对该交易所对应的对账本所执行的操作、上述交易数据等进行处理,将所得到的哈希值作为该交易的交易标识。
需要说明的是,本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括第二交易的第二交易标识hash(tx2),由于交易标识可以区分和确定交易对账本所执行的操作,因此第二客户端生成的第二交易的第二交易标识hash(tx2)可以唯一表示第二交易执行的内容。
本申请实施例中,第一客户端除了生成第一交易的第一交易标识hash(tx1),还会生 成第二交易的第一交易标识exp_hash(tx2)。
可选的,在一种实施例中,第一客户端可以通过调用助手链码获取第二客户端“理应”生成的第二交易的第一交易标识exp_hash(tx2)。
具体的,第一客户端在根据用户的交易操作生成第二交易对应的交易数据之后,可以以该交易数据作为输入,通过调用助手链码生成第二交易的第一交易标识exp_hash(tx2),该第二交易的第一交易标识exp_hash(tx2)可以表示第二客户端应该执行的第二交易唯一对应的交易标识。
可选的,在一种实施例中,第一客户端可以不通过查询助手链码来获取第二交易的第一交易标识exp_hash(tx2),而是通过与第二客户端通信,得到第二客户端理应执行的链码和参数,并计算出第二交易的第一交易标识exp_hash(tx2)。
本申请实施例中,第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。其中,第一交易的交易信息包括第一交易标识exp_hash(tx2)以及第一交易的第一交易标识hash(tx1)。
上述背书节点收到第一客户端发送的上述第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。上述背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。此外,上述背书响应还可以包括上述交易信息对应的客户端的标识、以及第一交易标识exp_hash(tx2)和第一交易的第一交易标识hash(tx1)。
本申请实施例中,背书节点可以将多个背书响应发送给客户端。
第一客户端可以接收各背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
本申请实施例中,第一客户端确定背书响应符合预设规则之后,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二节点集群,其中第一交易的交易信息包括第一交易标识exp_hash(tx2)和第一交易的第一交易标识hash(tx1)。
本申请实施例中,第二节点集群中包含的节点维护第一区块链,第二节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
第二节点集群中包含的多个排序节点可以为接收到的交易数据进行全局排序,并将一批排序后的交易数据组合生成区块结构。
当第二节点集群中的一个或多个排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由至少一个排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点集群,使得第一节点集群对M个区块进行验证,并将验证通过的区块依次添加到对应的区块链中。
本申请实施例中,第一节点集群中的节点可以接收到一个区块,该区块包括第一交易的交易信息以及与第一交易对应的多个背书签名。需要说明的是,为了方便描述,以下将 第一节点集群中的节点描述为第一节点。
第一节点接收到包括第一交易的交易信息以及与第一交易对应的多个背书签名的区块,可以对该区块进行验证。关于第一节点如何对该区块进行验证,可参照上述实施例,这里不再赘述。
第一节点可以向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识hash(tx1),可选的,第四交易包括第二交易的第一交易标识exp_hash(tx2)。
本申请实施例中,第三节点集群中包含的节点维护第三区块链,第三节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
本申请实施例中,第三节点集群还可以接收到第二节点发送的第二交易的第二交易标识hash(tx2)和第一交易的第二交易标识exp_hash(tx1)。具体的,第三节点集群还可以接收到第二节点发送的第五交易,该第五交易可以包括第二交易的第二交易标识hash(tx2)和第一交易的第二交易标识exp_hash(tx1)。
本申请实施例中,第三节点集群中包含的多个排序节点可以为接收到的交易进行全局排序,并将一批排序后的交易数据组合生成区块结构。
具体的,第三节点集群可以生成第四区块,第四区块包括第二交易的第二交易标识hash(tx2)和第一交易的第二交易标识exp_hash(tx1),第四区块还可以包括第二交易的第一交易标识exp_hash(tx2)和第一交易的第一交易标识hash(tx1)。
需要说明的是,第二交易的第二交易标识hash(tx2)、第一交易的第二交易标识exp_hash(tx1)、第二交易的第一交易标识exp_hash(tx2)和第一交易的第一交易标识hash(tx1)可以在同一个区块,也可以在不同的区块,这里并不限定。
602、第一节点获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识。
本申请实施例中,第一节点可以获取所述第三区块链上的第四区块,该第四区块可以包括第二交易的第二交易标识hash(tx2),其中第二交易的第二交易标识hash(tx2)为第二交易真实执行对应的交易标识,其可以唯一指示具体执行中第二交易的交易数据。
可选的,第四区块还可以包括第一交易的第二交易标识exp_hash(tx1)。
类似的,第二节点可以接收到第三节点集群发送的第五区块,该第五区块可以包括第一交易的第一交易标识hash(tx1),其中第一交易的第一交易标识hash(tx1)为第一交易真实执行对应的交易标识,其可以唯一指示具体执行中第一交易的交易数据。
可选的,第五区块还可以包括第二交易的第一交易标识exp_hash(tx2)。
在一种实施例中,若第三节点集群生成的第四区块和第五区块为同一个区块,则第一节点可以接收到第三节点集群发送的区块,该区块包括第二交易的第二交易标识hash(tx2)、第一交易的第二交易标识exp_hash(tx1)、第一交易的第一交易标识hash(tx1)和第二交易的第一交易标识exp_hash(tx2)。
603、第一节点根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
本申请实施例中,第一节点可以通过判断第二交易的第二交易标识hash(tx2)与第二交易的第一交易标识exp_hash(tx2)是否相等,进而判断第二交易是否按照正确的交易数据执行。
具体的,由于第二交易的第一交易标识exp_hash(tx2)是第一客户端通过第二交易的交易数据生成的,其可以表示第一客户端认为第二交易应该执行的交易数据。而第二交易的第二交易标识hash(tx2)表示第二交易真实执行的交易数据。
因此,通过判断第二交易的第二交易标识hash(tx2)与第二交易的第一交易标识exp_hash(tx2)是否相等,可以确定第二交易是否按照正确的交易数据执行。
类似的,第二节点可以通过判断第一交易的第一交易标识hash(tx1)与第一交易的第二交易标识exp_hash(tx1)是否相等,进而判断第一交易是否按照正确的交易数据执行。
具体的,由于第一交易的第二交易标识exp_hash(tx1)是第二客户端通过第一交易的交易数据生成的,其可以表示第二客户端认为第一交易应该执行的交易数据。而第一交易的第一交易标识hash(tx1)表示第一交易真实执行的交易数据。
因此,通过判断第一交易的第一交易标识hash(tx1)与第一交易的第二交易标识exp_hash(tx1)是否相等,可以确定第一交易是否按照正确的交易数据执行。
可选的,若第一区块包括第一交易的第二交易标识exp_hash(tx1),则第一节点可以通过判断第一交易的第一交易标识hash(tx1)与第一交易的第二交易标识exp_hash(tx1)是否相等,进而获取到第二节点的判断结果。
若第二区块包括第二交易的第一交易标识exp_hash(tx2),则第二节点可以通过判断第二交易的第二交易标识hash(tx2)与第二交易的第一交易标识exp_hash(tx2)是否相等,进而获取到第一节点的判断结果。
本申请实施例中,若第一节点判断第二交易的第二交易标识hash(tx2)与第二交易的第一交易标识exp_hash(tx2)相等,则第一节点可以确定第二交易按照正确的交易数据执行。
本申请实施例中,若第二节点判断第一交易的第一交易标识hash(tx1)与第一交易的第二交易标识exp_hash(tx1)相等,则第二节点可以确定第一交易按照正确的交易数据执行。
本申请实施例中,若第一节点确定第一交易按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则可以执行第一交易。
本申请实施例中,若第一节点确定第一交易没有按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则不执行第一交易。
本申请实施例中,若第一节点确定第一交易按照正确的交易数据执行,且第二交易没有按照正确的交易数据执行,则不执行第一交易。
本申请实施例中,若第二节点确定第一交易按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则可以执行第二交易。
本申请实施例中,若第二节点确定第一交易没有按照正确的交易数据执行,且第二交 易按照正确的交易数据执行,则不执行第二交易。
本申请实施例中,若第二节点确定第一交易按照正确的交易数据执行,且第二交易没有按照正确的交易数据执行,则不执行第二交易。
示例性的,若第一交易为A用户向B用户转10个单位的货币,此时,第一交易为第一区块链上A账户的余额减10个单位的货币,第二交易为第二区块链上B账户的余额加10个单位的货币。
此时,第一客户端基于第一交易的交易数据(包括在第一区块链上A账户的余额减10个单位的货币)生成第一交易的第一交易标识hash(tx1),以及基于第二交易的交易数据(包括在第二区块链上B账户的余额加10个单位的货币)生成第二交易的第一交易标识exp_hash(tx2)。
同样,第二客户端基于第一交易的交易数据(包括在第一区块链上A账户的余额减10个单位的货币)生成第一交易的第二交易标识exp_hash(tx1),以及基于第二交易的交易数据(包括在第二区块链上B账户的余额加20个单位的货币)生成第二交易的第二交易标识hash(tx2),即第二客户端想在B账户上增加更多的货币。
之后,由于第一节点会接收到第三节点发送的第二交易的第二交易标识hash(tx2),由于第二交易标识hash(tx2)与第二交易的第一交易标识exp_hash(tx2)不同,则第一节点会确定第二交易执行的交易数据不正确,即第二客户端存在欺骗性为,则不执行第一交易。
需要说明的是,图6对应的实施例可以与图3对应的实施例同时进行,这里并不限定。
本申请实施例提供了一种跨链交易方法,包括:所述第一节点获取所述第二交易的第一交易标识;所述第一节点获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;所述第一节点根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。本申请实施例中,第一节点可以通过判断第二交易的第二交易标识与第二交易的第一交易标识是否相等,进而确定第二交易是否按照正确的交易数据执行,且在第二交易没有按照正确的交易数据执行时,不执行第一交易。
当区块链网络中存在多个跨链交易时,各个跨链交易可能会存在一定的依赖关系,具体的,各个跨链交易的交易数据之间存在一定的依赖关系,例如,有两个跨链交易:跨链交易A和跨链交易B,跨链交易A包括第一交易和第二交易,跨链交易B包括第三交易和第四交易,第一交易和第三交易为第一区块链上的交易,第二交易和第四交易为第二区块链上的交易。
第一交易需要更新A账户的余额,而第三交易也需要更新A账户的余额,第一交易在时序上在第三交易之前。
第二交易需要更新B账户的余额,而第四交易也需要更新B账户的余额,第二交易在时序上在第四交易之后。
此时,第三交易需要第一交易完成之后,才能执行。
第一交易和第二交易属于同一笔跨链交易,则第一交易的执行完成需要依赖于第二交 易的执行结果。
第二交易需要第四交易完成之后,才能执行。
第四交易和第三交易属于同一笔跨链交易,则第四交易的执行完成需要依赖于第三交易的执行结果。
即形成了死锁,两笔跨链交易谁都无法完成,造成交易执行阻塞,导致系统无法提供服务。
参照图7a,图7a为一种跨链交易的依赖关系示意图,如图7a中示出的那样,第一交易A1和第二交易B1属于同一笔跨链交易,第三交易A2和第四交易B2属于同一笔跨链交易,第一交易A1和第三交易A2具有时序依赖关系,即第一交易A1执行完成之后第三交易A2才可以执行,第四交易B2和第二交易B1具有时序依赖关系,即第四交易B2执行完成之后第二交易B1才可以执行。
此时第一交易A1、第二交易B1、第三交易A2和第四交易B2存在交易死锁的问题。
为了解决上述问题,参照图7b,图7b为本申请实施例提供的一种跨链交易方法的实施例的示意图,具体的,本实施例提供的跨链交易方法,包括:
701、第一节点接收第一交易的交易数据,所述第一交易的交易数据包括目标交易参数。
702、第一节点接收第二交易的交易数据。
703、若所述第二交易的交易数据包括所述目标交易参数,则确定所述第二交易的交易状态为无效。
可选的,本申请实施例中,所述第一交易和第三交易为相互关联的跨链交易,所述第二交易和第四交易为相互关联的跨链交易,所述第一交易和所述第二交易为第一区块链上的交易,所述第三交易和所述第四交易为第二区块链上的交易。
例如,第一交易为A账户的余额减去5单位的货币,第二交易为A账户的余额减去10单位的货币,第三交易为B账户的余额加上5单位的货币,第四交易为B账户的余额加上10单位的货币。
此时,第一交易的交易数据包括目标交易参数“A账户”,第二交易的交易数据包括目标交易参数“A账户”,则第一节点可以直接确定第二交易的交易状态为无效,进行不执行第二交易,即不更新第二交易对应的状态数据库。
本申请实施例中,若确定存在会出现交易死锁情况的跨链交易,则确定其中一笔交易的交易状态为无效,进而可以解决由交易死锁造成的交易执行阻塞。
下面对本申请中一个实施例对应的跨链交易装置进行详细描述,请参阅图8,图8为本申请实施例中跨链交易装置的实施例示意图。本申请实施例中的跨链交易装置800包括:
处理模块801,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块802,用于获取第二交易的交易状态;
所述处理模块801,还用于当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。
本申请实施例中,处理模块801确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;获取模块802获取第二交易的交易状态;所述处理模块801当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
可选的,获取模块802,具体用于:获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
可选的,跨链交易装置还包括:发送模块803,用于向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
可选的,发送模块803,还用于向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
可选的,所述处理模块801,还用于当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
可选的,跨链交易装置还包括:接收模块804,具体用于:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
可选的,获取模块802,还用于:
获取第二交易的第一交易标识;
获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述处理模块801还用于:
根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
可选的,所述获取模块802,还用于:
获取所述第一交易的第一交易标识;
可选的,所述发送模块803,还用于:
向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
可选的,所述发送模块803还用于:
向第四节点广播同步信息,所述同步信息用于表示所述第一节点已更新所述第一节点的状态机,所述第一节点和所述第四节点属于同一个节点集群。
下面对本申请中一个实施例对应的跨链交易装置进行详细描述,请参阅图8,图8为本申请实施例中跨链交易装置的实施例示意图。本申请实施例中的跨链交易装置800包括:
处理模块801,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块802,用于获取第二交易的交易状态;
所述处理模块801,还用于当所述第二交易的交易状态为所述第三状态时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
可选的,获取模块802,具体用于:获取第三区块链上的第一区块,其中,所述第一节点和第三节点维护所述第三区块链,所述第一区块包括所述第二交易的交易状态。
可选的,跨链交易装置还包括:发送模块803,用于向所述第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
可选的,发送模块803,还用于向第三节点发送第四交易,所述第四交易包括超时信息,所述第一节点和所述第三节点维护所述第三区块链;
可选的,所述处理模块801,还用于当所述第一节点未获取到所述第二交易的交易状态,且获取到第三区块链上包括所述超时信息的第二区块时,所述第一节点不根据所述第一交易的交易数据修改所述第一节点的状态机。
可选的,跨链交易装置还包括:接收模块804,具体用于:
所述第一节点对所述第一交易进行共识校验;
当所述第一交易通过所述共识校验时,所述第一节点确定所述第一交易的交易状态为所述第一状态;
所述第一节点将第三区块加到第一区块链中,其中,所述第三区块包括所述第一交易的交易数据,所述第一节点维护所述第一区块链。
可选的,获取模块802,还用于:
获取第二交易的第一交易标识;
获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二交易标识;
所述处理模块801还用于:
根据所述第四区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
可选的,所述获取模块802,还用于:
获取所述第一交易的第一交易标识;
可选的,所述发送模块803,还用于:
向所述第三节点发送第四交易,所述第四交易包括所述第一交易的第一交易标识。
下面对本申请中一个实施例对应的跨链交易装置进行详细描述,请参阅图9,图9为本申请实施例中跨链交易装置的实施例示意图。本申请实施例中的跨链交易装置900包括:
获取模块901,用于获取第二交易的第一交易标识,所述第二交易属于第二区块链上的交易,所述第二交易与第一交易为相互关联的跨链交易,所述第一交易为第一区块链上的交易,所述第一节点维护第一区块链;接收第三节点发送的第一区块,所述第一区块包 括第二交易的第二交易标识;
处理模块902,用于根据所述第一区块,判断所述第二交易的第一交易标识与所述第二交易的第二交易标识是否相等。
可选的,跨链交易装置900还包括:发送模块903,用于向所述第三节点发送所述第二交易的第一交易标识。
可选的,所述获取模块901,还用于:获取所述第一交易的第一交易标识;
所述发送模块903,还用于向所述第三节点发送所述第一交易的第一交易标识。
可选的,所述第一区块还包括第一交易的第二交易标识;
所述处理模块902,具体用于根据所述第一区块,判断所述第一交易的第一交易标识与所述第一交易的第二交易标识是否相等。
下面对本申请中一个实施例对应的跨链交易装置进行详细描述,请参阅图10,图10为本申请实施例中跨链交易装置的实施例示意图。本申请实施例中的跨链交易装置1000包括:
接收模块1001,用于接收第一节点发送的第一交易的第一交易标识,所述第一节点维护第一区块链,所述第一交易为第一区块链上的交易;接收第二节点发送的第二交易的第二交易标识,所述第二节点维护第二区块链,所述第一交易与所述第二交易为相互关联的跨链交易,所述第二交易为所述第二区块链上的交易;
处理模块1002,用于生成第一区块,所述第一区块包括所述第二交易的第二交易标识;生成第二区块,所述第二区块包括所述第一交易的第一交易标识;
发送模块1003,用于向所述第一节点发送所述第一区块;向所述第二节点发送所述第二区块。
可选的,所述接收模块1001,还用于:接收第一节点发送的第二交易的第一交易标识;
所述第二区块还包括:所述第二交易的第一交易标识。
可选的,所述接收模块1001,还用于:接收第二节点发送的第一交易的第二交易标识;
所述第一区块还包括:所述第一交易的第二交易标识。
参照图11,图11为本申请实施例提供的一种跨链交易方法的示意图,如图11中示出的那样,跨链交易方法,包括:
301、所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验。
本申请实施例中,第一交易和第二交易为相互关联的跨链交易,其中,第一交易为属于第一区块链上的交易,第二交易为属于第二区块链上的交易。
本申请实施例中,第一交易为属于第一区块链上的交易可以理解为,第一交易的交易操作可以导致第一区块链的账本状态改变。类似的,第二交易为属于第二区块链上的交易可以理解为,第二交易的交易操作可以导致第二区块链的账本状态改变。
接下来以第一区块链和第二区块链为联盟链fabric链为例进行说明。
示例性的,当用户在第一客户端发起跨链交易,该跨链交易包括相互关联的两个跨链子交易(第一交易和第二交易)。具体的,用户可以通过第一客户端实施交易操作。第一客户端可以根据用户的交易操作生成第一交易对应的交易数据。该交易操作可以是导致第一区块链和第二区块链的账本状态改变的操作。交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
需要说明的是,本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
上述交易标识可以是由客户端生成的。交易标识可以用于区分和确定交易对账本所执行的操作。上述交易标识可以是一个由数字和字母所构成的字符串。在一些应用场景中,对于每一个交易,可以使用哈希函数对该交易所对应的对账本所执行的操作、上述交易数据等进行处理,将所得到的哈希值作为该交易的交易标识。
具体的,第一客户端可以使用哈希函数对第一交易所对应的对账本所执行的操作、第一交易的交易数据等信息进行处理,将所得到的哈希值作为第一交易的交易标识。
需要说明的是,第二客户端可以执行与第一客户端相同或相似的动作,重复之处不再赘述。
上述客户端签名可以是第一客户端使用自身的私钥生成的签名。上述第一客户端的私钥可以是使用哈希算法生成的哈希值,也可以是使用随机数函数生成的随机数等。
上述合约标识是指区块链中的各节点共同遵守的智能合约的标识。上述智能合约可以是运行于区块链网络上的应用程序。在一些应用场景中,上述智能合约又称为链码。链码包括系统链码和用户链码,系统链码用来实现系统层面的功能,包括系统的配置,用户链码的部署、升级,用户交易的签名和验证策略等。用户链码实现用户的应用功能。链码可以被编译成一个独立的应用程序。
在区块链网络中,客户端发起的交易信息所指示的交易数据需要由一个或多个背书节点进行验证。
本申请实施例中,第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。
其中,每一个背书节点上可以预先安装智能合约。对于第一交易的交易信息,背书节点可以调用智能合约对第一交易进行验证。
可选的,在一种实施例中,上述背书节点可以是由第一客户端预先设定的。在一些应用场景中,第一客户端在向背书节点发送第一交易的交易信息之前,可以调用智能合约中的背书策略以从第一节点集群包含的节点中确定出为上述第一交易的交易信息进行背书的至少一个背书节点。也就是说,在这些应用场景中,上述背书节点可以由第一客户端基于 预设背书策略,从第一节点集群包含的节点中选取。
上述背书节点收到第一客户端发送的上述第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。上述背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。此外,上述背书响应还可以包括上述交易信息对应的客户端的标识、以及交易标识。
上述背书节点的背书签名可以由背书节点根据其对应的私钥生成。上述背书节点的私钥可以是由哈希算法生成的哈希值,或者是由随机数生成函数生成的随机数。
本申请实施例中,背书节点可以将多个背书响应发送给客户端。
第一客户端可以接收各背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
可选的,在一种实施例中,上述第一客户端可以将根据用户操作生成的交易信息包括的客户端标识、交易标识,与接收到的预设背书节点发送的背书响应中的客户端标识以及交易标识进行匹配,若匹配成功,则进一步确定背书响应是否符合预设规则。
可选的,在一种实施例中,第一客户端可以确定上述背书响应是否包括背书节点对上述第一交易的交易信息的背书结果为通过的信息,若确定背书响应包括预设背书节点对第一交易的交易信息的背书结果为通过的信息,则确定背书响应符合预设规则;或者确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点的数量是否大于等于预设阈值,若确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点的数量大于等于预设阈值,则确定背书响应符合预设规则;或者确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点中是否包括权重大于预设权重阈值的背书节点;若确定接收到的、所指示的背书结果为通过的背书响应所对应的背书节点中包括权重大于预设权重阈值的背书节点,则确定背书响应符合预设规则。
需要说明的是,上述确定背书节点的方法,以及背书节点对第一交易的交易信息进行验证的方法是目前广泛研究和应用的公知技术,在此不再赘述。
需要说明的是,背书节点的数量可以为多个,则相应的背书响应也可以为多个,每个背书响应中包括一个背书节点的背书签名,即第一客户端可以接收到多个背书签名。
本申请实施例中,第一客户端确定背书响应符合预设规则之后,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二节点集群。
本申请实施例中,第二节点集群中包含的节点维护第一区块链,第二节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
第二节点集群中包含的多个排序节点可以为接收到的交易数据进行全局排序,并将一批排序后的交易数据组合生成区块结构。
在本实施例中,上述区块结构可以包括但不限于如下数据:当前区块号对应的、根据哈希算法得到的哈希值,上一区块号对应的哈希值,时间戳,以及多条交易数据。
当第二节点集群中的一个或多个排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由至少一个排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点集群,使得第一节点集群对M个区块进行验证,并将验证通过的区块依次添加到对应的区块链中。
本申请实施例中,第一节点集群中的节点可以接收到第三区块,该第三区块包括第一交易的交易数据以及与第一交易对应的多个背书签名。需要说明的是,为了方便描述,以下将第一节点集群中的节点描述为第一节点。
第一节点接收到包括第一交易的交易数据以及与第一交易对应的多个背书签名的区块,可以对该第三区块进行共识校验。具体的,第一节点可以对多个背书签名进行校验、对交易信息中的交易结构进行校验,以及对区块进行多版本并发控(multi version concurrency control,mvcc)校验等。
若第一节点对该第三区块的共识校验通过,则可以确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验。
若第一节点对该第三区块的共识校验不通过,则可以确定的交易状态为第三状态,所述第三状态表示交易未通过共识校验。
可选的,第一节点可以将该第三区块添加到第一区块链中,并在该第三区块中标注第一交易的交易状态。
本申请实施例中,第一节点在确定第一交易的交易状态为第一状态之后,即使未确定第二交易的交易状态,也将所述第三区块加到对应的区块链中,使得不会阻塞后续交易的执行。
在现有技术中,若第一节点对该区块的共识校验通过,则会在区块中与第一交易的交易状态相关的字段中标注为有效valid,并执行第一交易,具体的,第一节点可以更新第一交易对应的状态数据库(例如,账户余额以及交易时间等)。此时,若后续第二交易的交易状态为无效invalid时,由于第一交易对应的状态数据库中与第一交易相关的数据已经更新生效,此时第一交易已经执行,而第二交易并没有执行。
本申请实施例中,第一节点在确定第一交易通过共识校验时,可以在第三区块中与第一交易的交易状态相关的字段中标注为有效待定pending,且不修改第一节点的状态机。
需要说明的是,可选的,若第一节点确定第一交易的交易状态为第三状态(例如:无效invalid),则可以在第三区块中与第一交易的交易状态相关的字段中标注为无效invalid。
可选的,在一种实施例中,第一节点可以向第三节点集群的第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
可选的,在一种实施例中,第三交易可以包括交易状态指示信息,该交易状态指示信息可以指示第一交易的交易状态,例如,交易状态指示信息可以是一个字符串,当第一交易的交易状态为第一状态时,交易状态指示信息可以为pending或其他可以指示共识校验通过的字符串,当第一交易的交易状态为第三状态时,有效性指示信息可以为invalid或其他可以指示共识校验不通过的字符串。
本申请实施例中,第三节点集群中包含的节点维护第三区块链,第三节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
本申请实施例中,第三节点集群还可以接收到第二节点发送的第二交易的交易状态,其中,第二交易的交易状态为第二节点确定,并向第三节点集群发送的。
在本实施例中,第三节点集群中包含的多个排序节点可以为接收到的交易进行全局排序,并将一批排序后的交易数据组合生成区块结构。
具体的,第三节点集群可以生成第一区块,第一区块包括第一交易的交易状态以及第二交易的交易状态。
需要说明的是,第一交易的交易状态和第二交易的交易状态可以在同一个区块上,也可以在不同的区块上,这里并不限定。
302、第一节点获取第二交易的交易状态。
本申请实施例中,第一节点可以获取第三区块链上的第一区块,所述第一区块包括所述第二交易的交易状态。
具体的,第二交易的交易状态可以为第一状态或第三状态,其中,第一状态表示交易通过共识校验,第三状态表示交易未通过共识校验。所述第一节点可以接收第三节点发送的包括所述第二交易的交易状态的第一区块。
303、当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
本申请实施例中,第一节点获取第二交易的交易状态,进而可以确定第二交易的交易状态为第一状态还是第三状态,并当所述第二交易的交易状态为所述第一状态时,根据所述第一交易的交易数据修改所述第一节点的状态机。
例如,第一节点在确定第一交易的共识验证通过后,可以确定第一交易的交易状态为第一状态,示例性的,可以在第一交易的区块中标注其交易状态为待定pending,当第一节点确定第二交易的交易状态也为待定时,可以更新第一交易的区块中标注其交易状态为有效valid,并根据所述第一交易的交易数据修改所述第一节点的状态机。
本申请实施例中,第一节点获取第二交易的交易状态,进而可以确定第二交易的交易状态为第一状态还是第三状态,并当所述第二交易的交易状态为所述第三状态时,不根据所述第一交易的交易数据修改所述第一节点的状态机。
例如,第一节点在确定第一交易的共识验证通过后,可以确定第一交易的交易状态为第一状态,示例性的,可以在第一交易的区块中标注其交易状态为待定pending,当第一节点确定第二交易的交易状态为无效invalid时,可以更新第一交易的区块中标注其交易状态为无效invalid,同时,不根据所述第一交易的交易数据修改所述第一节点的状态机。
需要说明的是,上述实施例中,仅以跨链交易包括第一交易和第二交易为例进行了说明,在实际应用中,跨链交易也可以包括超过两个的交易,本申请并不限定,具体实施例方式可参照上述实施例,这里不再赘述。
需要说明的是,在一种应用场景中,普通交易和跨链交易可能会存在一定的依赖关系,具体的,普通交易和跨链交易的交易数据之间可能存在一定的依赖关系,需要指出的是,本实施例中的普通交易为可以独立执行的交易。
例如,有一个跨链交易:跨链交易A和普通交易A,跨链交易A包括第一交易和第二交易。
第一交易需要更新A账户的余额,而普通交易A也需要更新A账户的余额,第一交易在时序上在第三交易之前。
此时,普通交易A需要第一交易完成之后,才能执行。
而由于第一交易属于跨链交易,因此第一交易的执行与否取决于第一交易和第二交易的交易结果,交易时间可能会很长,因此会使得普通交易A的等待时间可能会很长。
本实施例中,若第一节点除了处理第一交易之外,还需要处理第三交易,其中,第三交易为普通交易,即可以独立完成的交易,而不是跨链子交易,第三交易的交易数据中包括目标交易参数,相应的,第一交易的交易数据中也包括目标交易参数,且第三交易对应的执行时序在第一交易的执行时序之后,换一种表述方式,若第一节点先接收到第一交易所在的区块,或者,若第一交易和第三交易所在的区块为同一个区块,在该区块上,第三交易在第一交易之后。
此时,如果第一节点确定第一交易的交易状态之后,才确定第三交易的交易状态,则第三交易的等待时间可能会很长。
本申请实施例中,第一节点可以直接确定第三交易的交易状态为第三状态。
可选的,所述第一节点根据所述第一交易的交易数据更新所述第一节点的状态机之后,所述方法还包括:
所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已更新所述第一节点的状态机,所述第一节点和所述第四节点属于同一个节点集群。
可选的,在一种实施例中,第一节点在确定第一交易的交易状态,并根据第一交易的交易状态执行或不执行第一交易(根据第一交易的交易数据修改第一节点的状态机或者不根据第一交易的交易数据修改第一节点的状态机)之后,可以将第一节点完成第一交易的同步信息发送到第二节点集群,第二节点集群可以生成包括同步信息的区块,并进行排序出块,相应的,第一节点集群中除了第一节点之外的节点(第四节点)可以接受到第二节点集群发送的包括同步信息的区块。类似的,第一节点集群中除了第一节点之外的节点(第四节点)也可以将第一节点完成第一交易的同步信息发送到第二节点集群,第二节点集群可以生成包括同步信息的区块,并进行排序出块。
如果第一节点确定第一交易的交易状态,并根据第一交易的交易状态执行或不执行第一交易,且接收到了第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点已经完成,进而可以认为第一交易对第三交易不产生影响,可以正常进行第三交易。
如果第一节点还未确定第一交易的交易状态,但接收到了第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点已经完成,进而可以认为第 一交易对第三交易不产生影响,可以正常进行第三交易。
如果第一节点确定第一交易的交易状态,但未接收到第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点没有完成,进而可以认为第一交易可能会对第三交易产生影响,第一节点可以直接确定第三交易的交易状态为第三状态。
如果第一节点未确定第一交易的交易状态,且未接收到第一节点集群中其他节点发送的第一交易的同步信息,则可以确定该第一交易在其他节点没有完成,进而可以认为第一交易可能会对第三交易产生影响,第一节点可以直接确定第三交易的交易状态为第三状态。
本申请提供了一种跨链交易方法,包括:第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;所述第一节点获取第二交易的交易状态;当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
参照图12a,图12a为一种跨链交易方法的应用例示意图,具体的,跨链交易方法包括:
4011、第一节点确定第一交易的交易状态为第一状态;
4012、第二节点确定第二交易的交易状态为第一状态;
4021、第一节点发送所述第二交易的交易状态;
4021、第二节点发送所述第二交易的交易状态;
4031、第三节点生成包括第一交易的交易状态的区块;
4032、第三节点生成包括第二交易的交易状态的区块;
4041、第三节点发送第二交易的交易状态;
4042、第三节点发送所述第一交易的交易状态;
4051、第一节点当第二交易的交易状态为第一状态时,根据第一交易的交易数据修改目标数据;
4052、第二节点当第一交易的交易状态为第一状态时,根据第一交易的交易数据修改目标数据。
关于步骤4011至步骤4052的具体描述可参照上述实施例,这里不再赘述。
更具体的,参照图12b,图12b为一种跨链交易方法的应用例示意图,具体的,跨链交易方法包括:
501、第一客户端接收用户的交易操作。
本申请实施例中,该交易操作可以是导致第一区块链和第二区块链的账本状态改变的 操作。
502、第一客户端生成交易数据。
本申请实施例中,第一客户端可以根据用户的交易操作生成第一交易对应的交易数据,其中,交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。
503、第一客户端将交易数据发送到第二客户端。
本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据
5041、第一客户端生成交易信息。
本申请实施例中,第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
5042、第二客户端生成交易信息。
本申请实施例中,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括交易标识、交易要调用的合约的合约标识、合约方法、交易数据以及客户端签名等。
5051、第一客户端向第一背书节点发送交易请求。
本申请实施例中,第一背书节点可以是第一节点集群中的一部分或全部节点。第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。其中,每一个背书节点上可以预先安装智能合约。对于第一交易的交易信息,背书节点可以调用智能合约对第一交易进行验证。
5052、第二客户端向第二背书节点发送交易请求。
本申请实施例中,第二背书节点可以是第二节点集群中的一部分或全部节点。第二客户端在生成第二交易的交易信息之后,可以将该交易信息发送到第二节点集群中的背书节点。其中,每一个背书节点上可以预先安装智能合约。对于第二交易的交易信息,背书节点可以调用智能合约对第二交易进行验证。
5061、第一背书节点进行背书。
本申请实施例中,第一背书节点收到第一客户端发送的第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如第一背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。第一背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。
5062、第二背书节点进行背书。
本申请实施例中,第二背书节点收到第二客户端发送的第二交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第二交易。例如背书节点将第二交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第二交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。第二背书节点可以将上述读操作集合和 写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。
5071、第一背书节点向第一客户端发送背书响应。
5072、第二背书节点向第一客户端发送背书响应。
5081、第一客户端验证通过。
本申请实施例中,第一客户端可以接收第一背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
5082、第二客户端验证通过。
本申请实施例中,第二客户端可以接收第二背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
5091、第一客户端将交易信息和签名发送到第一排序节点。
本申请实施例中,若第一客户端确定第一背书节点发送的背书响应符合预设规则,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第一排序节点。
5092、第二客户端将交易信息和签名发送到第二排序节点。
本申请实施例中,若第二客户端确定第二背书节点发送的背书响应符合预设规则,则可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二排序节点。
5101、第一排序节点生成区块。
5102、第二排序节点生成区块。
5111、第一排序节点将区块发送到第一节点。
本申请实施例中,当第一排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由第一排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点。
5112、第二排序节点将区块发送到第二节点。
本申请实施例中,当第二排序节点收到第二客户端传输的N个交易信息(至少包括第二交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由第二排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第二节点。
5121、第一节点验证区块,确定第一交易的交易状态。
本申请实施例中,第一节点接收到包括第一交易的交易信息以及与第一交易对应的多个背书签名的区块,可以对该区块进行验证。具体的,第一节点可以对多个背书签名进行验证、对交易信息中的交易结构进行验证,以及对区块进行多版本并发控(multi version concurrency control,mvcc)验证等。
5122、第二节点验证区块,确定第二交易的交易状态。
本申请实施例中,第二节点接收到包括第二交易的交易信息以及与第二交易对应的多个背书签名的区块,可以对该区块进行验证。具体的,第二节点可以对多个背书签名进行验证、对交易信息中的交易结构进行验证,以及对区块进行多版本并发控(multi version concurrency control,mvcc)验证等。
5131、第一节点将第一交易的交易状态发送到第三节点。
5132、第二节点将第二交易的交易状态发送到第三节点。
514、第三节点生成区块,并排序。
5151、第三节点将区块发送到第一节点。
5152、第三节点将区块发送到第二节点。
本申请实施例中,当第一排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个第一交易的背书响应中包括的多个背书签名,以及第二交易的交易信息以及多个第二交易的背书响应中包括的多个背书签名)后,可以由第三节点集群生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点和第二节点。
5161、第一节点根据第一交易的交易状态和第二交易的交易状态确定第一交易的交易状态。
5162、第二节点根据第一交易的交易状态和第二交易的交易状态确定第二交易的交易状态。
5171、第一节点根据第一交易的交易状态确定第一交易执行或不执行。
5172、第二节点根据第二交易的交易状态确定第二交易执行或不执行。
5181、第一节点将执行结果发送到第一客户端。
5182、第二节点将执行结果发送到第二客户端。
关于,第一节点如何根据第一交易的交易状态确定第一交易执行或不执行,以及第二节点如何根据第二交易的交易状态确定第一交易执行或不执行,可参照上述实施例的描述,这里不再赘述。
需要说明的是,以上为以第一区块链和第二区块链为联盟链fabric链为例进行的说明,当第一区块链和第二区块链为遵循不同的区块链基础协议的异构区块链时,例如,第一区块链可以是以太坊链,此时,第一节点在确定第一交易的交易状态为第一状态之后,可以在以太坊链上部署第一交易,并锁定第一交易,在接收到由第三节点集群发送的第二交易的交易状态之后,当所述第二交易的交易状态为所述第一状态时,确定所述第一交易的交易状态为第二状态,且当所述第一交易处于第二状态时,执行所述第一交易。
需要说明的是,本申请中的第一节点可以不属于以太坊链,而是新增的分布式节点集群的节点。
本申请实施例中,若所述第一交易的交易状态为第三状态,则不执行所述第一交易,具体的,第一节点可以指示以太坊链对第一交易执行回退,即指示以太坊链不执行第一交易。
本申请实施例中,若所述第一交易的交易状态为第二状态,则执行所述第一交易,具体的,第一节点可以指示以太坊链解锁第一交易,即指示以太坊链执行第一交易。
需要说明的是,若第一区块链为fabric链,第二区块链为以太坊链,则第一区块链执行上述实施例中关于fabric链的执行步骤,第二区块链执行上述实施例中关于以太坊链的执行步骤。
需要说明的是,在其他应用场景中,第一区块链或第二区块链还可以是比特币链,此 处并不限定。
参照图13,图13为本申请实施例的一种区块链网络的架构示意图,如图13中示出的那样,区块链网络包括:区块链4网络40、区块链2网络、区块链3网络30、第一客户端130、第二客户端230和节点集群510,其中,区块链4网络40对应的区块链为以太坊链。
本申请实施例中,区块链2网络和第二客户端230的具体描述可参照图2对应的实施例的描述,这里不再赘述。
本申请实施例中,区块链4网络40中包括节点集群410,节点集群410包括多个节点peer,这些节点peer共同维护以太坊链。
节点集群510包括多个节点peer,和图1的架构示意不同的是,区块链3网络30不包括节点集群110,此时可以由节点集群510来完成节点集群110的功能,即节点集群510可以作为适配器提供节点集群110的功能。
示例性的,用户可以在第一客户端130发起交易,第一客户端130可以生成相应的交易信息,并通过网络发送到集群510,集群510包括多个第一节点,第一节点在确定交易的交易状态为第一状态之后,第一节点可以在节点集群410上部署交易,相应的,节点集群410可以锁定该交易。第一节点还可以将第一交易的交易状态发送到集群310。
类似的,第二节点可以将第二交易的交易状态发送到集群310。
集群310可以为排序集群,包括多个第三节点,第三节点可以是排序节点,排序节点可以对接收到的交易数据进行全局排序,将一批排序后的交易数据组合生成区块,并将区块传输到集群510和集群210。
集群510可以根据接收到的区块确定交易的交易状态,并当交易状态为第二状态时,指示节点集群410执行交易,当交易状态为第三状态时,指示节点集群410执行交易回退,即不执行交易。
在一些场景中,跨链交易包括多个相关联的跨链子交易,例如第一交易和第二交易,若第一交易为A用户向B用户转10个单位的货币,此时,第一交易为第一区块链上A账户的余额减10个单位的货币,第二交易为第二区块链上B账户的余额加10个单位的货币。
然而,由于客户端可能是不可信的,存在一定的欺诈风险,第一客户端和第二客户端发起的交易可能是不真实的,例如,第一客户端发起的交易为第一区块链上A账户的余额减10个单位的货币,而第二交易为第二区块链上B账户的余额加20个单位的货币,这会破坏既有的数据逻辑关系,是不可接受的。
为了解决上述技术问题,本申请提供了一种跨链交易方法。
参照图14,图14为本申请实施例提供的一种跨链交易方法的示意图,如图14中示出的那样,跨链交易方法包括:
601、所述第一节点计算得到所述第二交易的第一哈希,或接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端。
本申请实施例中,第一交易和第二交易为相互关联的跨链交易,其中,第一交易为属于第一区块链上的交易,第二交易为属于第二区块链上的交易。
示例性的,当用户在第一客户端发起跨链交易,该跨链交易包括相互关联的两个跨链子交易(第一交易和第二交易)。具体的,用户可以通过第一客户端实施交易操作。第一客户端可以根据用户的交易操作生成第一交易对应的交易数据。该交易操作可以是导致第一区块链和第二区块链的账本状态改变的操作。交易数据可以包括但不限于用户标识、交易参数(例如交易金额)、交易时间等。第一客户端可以基于第一交易对应的交易数据生成第一交易的交易信息,该交易信息可以包括第一交易的第一哈希hash(tx1)。
其中,交易标识可以用于区分和确定交易对账本所执行的操作。上述第一交易的第一哈希hash(tx1)可以是一个由数字和字母所构成的字符串。在一些应用场景中,对于每一个交易,可以使用哈希函数对该交易所对应的对账本所执行的操作、上述交易数据等进行处理,将所得到的哈希值作为该交易的交易标识。
需要说明的是,本申请实施例中,第一客户端还可以根据用户的交易操作生成第二交易对应的交易数据,并向第二客户端发送第二交易对应的交易数据,第二客户端可以基于第二交易对应的交易数据生成第二交易的交易信息,该交易信息可以包括第二交易的第二哈希hash(tx2),由于交易标识可以区分和确定交易对账本所执行的操作,因此第二客户端生成的第二交易的第二哈希hash(tx2)可以唯一表示第二交易执行的内容。
本申请实施例中,第一客户端除了生成第一交易的第一哈希hash(tx1),还会生成第二交易的第一哈希exp_hash(tx2)。
可选的,在一种实施例中,第一客户端可以通过调用助手链码获取第二客户端“理应”生成的第二交易的第一哈希exp_hash(tx2)。
具体的,第一客户端在根据用户的交易操作生成第二交易对应的交易数据之后,可以以该交易数据作为输入,通过调用助手链码生成第二交易的第一哈希exp_hash(tx2),该第二交易的第一哈希exp_hash(tx2)可以表示第二客户端应该执行的第二交易唯一对应的交易标识。
可选的,在一种实施例中,第一客户端可以不通过查询助手链码来获取第二交易的第一哈希exp_hash(tx2),而是通过与第二客户端通信,得到第二客户端理应执行的链码和参数,并计算出第二交易的第一哈希exp_hash(tx2)。
本申请实施例中,第一客户端在生成第一交易的交易信息之后,可以将该交易信息发送到第一节点集群中的背书节点。其中,第一交易的交易信息包括第一哈希exp_hash(tx2)以及第一交易的第一哈希hash(tx1)。
上述背书节点收到第一客户端发送的上述第一交易的交易信息后,会调用智能合约中的相关代码模拟执行交易信息所指示的第一交易。例如背书节点将第一交易的交易信息中的交易数据作为输入,在自身对应的账本上模拟执行第一交易,生成包含执行返回值、读操作集合和写操作集合的交易结果。上述背书节点可以将上述读操作集合和写操作集合、背书结果(通过或者不通过)以及背书节点的背书签名进行打包,从而生成背书响应。此外,上述背书响应还可以包括上述交易信息对应的客户端的标识、以及第一哈希exp_hash(tx2)和第一交易的第一哈希hash(tx1)。
本申请实施例中,背书节点可以将多个背书响应发送给客户端。
第一客户端可以接收各背书节点发送的背书响应,然后确定背书响应是否符合预设规则。
本申请实施例中,第一客户端确定背书响应符合预设规则之后,可以将第一交易的交易信息以及多个背书响应中包括的多个背书签名发送到第二节点集群,其中第一交易的交易信息包括第一哈希exp_hash(tx2)和第一交易的第一哈希hash(tx1)。
本申请实施例中,第二节点集群中包含的节点维护第一区块链,第二节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
第二节点集群中包含的多个排序节点可以为接收到的交易数据进行全局排序,并将一批排序后的交易数据组合生成区块结构。
当第二节点集群中的一个或多个排序节点收到第一客户端传输的N个交易信息(至少包括第一交易的交易信息以及多个背书响应中包括的多个背书签名)后,可以由至少一个排序节点生成对应的M个区块并对M个区块进行排序,将M个区块传输至第一节点集群,使得第一节点集群对M个区块进行验证,并将验证通过的区块依次添加到对应的区块链中。
本申请实施例中,第一节点集群中的节点可以接收到一个区块,该区块包括第一交易的交易信息以及与第一交易对应的多个背书签名。需要说明的是,为了方便描述,以下将第一节点集群中的节点描述为第一节点。
第一节点接收到包括第一交易的交易信息以及与第一交易对应的多个背书签名的区块,可以对该区块进行验证。关于第一节点如何对该区块进行验证,可参照上述实施例,这里不再赘述。
第一节点可以向所述第三节点发送第六交易,所述第六交易包括所述第一交易的第一哈希hash(tx1),可选的,第四交易包括第二交易的第一哈希exp_hash(tx2)。
本申请实施例中,第三节点集群中包含的节点维护第三区块链,第三节点集群为排序集群(orderer group),其包括多个排序节点,每个排序节点都可以是部署在服务器上的抽象节点,每个排序节点都可用于提供区块链技术中的排序服务。
本申请实施例中,第三节点集群还可以接收到第二节点发送的第二交易的第二哈希hash(tx2)和第一交易的第二哈希exp_hash(tx1)。具体的,第三节点集群还可以接收到第二节点发送的第五交易,该第五交易可以包括第二交易的第二哈希hash(tx2)和第一交易的第二哈希exp_hash(tx1)。
本申请实施例中,第三节点集群中包含的多个排序节点可以为接收到的交易进行全局排序,并将一批排序后的交易数据组合生成区块结构。
具体的,第三节点集群可以生成第四区块,第四区块包括第二交易的第二哈希hash(tx2)和第一交易的第二哈希exp_hash(tx1),第四区块还可以包括第二交易的第一哈希exp_hash(tx2)和第一交易的第一哈希hash(tx1)。
需要说明的是,第二交易的第二哈希hash(tx2)、第一交易的第二哈希exp_hash(tx1)、第二交易的第一哈希exp_hash(tx2)和第一交易的第一哈希hash(tx1)可以在同一个区块,也可以在不同的区块,这里并不限定。
602、所述第一节点接收第三节点发送第二交易的第二哈希,其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
本申请实施例中,第一节点可以获取所述第三区块链上的第四区块,该第四区块可以包括第二交易的第二哈希hash(tx2),其中第二交易的第二哈希hash(tx2)为第二交易真实执行对应的交易标识,其可以唯一指示具体执行中第二交易的交易数据。
可选的,第四区块还可以包括第一交易的第二哈希exp_hash(tx1)。
类似的,第二节点可以接收到第三节点集群发送的第五区块,该第五区块可以包括第一交易的第一哈希hash(tx1),其中第一交易的第一哈希hash(tx1)为第一交易真实执行对应的交易标识,其可以唯一指示具体执行中第一交易的交易数据。
可选的,第五区块还可以包括第二交易的第一哈希exp_hash(tx2)。
在一种实施例中,若第三节点集群生成的第四区块和第五区块为同一个区块,则第一节点可以接收到第三节点集群发送的区块,该区块包括第二交易的第二哈希hash(tx2)、第一交易的第二哈希exp_hash(tx1)、第一交易的第一哈希hash(tx1)和第二交易的第一哈希exp_hash(tx2)。
本申请实施例中,第一节点可以通过判断第二交易的第二哈希hash(tx2)与第二交易的第一哈希exp_hash(tx2)是否相等,进而判断第二交易是否按照正确的交易数据执行。
具体的,由于第二交易的第一哈希exp_hash(tx2)是第一客户端通过第二交易的交易数据生成的,其可以表示第一客户端认为第二交易应该执行的交易数据。而第二交易的第二哈希hash(tx2)表示第二交易真实执行的交易数据。
因此,通过判断第二交易的第二哈希hash(tx2)与第二交易的第一哈希exp_hash(tx2)是否相等,可以确定第二交易是否按照正确的交易数据执行。
类似的,第二节点可以通过判断第一交易的第一哈希hash(tx1)与第一交易的第二哈希exp_hash(tx1)是否相等,进而判断第一交易是否按照正确的交易数据执行。
具体的,由于第一交易的第二哈希exp_hash(tx1)是第二客户端通过第一交易的交易数据生成的,其可以表示第二客户端认为第一交易应该执行的交易数据。而第一交易的第一哈希hash(tx1)表示第一交易真实执行的交易数据。
因此,通过判断第一交易的第一哈希hash(tx1)与第一交易的第二哈希exp_hash(tx1)是否相等,可以确定第一交易是否按照正确的交易数据执行。
可选的,若第一区块包括第一交易的第二哈希exp_hash(tx1),则第一节点可以通过判断第一交易的第一哈希hash(tx1)与第一交易的第二哈希exp_hash(tx1)是否相等,进而获取到第二节点的判断结果。
若第二区块包括第二交易的第一哈希exp_hash(tx2),则第二节点可以通过判断第二交易的第二哈希hash(tx2)与第二交易的第一哈希exp_hash(tx2)是否相等,进而获取到第一节点的判断结果。
本申请实施例中,若第一节点判断第二交易的第二哈希hash(tx2)与第二交易的第 一哈希exp_hash(tx2)相等,则第一节点可以确定第二交易按照正确的交易数据执行。
本申请实施例中,若第二节点判断第一交易的第一哈希hash(tx1)与第一交易的第二哈希exp_hash(tx1)相等,则第二节点可以确定第一交易按照正确的交易数据执行。
本申请实施例中,若第一节点确定第一交易按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则可以执行第一交易。
本申请实施例中,若第一节点确定第一交易没有按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则不执行第一交易。
本申请实施例中,若第一节点确定第一交易按照正确的交易数据执行,且第二交易没有按照正确的交易数据执行,则不执行第一交易。
本申请实施例中,若第二节点确定第一交易按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则可以执行第二交易。
本申请实施例中,若第二节点确定第一交易没有按照正确的交易数据执行,且第二交易按照正确的交易数据执行,则不执行第二交易。
本申请实施例中,若第二节点确定第一交易按照正确的交易数据执行,且第二交易没有按照正确的交易数据执行,则不执行第二交易。
示例性的,若第一交易为A用户向B用户转10个单位的货币,此时,第一交易为第一区块链上A账户的余额减10个单位的货币,第二交易为第二区块链上B账户的余额加10个单位的货币。
此时,第一客户端基于第一交易的交易数据(包括在第一区块链上A账户的余额减10个单位的货币)生成第一交易的第一哈希hash(tx1),以及基于第二交易的交易数据(包括在第二区块链上B账户的余额加10个单位的货币)生成第二交易的第一哈希exp_hash(tx2)。
同样,第二客户端基于第一交易的交易数据(包括在第一区块链上A账户的余额减10个单位的货币)生成第一交易的第二哈希exp_hash(tx1),以及基于第二交易的交易数据(包括在第二区块链上B账户的余额加20个单位的货币)生成第二交易的第二哈希hash(tx2),即第二客户端想在B账户上增加更多的货币。
之后,由于第一节点会接收到第三节点发送的第二交易的第二哈希hash(tx2),由于第二哈希hash(tx2)与第二交易的第一哈希exp_hash(tx2)不同,则第一节点会确定第二交易执行的交易数据不正确,即第二客户端存在欺骗性为,则不执行第一交易。
需要说明的是,图14对应的实施例可以与图3对应的实施例同时进行,这里并不限定。
本申请实施例提供了一种跨链交易方法,包括:所述第一节点获取所述第二交易的第一哈希;所述第一节点获取所述第三区块链上的第四区块,所述第四区块包括第二交易的第二哈希;所述第一节点根据所述第四区块,判断所述第二交易的第一哈希与所述第二交易的第二哈希是否相等。本申请实施例中,第一节点可以通过判断第二交易的第二哈希与第二交易的第一哈希是否相等,进而确定第二交易是否按照正确的交易数据执行,且在第二交易没有按照正确的交易数据执行时,不执行第一交易。
当区块链网络中存在多个跨链交易时,各个跨链交易可能会存在一定的依赖关系,具体的,各个跨链交易的交易数据之间存在一定的依赖关系,例如,有两个跨链交易:跨链交易A和跨链交易B,跨链交易A包括第一交易和第二交易,跨链交易B包括第三交易和第四交易,第一交易和第三交易为第一区块链上的交易,第二交易和第四交易为第二区块链上的交易。
第一交易需要更新A账户的余额,而第三交易也需要更新A账户的余额,第一交易在时序上在第三交易之前。
第二交易需要更新B账户的余额,而第四交易也需要更新B账户的余额,第二交易在时序上在第四交易之后。
此时,第三交易需要第一交易完成之后,才能执行。
第一交易和第二交易属于同一笔跨链交易,则第一交易的执行完成需要依赖于第二交易的执行结果。
第二交易需要第四交易完成之后,才能执行。
第四交易和第三交易属于同一笔跨链交易,则第四交易的执行完成需要依赖于第三交易的执行结果。
即形成了死锁,两笔跨链交易谁都无法完成,造成交易执行阻塞,导致系统无法提供服务。
参照图15a,图15a为一种跨链交易的依赖关系示意图,如图15a中示出的那样,第一交易A1和第二交易B1属于同一笔跨链交易,第三交易A2和第四交易B2属于同一笔跨链交易,第一交易A1和第三交易A2具有时序依赖关系,即第一交易A1执行完成之后第三交易A2才可以执行,第四交易B2和第二交易B1具有时序依赖关系,即第四交易B2执行完成之后第二交易B1才可以执行。
此时第一交易A1、第二交易B1、第三交易A2和第四交易B2存在交易死锁的问题。
为了解决上述问题,参照图15b,图15b为本申请实施例提供的一种跨链交易方法的实施例的示意图,具体的,本实施例提供的跨链交易方法,包括:
701、第一节点接收第一交易的交易数据,所述第一交易的交易数据包括目标交易参数。
702、第一节点接收第二交易的交易数据。
703、若所述第二交易的交易数据包括所述目标交易参数,则确定所述第二交易的交易状态为无效。
可选的,本申请实施例中,所述第一交易和第三交易为相互关联的跨链交易,所述第二交易和第四交易为相互关联的跨链交易,所述第一交易和所述第二交易为第一区块链上的交易,所述第三交易和所述第四交易为第二区块链上的交易。
例如,第一交易为A账户的余额减去5单位的货币,第二交易为A账户的余额减去10单位的货币,第三交易为B账户的余额加上5单位的货币,第四交易为B账户的余额加上10单位的货币。
此时,第一交易的交易数据包括目标交易参数“A账户”,第二交易的交易数据包括目标交易参数“A账户”,则第一节点可以直接确定第二交易的交易状态为无效,进行不执行 第二交易,即不更新第二交易对应的状态数据库。
本申请实施例中,若确定存在会出现交易死锁情况的跨链交易,则确定其中一笔交易的交易状态为无效,进而可以解决由交易死锁造成的交易执行阻塞。
下面对本申请中一个实施例对应的第一节点进行详细描述,请参阅图16,图16为本申请实施例中第一节点的实施例示意图。本申请实施例中的第一节点800包括:
处理模块801,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
获取模块802,用于获取第二交易的交易状态;
所述处理模块801,还用于当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
本申请实施例中,处理模块801确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;获取模块802获取第二交易的交易状态;所述处理模块801当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。通过上述方式,第一节点在确定第一交易的交易状态为第一状态之后,并不直接根据第一状态确定是否修改第一节点的状态机,而是接收第二交易的交易状态,并当所述第二交易的交易状态为所述第一状态时,修改第一节点的状态机,使得跨链子交易的执行与否不只是取决于第一交易的共识校验结果,还需要考虑其他相关联的跨链交易的共识校验结果,不会出现相互关联的跨链交易只有一部分成功执行,而另一部分未成功执行的情况,实现了跨链交易在多个区块链上进行原子性执行。
可选的,获取模块802,具体用于:接收第三节点发送的所述第二交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
可选的,所述第一节点还包括:
发送模块803,用于点向第三节点发送所述第一交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
可选的,所述发送模块803,具体用于:
所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
下面对本申请中一个实施例对应的第一节点进行详细描述,请参阅图16,图16为本申请实施例中第一节点的实施例示意图。本申请实施例中的第一节点800包括:
所述处理模块801,用于:
计算得到所述第二交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
所述接收模块804,用于接收第三节点发送第二交易的第二哈希;
其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述 第二交易的交易数据不正确。
可选的,所述处理模块801,还用于:
计算得到所述第一交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第一交易的第一哈希;
所述发送模块803,还用于向所述第三节点发送所述第一交易的第一哈希。
可选的,所述发送模块803,还用于:
向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,所述第一节点和所述第四节点属于同一个节点集群。
下面对本申请中一个实施例对应的跨链交易装置进行详细描述,请参阅图17,图17为本申请实施例中第三节点的实施例示意图。本申请实施例中的第三节点900包括:
获取模块901,用于接收第二节点发送的第二交易的交易状态,所述第二节点维护第二区块链,所述第二交易属于所述第二区块链;
发送模块903,用于向所述第一节点发送所述第二交易的交易状态,以便所述第一节点基于所述第二交易的交易状态和第一交易的交易状态处理目标数据,其中所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据,所述第二交易与所述第一交易为相关联的跨链交易,所述第一交易属于第一区块链,第一节点维护所述第一区块链,所述第三节点不维护所述第一区块链和所述第二区块链。
可选的,所述第三节点还包括:
处理模块902,用于生成包括所述第二交易的交易状态的第一区块。
可选的,所述接收模块,还用于:
接收至少一个第五节点发送的交易;
所述处理模块,具体用于:
基于接收到所述至少一个第五节点发送的交易以及所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
可选的,所述发送模块903,具体用于:
向所述第一节点发送所述第一区块。
可选的,所述接收模块,具体用于:
接收所述第二节点发送的第四交易,所述第四交易包括所述第二交易的交易状态。
可选的,所述接收模块,还用于:
接收所述第二节点发送的第二交易的第二哈希;
所述发送模块,还用于:
向所述第一节点发送所述第二交易的第二哈希,以便所述第一节点基于所述第二交易的第二哈希与第二交易的第一哈希确定所述第二交易的交易数据的正确性,其中,所述第 二交易的第一哈希为所述第一节点计算得到,或来自于第一客户端,所述第一客户端为所述第一交易的发起端。
本申请实施例还提供了一种跨链交易装置,如图18所示,图18为本申请实施例中跨链交易装置的一种结构示意图,为了便于说明,仅示出了与本申请实施例相关的部分,具体技术细节未揭示的,请参照本申请实施例方法部分。该跨链交易装置运行于终端,终端可以为包括手机、平板电脑、个人数字助理(personal digital assistant,PDA)、销售终端(point of sales,POS)、车载电脑等任意终端设备,以终端为手机为例:
手机包括:射频(radio frequency,RF)电路1110、存储器1120、输入单元1130、显示单元1140、传感器1150、音频电路1160、无线保真(wireless fidelity,WiFi)模块1170、处理器1180、以及电源1190等部件。本领域技术人员可以理解,图18中示出的手机结构并不构成对手机的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件布置。
RF电路1110可用于收发信息或通话过程中,信号的接收和发送,特别地,将基站的下行信息接收后,给处理器1180处理;另外,将设计上行的数据发送给基站。通常,RF电路1110包括但不限于天线、至少一个放大器、收发信机、耦合器、低噪声放大器(low noise amplifier,LNA)、双工器等。此外,RF电路1110还可以通过无线通信与网络和其他设备通信。上述无线通信可以使用任一通信标准或协议,包括但不限于全球移动通讯系统(global system of mobile communication,GSM)、通用分组无线服务(general packet radio service,GPRS)、码分多址(code division multiple access,CDMA)、宽带码分多址(wideband code division multiple access,WCDMA)、长期演进(long term evolution,LTE)、电子邮件、短消息服务(short messaging service,SMS)等。
存储器1120可用于存储软件程序以及模块,处理器1180通过运行存储在存储器1120的软件程序以及模块,从而执行手机的各种功能应用以及数据处理。存储器1120可主要包括存储程序区和存储数据区,其中,存储程序区可存储操作系统、至少一个功能所需的应用程序(比如声音播放功能、图像播放功能等)等;存储数据区可存储根据手机的使用所创建的数据(比如音频数据、电话本等)等。此外,存储器1120可以包括高速随机存取存储器,还可以包括非易失性存储器,例如至少一个磁盘存储器件、闪存器件、或其他易失性固态存储器件。
输入单元1130可用于接收输入的数字或字符信息,以及产生与手机的用户设置以及功能控制有关的键信号输入。具体地,输入单元1130可包括触控面板1131以及其他输入设备1132。触控面板1131,也称为触摸屏,可收集用户在其上或附近的触摸操作(比如用户使用手指、触笔等任何适合的物体或附件在触控面板1131上或在触控面板1131附近的操作),并根据预先设定的程式驱动相应的连接装置。可选的,触控面板1131可包括触摸检测装置和触摸控制器两个部分。其中,触摸检测装置检测用户的触摸方位,并检测触摸操作带来的信号,将信号传送给触摸控制器;触摸控制器从触摸检测装置上接收触摸信息,并将它转换成触点坐标,再送给处理器1180,并能接收处理器1180发来的命令并加以执 行。此外,可以采用电阻式、电容式、红外线以及表面声波等多种类型实现触控面板1131。除了触控面板1131,输入单元1130还可以包括其他输入设备1132。具体地,其他输入设备1132可以包括但不限于物理键盘、功能键(比如音量控制按键、开关按键等)、轨迹球、鼠标、操作杆等中的一种或多种。
显示单元1140可用于显示由用户输入的信息或提供给用户的信息以及手机的各种菜单。显示单元1140可包括显示面板1141,可选的,可以采用液晶显示器(liquid crystal display,LCD)、有机发光二极管(organic light-emitting diode,OLED)等形式来配置显示面板1141。进一步的,触控面板1131可覆盖显示面板1141,当触控面板1131检测到在其上或附近的触摸操作后,传送给处理器1180以确定触摸事件的类型,随后处理器1180根据触摸事件的类型在显示面板1141上提供相应的视觉输出。虽然在图18中,触控面板1181与显示面板1141是作为两个独立的部件来实现手机的输入和输入功能,但是在某些实施例中,可以将触控面板1131与显示面板1141集成而实现手机的输入和输出功能。
手机还可包括至少一种传感器1150,比如光传感器、运动传感器以及其他传感器。具体地,光传感器可包括环境光传感器及接近传感器,其中,环境光传感器可根据环境光线的明暗来调节显示面板1141的亮度,接近传感器可在手机移动到耳边时,关闭显示面板1141和/或背光。作为运动传感器的一种,加速计传感器可检测各个方向上(一般为三轴)加速度的大小,静止时可检测出重力的大小及方向,可用于识别手机姿态的应用(比如横竖屏切换、相关游戏、磁力计姿态校准)、振动识别相关功能(比如计步器、敲击)等;至于手机还可配置的陀螺仪、气压计、湿度计、温度计、红外线传感器等其他传感器,在此不再赘述。
音频电路1160、扬声器1161,传声器1162可提供用户与手机之间的音频接口。音频电路1160可将接收到的音频数据转换后的电信号,传输到扬声器1161,由扬声器1161转换为声音信号输出;另一方面,传声器1162将收集的声音信号转换为电信号,由音频电路1160接收后转换为音频数据,再将音频数据输出处理器1180处理后,经RF电路1110以发送给比如另一手机,或者将音频数据输出至存储器1120以便进一步处理。
WiFi属于短距离无线传输技术,手机通过WiFi模块1170可以帮助用户收发电子邮件、浏览网页和访问流式媒体等,它为用户提供了无线的宽带互联网访问。虽然图18示出了WiFi模块1170,但是可以理解的是,其并不属于手机的必须构成,完全可以根据需要在不改变申请的本质的范围内而省略。
处理器1180是手机的控制中心,利用各种接口和线路连接整个手机的各个部分,通过运行或执行存储在存储器1120内的软件程序和/或模块,以及调用存储在存储器1120内的数据,执行手机的各种功能和处理数据,从而对手机进行整体监控。可选的,处理器1180可包括一个或多个处理单元;可选的,处理器1180可集成应用处理器和调制解调处理器,其中,应用处理器主要处理操作系统、用户界面和应用程序等,调制解调处理器主要处理无线通信。可以理解的是,上述调制解调处理器也可以不集成到处理器1180中。
手机还包括给各个部件供电的电源1190(比如电池),可选的,电源可以通过电源管理系统与处理器1180逻辑相连,从而通过电源管理系统实现管理充电、放电、以及功耗管 理等功能。
尽管未示出,手机还可以包括摄像头、蓝牙模块等,在此不再赘述。
在本申请实施例中,该终端所包括的处理器1180可以执行上述图3、图4、图6、图11、图12a、图12b、图14以及图15b对应的实施例描述的步骤。
本申请实施例提供的跨链交易装置还可以部署于服务器中,该服务器可以为单个服务器也可以为多个服务器组成的服务器集群,下面,以单个服务器进行描述。请参阅图19,图19为本申请实施例中提供的一种服务器结构示意图,该服务器1200可因配置或性能不同而产生比较大的差异,可以包括一个或一个以上中央处理器(central processing units,CPU)1222(例如,一个或一个以上处理器)和存储器1232,一个或一个以上存储应用程序1242或数据1244的存储介质1230(例如一个或一个以上海量存储设备)。其中,存储器1232和存储介质1230可以是短暂存储或持久存储。存储在存储介质1230的程序可以包括一个或一个以上模块(图示没标出),每个模块可以包括对服务器中的一系列指令操作。更进一步地,中央处理器1222可以设置为与存储介质1230通信,在服务器1200上执行存储介质1230中的一系列指令操作。
服务器1200还可以包括一个或一个以上电源1226,一个或一个以上有线或无线网络接口1250,一个或一个以上输入输出接口1258,和/或,一个或一个以上操作系统1241,例如Windows ServerTM,Mac OS XTM,UnixTM,LinuxTM,FreeBSDTM等等。
上述实施例中由服务器所执行的步骤可以基于该图19所示的服务器结构。
CPU 1222可以执行上述图3、图4、图6、图11、图12a、图12b、图14以及图15b对应的实施例描述的步骤。
在上述实施例中,可以全部或部分地通过软件、硬件、固件或者其任意组合来实现。当使用软件实现时,可以全部或部分地以计算机程序产品的形式实现。
所述计算机程序产品包括一个或多个计算机指令。在计算机上加载和执行所述计算机程序指令时,全部或部分地产生按照本发明实施例所述的流程或功能。所述计算机可以是通用计算机、专用计算机、计算机网络、或者其他可编程装置。所述计算机指令可以存储在计算机可读存储介质中,或者从一个计算机可读存储介质向另一计算机可读存储介质传输,例如,所述计算机指令可以从一个网站站点、计算机、服务器或数据中心通过有线(例如同轴电缆、光纤、数字用户线(Digital Subscriber Line,DSL))或无线(例如红外、无线、微波等)方式向另一个网站站点、计算机、服务器或数据中心进行传输。所述计算机可读存储介质可以是计算机能够存储的任何可用介质或者是包含一个或多个可用介质集成的服务器、数据中心等数据存储设备。所述可用介质可以是磁性介质,(例如,软盘、硬盘、磁带)、光介质(例如,DVD)、或者半导体介质(例如固态硬盘Solid State Disk(SSD))等。
所属领域的技术人员可以清楚地了解到,为描述的方便和简洁,上述描述的系统,装置和单元的具体工作过程,可以参考前述方法实施例中的对应过程,在此不再赘述。
在本申请所提供的几个实施例中,应该理解到,所揭露的系统,装置和方法,可以通 过其它的方式实现。例如,以上所描述的装置实施例仅仅是示意性的,例如,所述单元的划分,仅仅为一种逻辑功能划分,实际实现时可以有另外的划分方式,例如多个单元或组件可以结合或者可以集成到另一个系统,或一些特征可以忽略,或不执行。另一点,所显示或讨论的相互之间的耦合或直接耦合或通信连接可以是通过一些接口,装置或单元的间接耦合或通信连接,可以是电性,机械或其它的形式。
所述作为分离部件说明的单元可以是或者也可以不是物理上分开的,作为单元显示的部件可以是或者也可以不是物理单元,即可以位于一个地方,或者也可以分布到多个网络单元上。可以根据实际的需要选择其中的部分或者全部单元来实现本实施例方案的目的。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (38)

  1. 一种跨链交易方法,其特征在于,应用于第一节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,第二交易属于第二区块链,第二节点维护所述第二区块链,所述方法包括:
    所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
    所述第一节点获取所述第二交易的交易状态;
    当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
  2. 根据权利要求1所述的方法,其特征在于,所述第一节点获取所述第二交易的交易状态,包括:
    所述第一节点接收第三节点发送的所述第二交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
  3. 根据权利要求1或2所述的方法,其特征在于,所述方法还包括:
    所述第一节点向第三节点发送所述第一交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
  4. 根据权利要求3所述的方法,其特征在于,所述第一节点向第三节点发送所述第一交易的交易状态,包括:
    所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
  5. 根据权利要求1至4任一所述的方法,其特征在于,所述方法还包括:
    所述第一节点计算得到所述第二交易的第一哈希,或接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
    所述第一节点接收第三节点发送第二交易的第二哈希;
    其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
  6. 根据权利要求1至5任一所述的方法,其特征在于,所述方法还包括:
    所述第一节点计算得到所述第一交易的第一哈希,或接收到第一客户端发送的所述第一交易的第一哈希;
    所述第一节点向所述第三节点发送所述第一交易的第一哈希。
  7. 根据权利要求1至6任一所述的方法,其特征在于,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据之后,所述方法还包括:
    所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,所述第一节点和所述第四节点属于同一个节点集群。
  8. 一种跨链交易方法,其特征在于,所述方法包括:
    第三节点接收第二节点发送的第二交易的交易状态,所述第二节点维护第二区块链,所述第二交易属于所述第二区块链;
    所述第三节点向所述第一节点发送所述第二交易的交易状态,以便所述第一节点基于所述第二交易的交易状态和第一交易的交易状态处理目标数据,其中所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据,所述第一交易属于第一区块链,第一节点维护所述第一区块链,所述第三节点不维护所述第一区块链和所述第二区块链。
  9. 根据权利要求8所述的方法,其特征在于,所述方法还包括:
    所述第三节点生成包括所述第二交易的交易状态的第一区块。
  10. 根据权利要求9所述的方法,其特征在于,所述方法还包括:
    所述第三节点接收至少一个第五节点发送的交易;
    所述第三节点生成包括所述第二交易的交易状态的第一区块,包括:
    所述第三节点基于接收所述至少一个第五节点发送的交易的时间以及接收所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
  11. 根据权利要求9或10所述的方法,其特征在于,所述第三节点向所述第一节点发送第二交易的交易状态,包括:
    所述第三节点向所述第一节点发送所述第一区块。
  12. 根据权利要求8至11任一所述的方法,其特征在于,所述第三节点接收第二节点发送的第二交易的交易状态,包括:
    所述第三节点接收所述第二节点发送的第四交易,所述第四交易包括所述第二交易的交易状态。
  13. 根据权利要求8至12任一所述的方法,其特征在于,所述方法还包括:
    所述第三节点接收所述第二节点发送的第二交易的第二哈希;
    所述第三节点向所述第一节点发送所述第二交易的第二哈希,以便所述第一节点基于所述第二交易的第二哈希与第二交易的第一哈希确定所述第二交易的交易数据的正确性,其中,所述第二交易的第一哈希为所述第一节点计算得到,或来自于第一客户端,所述第一客户端为所述第一交易的发起端。
  14. 一种跨链交易方法,其特征在于,应用于跨链交易系统,所述跨链交易系统包括第一节点、第二节点和第三节点,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述第三节点不维护所述第一区块链和所述第二区块链,所述方法包括:
    所述第一节点确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
    所述第二节点向所述第三节点发送所述第二交易的交易状态;
    所述第三节点向所述第一节点发送所述第二交易的交易状态;
    当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
  15. 根据权利要求14所述的方法,其特征在于,所述方法还包括:
    所述第三节点生成包括所述第二交易的交易状态的第一区块。
  16. 根据权利要求15所述的方法,其特征在于,所述方法还包括:
    所述第三节点接收至少一个第四节点发送的交易;
    所述第三节点生成包括所述第二交易的交易状态的第一区块,包括:
    所述第三节点基于接收所述至少一个第五节点发送的交易的时间以及接收所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
  17. 根据权利要求14或15所述的方法,其特征在于,所述第三节点向所述第一节点发送第二交易的交易状态,包括:
    所述第三节点向所述第一节点发送所述第一区块。
  18. 根据权利要求14至17任一所述的方法,其特征在于,所述第二节点向所述第三节点发送所述第二交易的交易状态,包括:
    所述第二节点向所述第三节点发送第四交易,所述第四交易包括所述第二交易的交易状态。
  19. 根据权利要求15所述的方法,其特征在于,所述第一节点向第三节点发送所述第一交易的交易状态,包括:
    所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
  20. 根据权利要求14至19任一所述的方法,其特征在于,所述方法还包括:
    所述第一节点计算得到所述第二交易的第一哈希,或接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
    所述第三节点接收所述第二节点发送的第二交易的第二哈希;
    所述第一节点接收所述第三节点发送的所述第二交易的第二哈希;
    其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
  21. 根据权利要求15至20任一所述的方法,其特征在于,所述跨链交易系统还包括第四节点,所述第一节点和所述第四节点属于同一个节点集群,所述第一节点根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据之后,所述方法还包括:
    所述第一节点向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据。
  22. 一种第一节点,其特征在于,所述第一节点维护第一区块链,第一交易属于所述第一区块链,所述第二交易属于第二区块链,第二节点维护所述第二区块链,所述第一节点包括:
    处理模块,用于确定第一交易的交易状态为第一状态,所述第一状态表示交易通过共识校验;
    获取模块,用于获取所述第二交易的交易状态;
    所述处理模块,还用于当所述第二交易的交易状态为所述第一状态时,所述第一节点根据所述第一交易的交易数据修改目标数据,所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据。
  23. 根据权利要求22所述的第一节点,其特征在于,所述获取模块,具体用于:
    接收第三节点发送的所述第二交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
  24. 根据权利要求22或23所述的第一节点,其特征在于,所述第一节点还包括:
    发送模块,用于点向第三节点发送所述第一交易的交易状态,所述第三节点不维护所述第一区块链和所述第二区块链。
  25. 根据权利要求24所述的第一节点,其特征在于,所述发送模块,具体用于:
    所述第一节点向第三节点发送第三交易,所述第三交易包括所述第一交易的交易状态。
  26. 根据权利要求22至25任一所述的第一节点,其特征在于,所述处理模块,还用于:
    计算得到所述第二交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第二交易的第一哈希,其中所述第一客户端为所述第一交易的发起端;
    所述接收模块,具体用于接收第三节点发送第二交易的第二哈希;
    其中,所述第二交易的第一哈希与所述第二交易的第二哈希相等,表示所述第二交易的交易数据正确;所述第二交易的第一哈希与所述第二交易的第二哈希不相等,表示所述第二交易的交易数据不正确。
  27. 根据权利要求22至26任一所述的第一节点,其特征在于,所述处理模块,还用于:
    计算得到所述第一交易的第一哈希,或所述接收模块,具体用于接收到第一客户端发送的所述第一交易的第一哈希;
    所述发送模块,还用于向所述第三节点发送所述第一交易的第一哈希。
  28. 根据权利要求22至27任一所述的第一节点,其特征在于,所述发送模块,还用于:
    向第四节点广播同步信息,所述同步信息用于表示所述第一节点已根据所述第一交易的交易数据修改所述第一节点的状态机中与所述第一交易相关的目标数据,所述第一节点和所述第四节点属于同一个节点集群。
  29. 一种第三节点,其特征在于,包括:
    接收模块,用于接收第二节点发送的第二交易的交易状态,所述第二节点维护第二区块链,所述第二交易属于所述第二区块链;
    发送模块,用于向所述第一节点发送所述第二交易的交易状态,以便所述第一节点基于所述第二交易的交易状态和第一交易的交易状态处理目标数据,其中所述目标数据为所述第一节点的状态机中与所述第一交易相关的数据,所述第一交易属于第一区块链,第一节点维护所述第一区块链,所述第三节点不维护所述第一区块链和所述第二区块链。
  30. 根据权利要求29所述的第三节点,其特征在于,所述第三节点还包括:
    处理模块,用于生成包括所述第二交易的交易状态的第一区块。
  31. 根据权利要求30所述的第三节点,其特征在于,所述接收模块,还用于:
    接收至少一个第五节点发送的交易;
    所述处理模块,具体用于:
    基于接收到所述至少一个第五节点发送的交易以及所述第二交易的交易状态的时间,对所述至少一个第五节点发送的交易和所述第二交易的交易状态进行排序,生成至少一个区块,其中第一区块为所述至少一个区块中的一个区块,所述第一区块包括所述第二交易的交易状态。
  32. 根据权利要求30或31所述的第三节点,其特征在于,所述发送模块,具体用于:
    向所述第一节点发送所述第一区块。
  33. 根据权利要求29至32任一所述的第三节点,其特征在于,所述接收模块,具体用于:
    接收所述第二节点发送的第四交易,所述第四交易包括所述第二交易的交易状态。
  34. 根据权利要求29至33任一所述的第三节点,其特征在于,所述接收模块,还用于:
    接收所述第二节点发送的第二交易的第二哈希;
    所述发送模块,还用于:
    向所述第一节点发送所述第二交易的第二哈希,以便所述第一节点基于所述第二交易的第二哈希与第二交易的第一哈希确定所述第二交易的交易数据的正确性,其中,所述第二交易的第一哈希为所述第一节点计算得到,或来自于第一客户端,所述第一客户端为所述第一交易的发起端。
  35. 一种跨链交易装置,包括:存储器、收发器、处理器以及总线系统;其中,所述存储器用于存储程序和指令;所述收发器用于在所述处理器的控制下接收或发送信息;所述处理器用于执行所述存储器中的程序;所述总线系统用于连接所述存储器、所述收发器以及所述处理器,以使所述存储器、所述收发器以及所述处理器进行通信;所述处理器用于调用所述存储器中的程序指令,执行如权利要求1至7中任一所述的跨链交易方法。
  36. 一种跨链交易装置,包括:存储器、收发器、处理器以及总线系统;其中,所述存储器用于存储程序和指令;所述收发器用于在所述处理器的控制下接收或发送信息;所述处理器用于执行所述存储器中的程序;所述总线系统用于连接所述存储器、所述收发器以及所述处理器,以使所述存储器、所述收发器以及所述处理器进行通信;所述处理器用 于调用所述存储器中的程序指令,执行如权利要求8至13中任一所述的跨链交易方法。
  37. 一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,所述指令在计算机上运行时,使得所述计算机执行如权利要求1至7中任一所述的跨链交易方法。
  38. 一种计算机可读存储介质,所述计算机可读存储介质中存储有指令,所述指令在计算机上运行时,使得所述计算机执行如权利要求8至13中任一所述的跨链交易方法。
PCT/CN2020/104551 2019-07-26 2020-07-24 一种跨链交易方法和装置 WO2021018048A1 (zh)

Priority Applications (2)

Application Number Priority Date Filing Date Title
EP20847049.2A EP3996028A4 (en) 2019-07-26 2020-07-24 METHOD AND DEVICE FOR CROSS-CHAIN TRANSACTIONS
US17/585,250 US11966378B2 (en) 2019-07-26 2022-01-26 Cross-chain transaction method and apparatus

Applications Claiming Priority (4)

Application Number Priority Date Filing Date Title
CN201910683735.1 2019-07-26
CN201910683735 2019-07-26
CN201911129391.6 2019-11-18
CN201911129391.6A CN112308713A (zh) 2019-07-26 2019-11-18 一种跨链交易方法和装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/585,250 Continuation US11966378B2 (en) 2019-07-26 2022-01-26 Cross-chain transaction method and apparatus

Publications (1)

Publication Number Publication Date
WO2021018048A1 true WO2021018048A1 (zh) 2021-02-04

Family

ID=74230210

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/104551 WO2021018048A1 (zh) 2019-07-26 2020-07-24 一种跨链交易方法和装置

Country Status (3)

Country Link
US (1) US11966378B2 (zh)
EP (1) EP3996028A4 (zh)
WO (1) WO2021018048A1 (zh)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114708103A (zh) * 2022-06-06 2022-07-05 杭州费尔斯通科技有限公司 数据资产交易方法、计算机设备以及可读存储介质

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP3958507A1 (en) * 2020-08-17 2022-02-23 Nokia Solutions and Networks Oy Blockchain-based network device management methods and devices
US20220094555A1 (en) * 2020-09-18 2022-03-24 Fujitsu Limited Validator control for transaction between blockchains
US11888991B2 (en) * 2021-08-25 2024-01-30 Paypal, Inc. Universally trusted bridges for heterogenous blockchain networks

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107248076A (zh) * 2017-06-24 2017-10-13 北京天德科技有限公司 一种双链式跨链交易的区块链互联网模型的核心算法
CN107909369A (zh) * 2017-10-13 2018-04-13 布比(北京)网络技术有限公司 基于跨链交易的共识方法、装置和存储介质
CN109426949A (zh) * 2017-08-29 2019-03-05 华为技术有限公司 一种跨链交易方法及装置

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10097344B2 (en) * 2016-07-15 2018-10-09 Mastercard International Incorporated Method and system for partitioned blockchains and enhanced privacy for permissioned blockchains
US10447480B2 (en) * 2016-12-30 2019-10-15 Guardtime Sa Event verification receipt system and methods
CN107301600B (zh) * 2017-06-23 2021-07-20 北京天德科技有限公司 一种跨链交易的区块链互联网模型的核心构建方法
CN109150943B (zh) * 2017-06-27 2022-03-29 华为技术有限公司 信息的传输方法、装置和系统
KR20190067581A (ko) * 2017-12-07 2019-06-17 한국전자통신연구원 블록체인 트랜잭션 분산 처리 장치 및 방법
GB2570301A (en) * 2018-01-17 2019-07-24 Setl Development Ltd Interaction between blockchains
US20190236698A1 (en) * 2018-01-26 2019-08-01 Richard Postrel Method and system for reconciling the exchange of cryptocurrencies utilizing blockchain
CN111787072B (zh) 2018-04-03 2023-02-28 创新先进技术有限公司 跨区块链的交互方法及装置、系统、电子设备

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107248076A (zh) * 2017-06-24 2017-10-13 北京天德科技有限公司 一种双链式跨链交易的区块链互联网模型的核心算法
CN109426949A (zh) * 2017-08-29 2019-03-05 华为技术有限公司 一种跨链交易方法及装置
CN107909369A (zh) * 2017-10-13 2018-04-13 布比(北京)网络技术有限公司 基于跨链交易的共识方法、装置和存储介质

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
See also references of EP3996028A4

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114708103A (zh) * 2022-06-06 2022-07-05 杭州费尔斯通科技有限公司 数据资产交易方法、计算机设备以及可读存储介质
CN114708103B (zh) * 2022-06-06 2022-08-30 杭州费尔斯通科技有限公司 数据资产交易方法、计算机设备以及可读存储介质

Also Published As

Publication number Publication date
EP3996028A1 (en) 2022-05-11
US11966378B2 (en) 2024-04-23
US20220147999A1 (en) 2022-05-12
EP3996028A4 (en) 2022-08-31

Similar Documents

Publication Publication Date Title
WO2021018048A1 (zh) 一种跨链交易方法和装置
CN110163004B (zh) 一种区块链生成的方法、相关设备及系统
US20200042992A1 (en) Resource transaction method, node, device and storage medium
CN112308713A (zh) 一种跨链交易方法和装置
US20150302215A1 (en) Sensitive operation verification method, terminal device, server, and verification system
CN104616138A (zh) 资源转移方法、系统及装置
US11570051B2 (en) Method, system, and computer program product for configuring a gateway
CN111078556B (zh) 应用测试方法及装置
CN111176977B (zh) 一种安全漏洞自动识别方法和装置
CN111104425A (zh) 数据处理方法及装置
WO2017166170A1 (zh) 中央清分结算方法
WO2015101254A1 (zh) 一种信息交互的方法、装置及系统
CN111359210B (zh) 一种数据处理方法、装置、电子设备以及存储介质
CN110585733B (zh) 一种虚拟资产交易的方法以及相关装置
WO2017166174A1 (zh) 中央清分结算方法
CN116680160A (zh) 一种测试用例生成方法以及相关装置
CN111476562A (zh) 一种虚拟资源转移方法、装置、电子设备以及存储介质
CN107809449B (zh) 交易控制方法及装置
WO2017166175A1 (zh) 中央清分结算系统
WO2017166101A1 (zh) 制卡系统
CN113806801B (zh) 交易信息上链方法、装置、计算机设备及存储介质
US20220129578A1 (en) Electronic device for managing personal information and method therefor
CN117555962A (zh) 一种基于跨合约调用的数据存储方法以及相关装置
WO2017166107A1 (zh) 制卡方法
WO2017166110A1 (zh) 制卡方法

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: 20847049

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

ENP Entry into the national phase

Ref document number: 2020847049

Country of ref document: EP

Effective date: 20220204