WO2022206439A1 - Method and apparatus for providing cross-chain message - Google Patents

Method and apparatus for providing cross-chain message Download PDF

Info

Publication number
WO2022206439A1
WO2022206439A1 PCT/CN2022/081760 CN2022081760W WO2022206439A1 WO 2022206439 A1 WO2022206439 A1 WO 2022206439A1 CN 2022081760 W CN2022081760 W CN 2022081760W WO 2022206439 A1 WO2022206439 A1 WO 2022206439A1
Authority
WO
WIPO (PCT)
Prior art keywords
transaction
message
chain
cross
blockchain
Prior art date
Application number
PCT/CN2022/081760
Other languages
French (fr)
Chinese (zh)
Inventor
余逸荣
Original Assignee
支付宝(杭州)信息技术有限公司
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 支付宝(杭州)信息技术有限公司, 蚂蚁区块链科技(上海)有限公司 filed Critical 支付宝(杭州)信息技术有限公司
Publication of WO2022206439A1 publication Critical patent/WO2022206439A1/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/24Querying
    • G06F16/245Query processing
    • G06F16/2458Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
    • G06F16/2471Distributed queries
    • 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
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network

Definitions

  • the embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for providing cross-chain messages, and a method and apparatus for obtaining cross-chain messages.
  • Blockchain technology also known as distributed ledger technology, is a decentralized distributed database technology characterized by decentralization, openness, transparency, immutability, and trustworthiness. Each data of the blockchain will be broadcast to the blockchain nodes of the entire network, and each full node has a full amount of consistent data.
  • many different types of chains have emerged, which are applied in the fields of finance, health care, supply chain, asset management and traceability. At present, how to make different types of chains cooperate and realize the circulation of value is an important exploration direction.
  • the cross-chain messages sent by the account in the blockchain to the outside of the chain are usually obtained by reading the block data in the blockchain ledger.
  • the embodiments of this specification aim to provide a more efficient solution for transmitting cross-chain messages, so as to solve the deficiencies in the prior art.
  • one aspect of this specification provides a method for providing cross-chain messages, the method being executed by a node device of a blockchain, including: acquiring a first transaction, in which the first contract is invoked , and provide the first cross-chain message to the first contract; execute the first transaction to record the first cross-chain message in the message queue in the account state of the first contract; obtain the second transaction, the first In the second transaction, the query function in the first contract is called; the second transaction is executed to read the first cross-chain message from the message queue; the first data corresponding to the second transaction is generated, and the The first data includes the first cross-chain message; and the first data is stored in the blockchain.
  • executing the second transaction further includes, after reading the first cross-chain message from the message queue, deleting the first cross-chain message from the message queue.
  • executing the second transaction further includes verifying whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, extracting from the message queue Read the first cross-chain message.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • Another aspect of this specification provides a method for obtaining a cross-chain message, the method is executed by an off-chain device, and includes: sending a second transaction to the blockchain, in which the query function in the first contract is invoked in the second transaction,
  • the account state of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; obtain from the blockchain corresponding to the second transaction
  • the first data of the first data includes the first cross-chain message in the message queue.
  • the method further includes, after obtaining the first data of the second transaction from the blockchain, obtaining certification data of the first data from the blockchain.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of this specification provides an apparatus for providing cross-chain messages, the apparatus is deployed on a node device of a blockchain, and includes: a first obtaining unit configured to obtain a first transaction, in which the first transaction calls the the first contract and provide the first cross-chain message to the first contract; the first execution unit is configured to execute the first transaction to record the first transaction in the message queue in the account state of the first contract a cross-chain message; a second acquisition unit, configured to acquire a second transaction, in which the query function in the first contract is invoked; and a second execution unit, configured to execute the second transaction to obtain the reading the first cross-chain message in the message queue; a generating unit configured to generate first data corresponding to the second transaction, where the first data includes the first cross-chain message; a storage unit , configured to store the first data in the blockchain.
  • the second execution unit is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue.
  • the second execution unit is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the The first cross-chain message is read from the message queue.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • Another aspect of this specification provides an apparatus for obtaining cross-chain messages, the apparatus is deployed on off-chain devices, and includes: a sending unit configured to send a second transaction to the blockchain, in which the second transaction calls the first transaction A query function in the contract, the account status of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; the first acquisition unit is configured to: The first data corresponding to the second transaction is obtained from the blockchain, and the first data includes the first cross-chain message in the message queue.
  • the apparatus further includes a second obtaining unit configured to obtain the first data of the second transaction from the blockchain after obtaining the first data of the second transaction from the blockchain Proof data of the first data.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
  • the cross-chain messages are stored in the account state of the message sending contract, and the cross-chain messages in the account state are queried by calling the query function of the message sending contract, providing a A novel method for querying the blockchain ledger, through which a verification procedure can be set in the query function, and it can also be verified whether the query account is an allowed preset account, thereby improving security.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification
  • FIG. 2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification
  • Figure 3 shows a schematic diagram of transaction m
  • Figure 4 shows a schematic diagram of a log included in receipt m
  • FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification
  • FIG. 6 shows an apparatus 600 for acquiring a cross-chain message according to an embodiment of the present specification.
  • FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification.
  • the cross-chain system includes a blockchain 11 and an off-chain device 12 .
  • a business contract and a message sending contract are deployed in the blockchain 11.
  • the business contract is, for example, a cross-chain transfer contract, and the business contract includes a call of a message sending contract, and the message sending contract is used to send cross-chain messages.
  • a user in the blockchain 11 wishes to perform a cross-chain transfer, he can send transaction 1 to the blockchain 11 through his device.
  • the transaction 1 calls the business contract, and transfers the parameters related to the transfer to the business contract.
  • the account balance that initiates the transaction 1 is reduced by the transfer amount, and a cross-chain message to be sent (message 1 in FIG. 1 ) is generated.
  • the message 1 includes The message 1 contains the sending block chain identifier, receiving block chain identifier, sending account, receiving account, receiving contract account, and adding the amount to the balance of the receiving account, and then executes the message sending contract and provides message 1 to the message sending contract.
  • the message 1 is recorded in the message queue in the account status of the message sending contract, that is, the message 1 is recorded in the ledger of the blockchain 11.
  • the messages 1- Message 5 schematically shows the message queue in the account state of the message sending contract.
  • the off-chain device 12 is used to pass messages between the blockchain 11 and other blockchains.
  • the off-chain device 12 can obtain cross-chain messages by sending a transaction (eg, transaction m in FIG. 1 , where m is a transaction number) to the blockchain 11 .
  • the query function of the message sending contract is called in transaction m to query the above message queue.
  • the blockchain 11 is the Ethereum chain
  • the node device in the blockchain 11 executes the transaction m, it reads the message 1 from the message queue and deletes the message 1 in the message queue (as shown in the dotted box in Figure 1). shown).
  • the node device executes and completes the transaction m, it stores the receipt m in the blockchain 11, and the receipt m includes the message 1 obtained by querying the message queue.
  • the off-chain device 12 can read the receipt m and its Spv proof from the blockchain 11, so that the receipt m can be verified through the Spv proof, and the message 1 in it can be obtained. After acquiring the message 1, the off-chain device 12 can provide the message 1 to the receiving account and the receiving contract in the receiving blockchain in the message 1, so that the receiving blockchain can complete the transfer process based on the message 1.
  • the blockchain 11 is not limited to the Ethereum chain, therefore, when executing the transaction m, it is not limited to depositing the receipt m including the message 1 in the blockchain 11, but can be implemented in other forms according to the specific blockchain type The storage of message 1 is performed.
  • the method for providing messages across chains according to embodiments of the present specification will be described in detail below.
  • FIG. 2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification.
  • the blockchain 11 includes, for example, node 1 and node 2.
  • the ledger data of the blockchain 11 is stored in the node devices of node 1 and node 2 of the blockchain, which are described in FIG. 2 and below.
  • node 1 represents the node device of node 1
  • node 2 represents the node device of node 2
  • the corresponding steps are performed by the corresponding node device.
  • the method can be executed jointly by node 1, node 2 and off-chain device 12 of the blockchain 11.
  • step S201 node 1 sends transaction 1 to node 2.
  • a user corresponding to node 1 in blockchain 11 wishes to perform a cross-chain transfer business. Therefore, the user can send transaction 1 to any node in blockchain 11 (for example, node 2 here) through node 1 to Broadcast transaction 1 to the blockchain.
  • the transaction 1 includes a call to the business contract in FIG. 1 for cross-chain transfer business.
  • the business contract calls the sending function included in the message sending contract with message 1 as the incoming parameter, so as to send message 1 to the outside of the chain as a cross-chain message. It can be understood that, here, it is not limited to send transaction 1 from node 1 to node 2.
  • the user of blockchain 11 can also send transaction 1 to node 2 through their user equipment.
  • step S202 node 2 executes transaction 1 and stores message 1 in blockchain 11.
  • each node of blockchain 11 After node 1 sends transaction 1 to blockchain 11, each node of blockchain 11 will obtain transaction 1 and execute transaction 1 to store the data related to transaction 1 in the ledger of blockchain 11 .
  • the message queue may be a first-in, first-out message queue.
  • message 1 is a cross-chain message corresponding to transaction 1
  • message 2 is a cross-chain message corresponding to transaction 2
  • transaction 2 is executing The transaction is executed after transaction 1. Therefore, message 2 enters the message queue after message 1.
  • the off-chain device 12 reads the message queue, message 1 can be read first, and then message 2 can be read.
  • step S203 the off-chain device 12 sends the transaction m to the node 2.
  • the off-chain device 12 may be the device of the user of the blockchain 11, the node device of other blockchains, or the relay device used to transfer messages between multiple blockchains, etc., which is not limited here. , the ledger data of the blockchain 11 is not stored in the off-chain device 12 .
  • the off-chain device 12 obtains cross-chain messages from the blockchain 11 by sending a specific transaction to the blockchain 11 . Specifically, for example, as shown in FIG. 1 , the off-chain device 12 can send a transaction m to any node of the blockchain 11 (eg, node 2 ), and the transaction m calls the query function included in the message sending contract.
  • Figure 3 shows a schematic diagram of transaction m.
  • step S204 node 2 executes transaction m and reads message 1.
  • the node broadcasts the transaction m to the blockchain 11, and the The accounting node of 1 executes transaction m, updates the world state and incorporates the block, after which the accounting node sends the block including transaction m to blockchain 11, so that each node in blockchain 11 executes transaction m , update the world state and update the block, so that finally the ledger data of each node in the blockchain 11 is consistent. That is, this step performed by the node 2 of the blockchain 11 shown in FIG. 2 is performed in each node device in the blockchain 11 .
  • the query function in the message sending contract in the transaction m is executed.
  • the query function can be preset to allow the query account to verify whether the sending account of the transaction m is an allowed query account. . Therefore, when executing the query function, the sending account of the transaction m is first verified. If the verification fails, the query failure is returned. If the verification succeeds, the cross-chain message is read from the message queue in the account status of the message sending contract. It can be understood that in the case where the query account does not need to be verified, when the query function is executed, the cross-chain message can be directly read from the message queue in the account state of the message sending contract.
  • the query function includes, for example, the GetProposer interface.
  • the certificate of the proposer is first obtained by calling GetProposer. It includes the proposer's account, public key and other information, so that it can be verified whether the proposer is allowed to query based on the account or public key preset in the query function.
  • the query function includes, for example, the GetCreator interface. When the query function is executed, the proposer's account is first obtained by calling GetCreator, and then whether the proposer's account is verified based on the allowable account preset in the query function for allowed accounts.
  • the reading method of cross-chain messages in the query function can be set according to requirements. For example, it can be preset that each time the query function is executed, the oldest message is read from the message queue. Referring to Figure 1, assuming the current message 1 is the earliest recorded message, and message 2-message 5 are all messages recorded after message 1. Therefore, when the query function is executed this time, message 1 in the message queue is read.
  • the query function is not limited to reading the oldest message, but can be preset to read the oldest predetermined number (for example, 5, etc.) messages in the message queue, or can be preset to read The latest predetermined number of messages in the message queue, or it can be preset to read the message with the specified sequence number, and the specified sequence number can be passed to the query function as an incoming parameter when calling the query function, or it can be preset to read the specified sequence number.
  • the content of the message, the specified content is the content included in the message, such as accepting the contract account number, receiving the blockchain identifier, etc.
  • the specified content can also be passed to the query function as an incoming parameter when calling the query function. .
  • the query function can also be preset to modify the state of the message sending contract (that is, modify the world state) after reading the cross-chain message. Specifically, in one embodiment, after reading the message 1 in the message queue, for example, the message 1 can be deleted in the message queue, so that the message 1 will not be read repeatedly when the query function is executed next time. In one embodiment, after reading message 1, message 1 may be marked to indicate that off-chain device 12 has read message 1, and in this embodiment, off-chain device 12 may read message 1 repeatedly, Alternatively, in the case where more than one off-chain device reads the cross-chain message from the blockchain 11, after the off-chain device 12 reads the message 1, other off-chain devices can also read the message 1.
  • step S205 node 2 generates and stores receipt m.
  • node 2 After node 2 executes the above query function, it uses the read cross-chain message (for example, message 1) as the return data for executing the query function, so that after executing transaction m, node 2 generates a receipt m for transaction m, and displays it in the area.
  • the receipt m of the transaction m is stored in the blockchain, and the receipt m includes the return data (ie, message 1) of executing the query function.
  • the blockchain 11 is described as an example of the Ethereum chain, the blockchain 11 is not limited to the Ethereum chain, but can be any other type of blockchain.
  • the blockchain 11 can also be a Hyperledger Fabric blockchain.
  • the node device of the endorsing node in the blockchain 11 pre-executes the transaction m, after reading the message 1, it writes the message 1 into In the read-write set corresponding to the transaction m, the submitting node in the blockchain 11 stores the read-write set in the blockchain 11 after verifying the read-write set of the transaction m.
  • step S206 the off-chain device 12 obtains the receipt m from the node 2.
  • the off-chain device 12 can connect to any node in the blockchain 11 and remotely read the receipt m from that node. In one embodiment, after reading the receipt m, the off-chain device 12 may also read the Spv proof of the receipt m from the node of the blockchain 11 .
  • any node in the blockchain 11 can actively push the receipt m to the off-chain device 12 after depositing the receipt m.
  • step S207 the off-chain device 12 obtains the message 1 from the receipt m.
  • the off-chain device 12 when the off-chain device 12 is a relay device, the off-chain device 12 can obtain the message 1 by parsing the receipt m after obtaining the receipt m and its Spv proof.
  • Message 1 is recorded in receipt m, for example, in the form of a log (Log).
  • the log is a log recorded after executing the message sending contract, and is used to record the return data when the function of the message sending contract is executed, that is, message 1.
  • FIG. 4 shows a schematic diagram of the log included in the receipt m. As shown in Fig. 4, the log has, for example, a preset specific identifier (as shown in "Message" in Fig.
  • the log for recording message 1 can be determined based on the specific identifier "Message” or the account of the message sending contract, and the content of the "Data” field of the log can be obtained, which is message 1 .
  • the off-chain device 12 After acquiring the message 1, the off-chain device 12 can determine the receiving chain identification from the message 1 based on the predetermined data structure of the message 1, and thus can provide the receipt m and its Spv proof to the corresponding receiving chain.
  • the off-chain device 12 in the case where the off-chain device 12 is a trusted relay device, after obtaining the receipt m and its Spv certificate, the off-chain device 12 can first use the Spv certificate to verify the receipt m, and after the verification passes In the case of , by parsing the receipt m, the message 1 can be obtained, the receiving chain identifier can be determined from the message 1, and the message 1 can be directly provided to the corresponding receiving chain.
  • receipt m or message 1 in receipt m may be provided to the corresponding receiving chain.
  • FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification.
  • the apparatus 500 is deployed on a node device of a blockchain, and includes: a first obtaining unit 51 configured to obtain a first transaction, where the In the first transaction, the first contract is invoked, and the first cross-chain message is provided to the first contract; the first execution unit 52 is configured to execute the first transaction to the account status of the first contract.
  • the first cross-chain message is recorded in the message queue;
  • the second acquisition unit 53 is configured to acquire a second transaction, and the query function in the first contract is called in the second transaction;
  • the second execution unit 54 is configured to in order to execute the second transaction to read the first cross-chain message from the message queue;
  • the generating unit 55 is configured to generate first data corresponding to the second transaction, wherein the first data contains Including the first cross-chain message;
  • the storage unit 56 is configured to store the first data in the blockchain.
  • the second execution unit 54 is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue .
  • the second execution unit 54 is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the Read the first cross-chain message from the message queue.
  • the first data is a receipt for the second transaction.
  • the blockchain is a Fabric chain
  • the first data is a read-write set of the second transaction.
  • FIG. 6 shows an apparatus 600 for obtaining a cross-chain message according to an embodiment of the present specification.
  • the apparatus 600 is deployed on an off-chain device, and includes a sending unit 61 configured to send a second transaction to the blockchain, the The second transaction calls the query function in the first contract, the account status of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; the first The obtaining unit 62 is configured to obtain first data corresponding to the second transaction from the blockchain, where the first data includes the first cross-chain message in the message queue.
  • the apparatus 600 further includes a second obtaining unit 63, configured to obtain the first data of the second transaction from the blockchain after obtaining the first data of the second transaction from the blockchain Proof data of the first data.
  • the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above-mentioned methods executed by a blockchain node device.
  • Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
  • Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
  • the cross-chain messages are stored in the account state of the message sending contract, and the cross-chain messages in the account state are queried by calling the query function of the message sending contract, providing a A novel method for querying the blockchain ledger, through which a verification procedure can be set in the query function, and it can also be verified whether the query account is an allowed preset account, thereby improving security.
  • the software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or technical fields in any other form of storage medium known in the art.
  • RAM random access memory
  • ROM read only memory
  • electrically programmable ROM electrically erasable programmable ROM
  • registers hard disks, removable disks, CD-ROMs, or technical fields in any other form of storage medium known in the art.

Landscapes

  • Engineering & Computer Science (AREA)
  • Business, Economics & Management (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Finance (AREA)
  • Accounting & Taxation (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Fuzzy Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Computational Linguistics (AREA)
  • Software Systems (AREA)
  • Signal Processing (AREA)
  • Probability & Statistics with Applications (AREA)
  • Mathematical Physics (AREA)
  • Databases & Information Systems (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

A method and apparatus for providing a cross-chain message. The method is executed by node devices in a blockchain, and comprises: obtaining a first transaction, the first transaction calling a first contract and providing a first cross-chain message for the first contract; performing the first transaction to record the first cross-chain message in a message queue in an account state of the first contract; obtaining a second transaction, the second transaction calling a query function in the first contract; performing the second transaction to read the first cross-chain message from the message queue; generating first data corresponding to the second transaction, the first data comprising the first cross-chain message; and storing the first data into the blockchain.

Description

提供跨链消息的方法和装置Method and apparatus for providing cross-chain messages 技术领域technical field
本说明书实施例涉及区块链技术领域,更具体地,涉及一种提供跨链消息的方法和装置、以及获取跨链消息的方法和装置。The embodiments of this specification relate to the field of blockchain technology, and more particularly, to a method and apparatus for providing cross-chain messages, and a method and apparatus for obtaining cross-chain messages.
背景技术Background technique
区块链技术也被称之为分布式账本技术,是一种去中心化的分布式数据库技术,其特点是去中心化、公开透明、不可篡改、可信任。区块链的每笔数据,都会广播到全网的区块链节点,每个全节点都有全量的、一致的数据。随着区块链技术的火热,出现了许多不同类型的链,应用在金融、健康医疗、供应链、资产管理和溯源等领域。当前,如何能让不同类型的链协同合作实现价值的流通是一个重要的探索方向。在已有的跨链技术中,通常通过读取区块链账本中的区块数据而获取由该区块链中的账户向链外发送的跨链消息。Blockchain technology, also known as distributed ledger technology, is a decentralized distributed database technology characterized by decentralization, openness, transparency, immutability, and trustworthiness. Each data of the blockchain will be broadcast to the blockchain nodes of the entire network, and each full node has a full amount of consistent data. With the popularity of blockchain technology, many different types of chains have emerged, which are applied in the fields of finance, health care, supply chain, asset management and traceability. At present, how to make different types of chains cooperate and realize the circulation of value is an important exploration direction. In the existing cross-chain technology, the cross-chain messages sent by the account in the blockchain to the outside of the chain are usually obtained by reading the block data in the blockchain ledger.
因此,需要一种更有效的跨链传递消息的方案。Therefore, a more efficient scheme for delivering messages across chains is needed.
发明内容SUMMARY OF THE INVENTION
本说明书实施例旨在提供一种更有效的传递跨链消息的方案,以解决现有技术中的不足。The embodiments of this specification aim to provide a more efficient solution for transmitting cross-chain messages, so as to solve the deficiencies in the prior art.
为实现上述目的,本说明书一个方面提供一种提供跨链消息的方法,所述方法由区块链的节点设备执行,包括:获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;执行第一交易,以在第一合约的账户状态中的消息队列中记录所述第一跨链消息;获取第二交易,所述第二交易中调用所述第一合约中的查询函数;执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;将所述第一数据存储到所述区块链中。In order to achieve the above object, one aspect of this specification provides a method for providing cross-chain messages, the method being executed by a node device of a blockchain, including: acquiring a first transaction, in which the first contract is invoked , and provide the first cross-chain message to the first contract; execute the first transaction to record the first cross-chain message in the message queue in the account state of the first contract; obtain the second transaction, the first In the second transaction, the query function in the first contract is called; the second transaction is executed to read the first cross-chain message from the message queue; the first data corresponding to the second transaction is generated, and the The first data includes the first cross-chain message; and the first data is stored in the blockchain.
在一种实施方式中,执行第二交易还包括,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。In one embodiment, executing the second transaction further includes, after reading the first cross-chain message from the message queue, deleting the first cross-chain message from the message queue.
在一种实施方式中,执行第二交易还包括,验证所述第二交易的发送账户是否为预 定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。In one embodiment, executing the second transaction further includes verifying whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, extracting from the message queue Read the first cross-chain message.
在一种实施方式中,所述第一数据为所述第二交易的收据。In one embodiment, the first data is a receipt for the second transaction.
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。In one embodiment, the blockchain is a Fabric chain, and the first data is a read-write set of the second transaction.
本说明书另一方面提供一种获取跨链消息的方法,所述方法由链下设备执行,包括:向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述查询函数用于读取所述消息队列中的跨链消息;从所述区块链中获取与所述第二交易对应的第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。Another aspect of this specification provides a method for obtaining a cross-chain message, the method is executed by an off-chain device, and includes: sending a second transaction to the blockchain, in which the query function in the first contract is invoked in the second transaction, The account state of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; obtain from the blockchain corresponding to the second transaction The first data of the first data includes the first cross-chain message in the message queue.
在一种实施方式中,所述方法还包括,在从所述区块链中获取所述第二交易的第一数据之后,从所述区块链获取所述第一数据的证明数据。In one embodiment, the method further includes, after obtaining the first data of the second transaction from the blockchain, obtaining certification data of the first data from the blockchain.
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。In an implementation manner, the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
本说明书另一方面提供一种提供跨链消息的装置,所述装置部署于区块链的节点设备,包括:第一获取单元,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;第一执行单元,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中记录所述第一跨链消息;第二获取单元,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;第二执行单元,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成单元,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;存储单元,配置为,将所述第一数据存储到所述区块链中。Another aspect of this specification provides an apparatus for providing cross-chain messages, the apparatus is deployed on a node device of a blockchain, and includes: a first obtaining unit configured to obtain a first transaction, in which the first transaction calls the the first contract and provide the first cross-chain message to the first contract; the first execution unit is configured to execute the first transaction to record the first transaction in the message queue in the account state of the first contract a cross-chain message; a second acquisition unit, configured to acquire a second transaction, in which the query function in the first contract is invoked; and a second execution unit, configured to execute the second transaction to obtain the reading the first cross-chain message in the message queue; a generating unit configured to generate first data corresponding to the second transaction, where the first data includes the first cross-chain message; a storage unit , configured to store the first data in the blockchain.
在一种实施方式中,所述第二执行单元还配置为,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。In one embodiment, the second execution unit is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue.
在一种实施方式中,所述第二执行单元还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。In one embodiment, the second execution unit is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the The first cross-chain message is read from the message queue.
在一种实施方式中,所述第一数据为所述第二交易的收据。In one embodiment, the first data is a receipt for the second transaction.
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。In one embodiment, the blockchain is a Fabric chain, and the first data is a read-write set of the second transaction.
本说明书另一方面提供一种获取跨链消息的装置,所述装置部署于链下设备,包括:发送单元,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述查询函数用于读取所述消息队列中的跨链消息;第一获取单元,配置为,从所述区块链中获取与所述第二交易对应的第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。Another aspect of this specification provides an apparatus for obtaining cross-chain messages, the apparatus is deployed on off-chain devices, and includes: a sending unit configured to send a second transaction to the blockchain, in which the second transaction calls the first transaction A query function in the contract, the account status of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; the first acquisition unit is configured to: The first data corresponding to the second transaction is obtained from the blockchain, and the first data includes the first cross-chain message in the message queue.
在一种实施方式中,所述装置还包括,第二获取单元,配置为,在从所述区块链中获取所述第二交易的第一数据之后,从所述区块链获取所述第一数据的证明数据。In one embodiment, the apparatus further includes a second obtaining unit configured to obtain the first data of the second transaction from the blockchain after obtaining the first data of the second transaction from the blockchain Proof data of the first data.
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。In an implementation manner, the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由区块链节点设备执行的任一种方法。Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above-mentioned methods executed by a blockchain node device.
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由区块链节点设备执行的任一种方法。Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由链下设备执行的任一种方法。Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由链下设备执行的任一种方法。Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned methods executed by an off-chain device .
在根据本说明书实施例的提供跨链消息的方案中,在消息发送合约的账户状态中保存跨链消息,并通过调用消息发送合约的查询函数来查询账户状态中的跨链消息,提供了一种新颖的查询区块链账本的方法,通过该方法,还可以通过在查询函数设置验证程序,还可以验证查询账户是否为允许的预设账户,从而提高了安全性。In the solution for providing cross-chain messages according to the embodiments of this specification, the cross-chain messages are stored in the account state of the message sending contract, and the cross-chain messages in the account state are queried by calling the query function of the message sending contract, providing a A novel method for querying the blockchain ledger, through which a verification procedure can be set in the query function, and it can also be verified whether the query account is an allowed preset account, thereby improving security.
附图说明Description of drawings
通过结合附图描述本说明书实施例,可以使得本说明书实施例更加清楚:By describing the embodiments of the present specification in conjunction with the accompanying drawings, the embodiments of the present specification can be made clearer:
图1示出根据本说明书实施例的跨链系统的示意图;FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification;
图2示出根据本说明书实施例的提供跨链消息的方法流程图;2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification;
图3示出交易m的示意图;Figure 3 shows a schematic diagram of transaction m;
图4示出收据m中包括的日志示意图;Figure 4 shows a schematic diagram of a log included in receipt m;
图5示出根据本说明书实施例的一种提供跨链消息的装置500;FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification;
图6示出根据本说明书实施例的一种获取跨链消息的装置600。FIG. 6 shows an apparatus 600 for acquiring a cross-chain message according to an embodiment of the present specification.
具体实施方式Detailed ways
下面将结合附图描述本说明书实施例。The embodiments of the present specification will be described below with reference to the accompanying drawings.
图1示出根据本说明书实施例的跨链系统的示意图。如图1所示,所述跨链系统中包括区块链11和链下设备12。区块链11中部署有业务合约和消息发送合约,所述业务合约例如为跨链转账合约,并且所述业务合约中包括消息发送合约的调用,所述消息发送合约用于发送跨链消息。当区块链11中的用户希望进行跨链转账时,可通过其设备向区块链11中发送交易1,所述交易1中调用业务合约,并向业务合约传入与转账相关的参数,如接收转账的区块链标识、接收转账的账户、转账金额、接收合约账户等等。当区块链11中的各个节点设备执行交易1时,将发起交易1的账户余额减少所述转账金额,并生成待发送的跨链消息(图1中的消息1),消息1中例如包括该消息1的发送区块链标识、接收区块链标识、发送账户、接收账户、接收合约账户及对接收账户的余额增加金额等内容,然后执行消息发送合约,并将消息1提供给消息发送合约。通过执行交易1中的消息发送合约,将消息1记录到消息发送合约的账户状态中的消息队列中,即将消息1记录到区块链11的账本中,图1中以顺序排列的消息1-消息5示意示出消息发送合约的账户状态中的消息队列。FIG. 1 shows a schematic diagram of a cross-chain system according to an embodiment of the present specification. As shown in FIG. 1 , the cross-chain system includes a blockchain 11 and an off-chain device 12 . A business contract and a message sending contract are deployed in the blockchain 11. The business contract is, for example, a cross-chain transfer contract, and the business contract includes a call of a message sending contract, and the message sending contract is used to send cross-chain messages. When a user in the blockchain 11 wishes to perform a cross-chain transfer, he can send transaction 1 to the blockchain 11 through his device. The transaction 1 calls the business contract, and transfers the parameters related to the transfer to the business contract. Such as the blockchain identification of the receiving transfer, the account receiving the transfer, the transfer amount, the receiving contract account, etc. When each node device in the blockchain 11 executes the transaction 1, the account balance that initiates the transaction 1 is reduced by the transfer amount, and a cross-chain message to be sent (message 1 in FIG. 1 ) is generated. For example, the message 1 includes The message 1 contains the sending block chain identifier, receiving block chain identifier, sending account, receiving account, receiving contract account, and adding the amount to the balance of the receiving account, and then executes the message sending contract and provides message 1 to the message sending contract. By executing the message sending contract in transaction 1, the message 1 is recorded in the message queue in the account status of the message sending contract, that is, the message 1 is recorded in the ledger of the blockchain 11. In Figure 1, the messages 1- Message 5 schematically shows the message queue in the account state of the message sending contract.
链下设备12用于在区块链11与其它区块链之间传递消息。链下设备12可通过向区块链11发送交易(例如图1中的交易m,其中m为交易编号)以获取跨链消息。交易m中调用消息发送合约的查询函数,以进行对上述消息队列的查询。假设区块链11为以太坊链,当区块链11中的节点设备执行交易m时,从消息队列中读取消息1,并将消息队列中的消息1删除(如图1中的虚线框所示)。节点设备在执行完成交易m之后,在区块链11中存入收据m,收据m中包括通过查询消息队列获取的消息1。之后,链下设备12可从区块链11中读取收据m及其Spv证明,从而可通过Spv证明对收据m 进行验证,获取其中的消息1。链下设备12在获取消息1之后,可以将消息1提供给该消息1中的接收区块链中的接收账户和接收合约,从而使得接收区块链可基于该消息1完成转账过程。The off-chain device 12 is used to pass messages between the blockchain 11 and other blockchains. The off-chain device 12 can obtain cross-chain messages by sending a transaction (eg, transaction m in FIG. 1 , where m is a transaction number) to the blockchain 11 . The query function of the message sending contract is called in transaction m to query the above message queue. Assuming that the blockchain 11 is the Ethereum chain, when the node device in the blockchain 11 executes the transaction m, it reads the message 1 from the message queue and deletes the message 1 in the message queue (as shown in the dotted box in Figure 1). shown). After the node device executes and completes the transaction m, it stores the receipt m in the blockchain 11, and the receipt m includes the message 1 obtained by querying the message queue. After that, the off-chain device 12 can read the receipt m and its Spv proof from the blockchain 11, so that the receipt m can be verified through the Spv proof, and the message 1 in it can be obtained. After acquiring the message 1, the off-chain device 12 can provide the message 1 to the receiving account and the receiving contract in the receiving blockchain in the message 1, so that the receiving blockchain can complete the transfer process based on the message 1.
可以理解,上述参考图1的描述只是示意性的,而不是用于限制本说明书实施例。例如,区块链11不限于为以太坊链,因此,当执行交易m时,不限于在区块链11中存入包括消息1的收据m,而可以根据具体的区块链类型通过其它形式进行对消息1的存储。下文将详细描述根据本说明书实施例的跨链提供消息的方法。It can be understood that the above description with reference to FIG. 1 is only illustrative, and is not used to limit the embodiments of the present specification. For example, the blockchain 11 is not limited to the Ethereum chain, therefore, when executing the transaction m, it is not limited to depositing the receipt m including the message 1 in the blockchain 11, but can be implemented in other forms according to the specific blockchain type The storage of message 1 is performed. The method for providing messages across chains according to embodiments of the present specification will be described in detail below.
图2示出根据本说明书实施例的提供跨链消息的方法流程图。如图2所示,区块链11中例如包括节点1和节点2,区块链的节点1和节点2的节点设备中都存储有区块链11的账本数据,在图2及下文的描述中,为了简化描述,以节点1表示节点1的节点设备,以节点2表示节点2的节点设备,相应的步骤由相应的节点设备执行。该方法可由区块链11的节点1、节点2以及链下设备12共同执行。FIG. 2 shows a flowchart of a method for providing a cross-chain message according to an embodiment of the present specification. As shown in FIG. 2 , the blockchain 11 includes, for example, node 1 and node 2. The ledger data of the blockchain 11 is stored in the node devices of node 1 and node 2 of the blockchain, which are described in FIG. 2 and below. In , in order to simplify the description, node 1 represents the node device of node 1, node 2 represents the node device of node 2, and the corresponding steps are performed by the corresponding node device. The method can be executed jointly by node 1, node 2 and off-chain device 12 of the blockchain 11.
首先,在步骤S201,节点1向节点2发送交易1。First, in step S201, node 1 sends transaction 1 to node 2.
例如,区块链11中的节点1对应的用户希望进行跨链转账业务,因此,该用户可通过节点1向区块链11中的任一节点(这里例如为节点2)发送交易1,以将交易1广播到区块链中。该交易1中包括对图1中的业务合约的调用,以用于进行跨链转账业务。该业务合约以消息1为传入参数调用消息发送合约中包括的发送函数,以用于将消息1作为跨链消息发送到链外。可以理解,这里,不限于由节点1向节点2发送交易1,例如也可以由区块链11的用户通过其用户设备向节点2发送交易1。For example, a user corresponding to node 1 in blockchain 11 wishes to perform a cross-chain transfer business. Therefore, the user can send transaction 1 to any node in blockchain 11 (for example, node 2 here) through node 1 to Broadcast transaction 1 to the blockchain. The transaction 1 includes a call to the business contract in FIG. 1 for cross-chain transfer business. The business contract calls the sending function included in the message sending contract with message 1 as the incoming parameter, so as to send message 1 to the outside of the chain as a cross-chain message. It can be understood that, here, it is not limited to send transaction 1 from node 1 to node 2. For example, the user of blockchain 11 can also send transaction 1 to node 2 through their user equipment.
在步骤S202,节点2执行交易1,在区块链11中存入消息1。In step S202, node 2 executes transaction 1 and stores message 1 in blockchain 11.
在节点1向区块链11中发送交易1之后,区块链11的每个节点都将获取到交易1,执行交易1,以将与交易1相关的数据存入区块链11的账本中。After node 1 sends transaction 1 to blockchain 11, each node of blockchain 11 will obtain transaction 1 and execute transaction 1 to store the data related to transaction 1 in the ledger of blockchain 11 .
具体是,区块链11中的各个节点的节点设备在执行交易1中的消息发送合约时,基于传入参数生成消息1,将消息1记录到消息发送合约的账户状态中的消息队列中,如图1中所示。该消息队列可以为先进先出的消息队列,例如,如图1中所示,消息1为与交易1对应的跨链消息,消息2为与交易2对应的跨链消息,交易2为在执行交易1之后执行的交易,因此,消息2在消息1之后进入消息队列,当链外设备12对该消息队列进行读取时,可先读取消息1,之后再读取消息2。Specifically, when the node device of each node in the blockchain 11 executes the message sending contract in transaction 1, it generates message 1 based on the incoming parameters, and records message 1 in the message queue in the account status of the message sending contract, As shown in Figure 1. The message queue may be a first-in, first-out message queue. For example, as shown in FIG. 1 , message 1 is a cross-chain message corresponding to transaction 1, message 2 is a cross-chain message corresponding to transaction 2, and transaction 2 is executing The transaction is executed after transaction 1. Therefore, message 2 enters the message queue after message 1. When the off-chain device 12 reads the message queue, message 1 can be read first, and then message 2 can be read.
在步骤S203,链下设备12向节点2发送交易m。In step S203, the off-chain device 12 sends the transaction m to the node 2.
所述链下设备12可以为区块链11的使用用户的设备,其它区块链的节点设备、或者用于在多个区块链之间中转消息的中继设备等等,在此不作限定,所述链下设备12中未存储有区块链11的账本数据。链下设备12通过向区块链11发送特定交易来从区块链11获取跨链消息。具体是,例如,如图1所示,链下设备12可向区块链11的任一节点(例如节点2)发送交易m,该交易m中调用消息发送合约中包括的查询函数。图3示出交易m的示意图。如图3所示,在交易m中,“From”字段中的“0x215e...”为链下设备12用于向区块链11发送交易m的账户,表示该交易m由链下设备12发出,“To”字段中的“SendMessage(0x29a0…)”为消息发送合约的合约名称,“0x29a0…”为消息发送合约的合约账户,表示该交易m调用消息发送合约,“Data”字段中的“Qurery()”为消息发送合约中的查询函数,表示交易m调用消息发送合约中的查询函数。这里对于Qurery()未传入任何参数,如下文中所述,在对Qurery()函数不同的设定下,也可以对Qurery()函数传入用于进行查询的参数。The off-chain device 12 may be the device of the user of the blockchain 11, the node device of other blockchains, or the relay device used to transfer messages between multiple blockchains, etc., which is not limited here. , the ledger data of the blockchain 11 is not stored in the off-chain device 12 . The off-chain device 12 obtains cross-chain messages from the blockchain 11 by sending a specific transaction to the blockchain 11 . Specifically, for example, as shown in FIG. 1 , the off-chain device 12 can send a transaction m to any node of the blockchain 11 (eg, node 2 ), and the transaction m calls the query function included in the message sending contract. Figure 3 shows a schematic diagram of transaction m. As shown in Figure 3, in transaction m, "0x215e..." in the "From" field is the account used by the off-chain device 12 to send the transaction m to the blockchain 11, indicating that the transaction m is sent by the off-chain device 12 Send, "SendMessage(0x29a0...)" in the "To" field is the contract name of the message sending contract, "0x29a0..." is the contract account of the message sending contract, indicating that the transaction m calls the message sending contract, and the "Data" field "Query()" is the query function in the message sending contract, which means that transaction m calls the query function in the message sending contract. Here, no parameters are passed to Query(), as described below, under different settings for the Query() function, the parameters for querying can also be passed to the Query() function.
在步骤S204,节点2执行交易m,读取消息1。In step S204, node 2 executes transaction m and reads message 1.
假设区块链11为以太坊链,在链下设备12向区块链11中的任一节点发送交易m之后,该节点将交易m广播到区块链11中,并由区块链11中的记账节点执行交易m、更新世界状态并入块,之后,记账节点将该包括交易m的区块发送到区块链11中,以使得区块链11中的每个节点执行交易m、更新世界状态并更新区块,从而最终区块链11中的每个节点的账本数据都是一致的。也就是说,图2中示出的区块链11的节点2执行的该步骤在区块链11中的每个节点设备中执行。Assuming that the blockchain 11 is an Ethereum chain, after the off-chain device 12 sends the transaction m to any node in the blockchain 11, the node broadcasts the transaction m to the blockchain 11, and the The accounting node of 1 executes transaction m, updates the world state and incorporates the block, after which the accounting node sends the block including transaction m to blockchain 11, so that each node in blockchain 11 executes transaction m , update the world state and update the block, so that finally the ledger data of each node in the blockchain 11 is consistent. That is, this step performed by the node 2 of the blockchain 11 shown in FIG. 2 is performed in each node device in the blockchain 11 .
当区块链11的节点2执行交易m时,执行交易m中的消息发送合约中的查询函数,该查询函数中可预设允许查询账户,以验证交易m的发送账户是否为允许的查询账户。因此,在执行查询函数时,首先对交易m的发送账户进行验证,如果验证失败,则返回查询失败,如果验证成功,则从消息发送合约的账户状态中的消息队列中读取跨链消息。可以理解,在不需要对查询账户进行验证的情况中,在执行查询函数时,可直接从消息发送合约的账户状态中的消息队列中读取跨链消息。When the node 2 of the blockchain 11 executes the transaction m, the query function in the message sending contract in the transaction m is executed. The query function can be preset to allow the query account to verify whether the sending account of the transaction m is an allowed query account. . Therefore, when executing the query function, the sending account of the transaction m is first verified. If the verification fails, the query failure is returned. If the verification succeeds, the cross-chain message is read from the message queue in the account status of the message sending contract. It can be understood that in the case where the query account does not need to be verified, when the query function is executed, the cross-chain message can be directly read from the message queue in the account state of the message sending contract.
在区块链11为Hyperledger Fabric区块链的情况中,在一种实施方式中,所述查询函数中例如包括GetProposer接口,在执行查询函数时,首先通过调用GetProposer获取提案者的证书,该证书中包括提案者的账户、公钥等信息,从而可基于查询函数中预设的账户或公钥验证该提案者是否被允许进行查询。在一种实施方式中,所述查询函数中例如包括GetCreator接口,在执行查询函数时,首先通过调用GetCreator获取提案者的 账户,然后基于查询函数中预设的允许账户验证该提案者的账户是否为允许账户。In the case where the blockchain 11 is the Hyperledger Fabric blockchain, in one embodiment, the query function includes, for example, the GetProposer interface. When executing the query function, the certificate of the proposer is first obtained by calling GetProposer. It includes the proposer's account, public key and other information, so that it can be verified whether the proposer is allowed to query based on the account or public key preset in the query function. In one embodiment, the query function includes, for example, the GetCreator interface. When the query function is executed, the proposer's account is first obtained by calling GetCreator, and then whether the proposer's account is verified based on the allowable account preset in the query function for allowed accounts.
所述查询函数中对跨链消息的读取方式可根据需求进行设置,例如,可预设,在每次执行查询函数时,从消息队列中读取最早的消息,参考图1,假设当前消息1为最早记录的消息,消息2-消息5都是在消息1之后记录的消息。因此,在该次执行查询函数时,读取消息队列中的消息1。可以理解,所述查询函数不限于读取最老的1个消息,而可以预设为读取消息队列中最老的预定数目个(例如5个等等)消息,或者可以预设为读取消息队列中最新的预定数目个消息,或者可以预设为读取指定序号的消息,所述指定序号可在调用查询函数时作为传入参数传入给查询函数,或者可以预设为读取指定内容的消息,所述指定内容为所述消息中包括的内容,如接受合约账号、接收区块链标识等等,所述指定内容也可以在调用查询函数时作为传入参数传入给查询函数。The reading method of cross-chain messages in the query function can be set according to requirements. For example, it can be preset that each time the query function is executed, the oldest message is read from the message queue. Referring to Figure 1, assuming the current message 1 is the earliest recorded message, and message 2-message 5 are all messages recorded after message 1. Therefore, when the query function is executed this time, message 1 in the message queue is read. It can be understood that the query function is not limited to reading the oldest message, but can be preset to read the oldest predetermined number (for example, 5, etc.) messages in the message queue, or can be preset to read The latest predetermined number of messages in the message queue, or it can be preset to read the message with the specified sequence number, and the specified sequence number can be passed to the query function as an incoming parameter when calling the query function, or it can be preset to read the specified sequence number. The content of the message, the specified content is the content included in the message, such as accepting the contract account number, receiving the blockchain identifier, etc. The specified content can also be passed to the query function as an incoming parameter when calling the query function. .
查询函数中还可以预设在进行对跨链消息的读取之后修改消息发送合约的状态(即修改世界状态)。具体是,在一种实施方式中,在例如读取消息队列中的消息1之后,可在消息队列中删除消息1,从而使得在下一次执行查询函数时不会重复读取消息1。在一种实施方式中,在读取消息1之后,可对消息1进行标记,以指示链下设备12已读取消息1,在该实施方式中,链下设备12可重复读取消息1,或者,在不止一个链下设备从区块链11读取跨链消息的情况中,在链下设备12读取消息1之后,其它链下设备还可以读取消息1。The query function can also be preset to modify the state of the message sending contract (that is, modify the world state) after reading the cross-chain message. Specifically, in one embodiment, after reading the message 1 in the message queue, for example, the message 1 can be deleted in the message queue, so that the message 1 will not be read repeatedly when the query function is executed next time. In one embodiment, after reading message 1, message 1 may be marked to indicate that off-chain device 12 has read message 1, and in this embodiment, off-chain device 12 may read message 1 repeatedly, Alternatively, in the case where more than one off-chain device reads the cross-chain message from the blockchain 11, after the off-chain device 12 reads the message 1, other off-chain devices can also read the message 1.
在步骤S205,节点2生成并存入收据m。In step S205, node 2 generates and stores receipt m.
节点2在执行完成上述查询函数之后,以读取到的跨链消息(例如消息1)作为执行查询函数的返回数据,从而节点2在执行交易m之后,生成交易m的收据m,并在区块链中存入交易m的收据m,该收据m中包括执行查询函数的返回数据(即消息1)。After node 2 executes the above query function, it uses the read cross-chain message (for example, message 1) as the return data for executing the query function, so that after executing transaction m, node 2 generates a receipt m for transaction m, and displays it in the area. The receipt m of the transaction m is stored in the blockchain, and the receipt m includes the return data (ie, message 1) of executing the query function.
可以理解,上文虽然以区块链11为以太坊链为例进行了描述,区块链11不限于为以太坊链,而可以为其它任意类型的区块链。例如,区块链11也可以为Hyperledger Fabric区块链,在该情况中,区块链11中的背书节点的节点设备在预执行交易m时,在读取消息1之后,将消息1写入与交易m对应的读写集中,区块链11中的提交节点在验证交易m的读写集之后,将该读写集存入区块链11中。It can be understood that although the blockchain 11 is described as an example of the Ethereum chain, the blockchain 11 is not limited to the Ethereum chain, but can be any other type of blockchain. For example, the blockchain 11 can also be a Hyperledger Fabric blockchain. In this case, when the node device of the endorsing node in the blockchain 11 pre-executes the transaction m, after reading the message 1, it writes the message 1 into In the read-write set corresponding to the transaction m, the submitting node in the blockchain 11 stores the read-write set in the blockchain 11 after verifying the read-write set of the transaction m.
在步骤S206,链下设备12从节点2获取收据m。In step S206, the off-chain device 12 obtains the receipt m from the node 2.
在一种实施方式中,链下设备12可连接区块链11中的任一节点,并从该节点远程读取收据m。在一种实施方式中,链下设备12在读取收据m之后,还可以从区块链11 的节点中读取收据m的Spv证明。In one embodiment, the off-chain device 12 can connect to any node in the blockchain 11 and remotely read the receipt m from that node. In one embodiment, after reading the receipt m, the off-chain device 12 may also read the Spv proof of the receipt m from the node of the blockchain 11 .
在一种实施方式中,区块链11中的任一节点可在存入收据m之后主动向链下设备12推送所述收据m。In one embodiment, any node in the blockchain 11 can actively push the receipt m to the off-chain device 12 after depositing the receipt m.
在步骤S207,链下设备12从收据m获取消息1。In step S207, the off-chain device 12 obtains the message 1 from the receipt m.
在一种实施方式中,在链下设备12为中继设备的情况中,链下设备12在获取收据m及其Spv证明之后,通过解析收据m,可获取消息1。在收据m中例如以日志(Log)的形式记录消息1。该日志为在执行消息发送合约之后记录的日志,以用于记录执行消息发送合约的函数时的返回数据,即消息1。图4示出收据m中包括的日志示意图。如图4所示,该日志例如具有预设的特定标识(如图4中的“Message”所示),并且该日志中的“From”字段记录调用消息发送合约的合约(例如转账合约Transfer)的账户,“To”字段中记录消息发送合约的账户。因此,在收据m中,可基于所述特定标识“Message”或者消息发送合约的账户来确定用于记录消息1的日志,并获取该日志的“Data”字段的内容,该内容即为消息1。In one embodiment, when the off-chain device 12 is a relay device, the off-chain device 12 can obtain the message 1 by parsing the receipt m after obtaining the receipt m and its Spv proof. Message 1 is recorded in receipt m, for example, in the form of a log (Log). The log is a log recorded after executing the message sending contract, and is used to record the return data when the function of the message sending contract is executed, that is, message 1. FIG. 4 shows a schematic diagram of the log included in the receipt m. As shown in Fig. 4, the log has, for example, a preset specific identifier (as shown in "Message" in Fig. 4), and the "From" field in the log records the contract that calls the message sending contract (such as the transfer contract Transfer) The account of the message sending contract is recorded in the "To" field. Therefore, in receipt m, the log for recording message 1 can be determined based on the specific identifier "Message" or the account of the message sending contract, and the content of the "Data" field of the log can be obtained, which is message 1 .
在获取消息1之后,链下设备12可基于消息1的预定数据结构从消息1中确定接收链标识,从而可将该收据m及其Spv证明提供给相应的接收链。After acquiring the message 1, the off-chain device 12 can determine the receiving chain identification from the message 1 based on the predetermined data structure of the message 1, and thus can provide the receipt m and its Spv proof to the corresponding receiving chain.
在一种实施方式中,在链下设备12为可信中继设备的情况中,链下设备12在获取收据m及其Spv证明之后,首先可使用Spv证明对收据m进行验证,在验证通过的情况中,通过解析收据m,可获取消息1,从消息1中确定接收链标识,从而将消息1直接提供给相应的接收链。In one embodiment, in the case where the off-chain device 12 is a trusted relay device, after obtaining the receipt m and its Spv certificate, the off-chain device 12 can first use the Spv certificate to verify the receipt m, and after the verification passes In the case of , by parsing the receipt m, the message 1 can be obtained, the receiving chain identifier can be determined from the message 1, and the message 1 can be directly provided to the corresponding receiving chain.
在一种实施方式中,在链下设备12仅获取收据m的情况中,可将收据m或收据m中的消息1提供给对应的接收链。In one embodiment, where the off-chain device 12 only obtains receipt m, receipt m or message 1 in receipt m may be provided to the corresponding receiving chain.
图5示出根据本说明书实施例的一种提供跨链消息的装置500,所述装置500部署于区块链的节点设备,包括:第一获取单元51,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;第一执行单元52,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中记录所述第一跨链消息;第二获取单元53,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;第二执行单元54,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;生成单元55,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;存储单元56,配置为,将所述第一数据存储到所述区块链中。FIG. 5 shows an apparatus 500 for providing a cross-chain message according to an embodiment of the present specification. The apparatus 500 is deployed on a node device of a blockchain, and includes: a first obtaining unit 51 configured to obtain a first transaction, where the In the first transaction, the first contract is invoked, and the first cross-chain message is provided to the first contract; the first execution unit 52 is configured to execute the first transaction to the account status of the first contract. The first cross-chain message is recorded in the message queue; the second acquisition unit 53 is configured to acquire a second transaction, and the query function in the first contract is called in the second transaction; the second execution unit 54 is configured to in order to execute the second transaction to read the first cross-chain message from the message queue; the generating unit 55 is configured to generate first data corresponding to the second transaction, wherein the first data contains Including the first cross-chain message; the storage unit 56 is configured to store the first data in the blockchain.
在一种实施方式中,所述第二执行单元54还配置为,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。In an embodiment, the second execution unit 54 is further configured to delete the first cross-chain message from the message queue after reading the first cross-chain message from the message queue .
在一种实施方式中,所述第二执行单元54还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。In one embodiment, the second execution unit 54 is further configured to verify whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the Read the first cross-chain message from the message queue.
在一种实施方式中,所述第一数据为所述第二交易的收据。In one embodiment, the first data is a receipt for the second transaction.
在一种实施方式中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。In one embodiment, the blockchain is a Fabric chain, and the first data is a read-write set of the second transaction.
图6示出根据本说明书实施例的一种获取跨链消息的装置600,所述装置600部署于链下设备,包括:发送单元61,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述查询函数用于读取所述消息队列中的跨链消息;第一获取单元62,配置为,从所述区块链中获取与所述第二交易对应的第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。FIG. 6 shows an apparatus 600 for obtaining a cross-chain message according to an embodiment of the present specification. The apparatus 600 is deployed on an off-chain device, and includes a sending unit 61 configured to send a second transaction to the blockchain, the The second transaction calls the query function in the first contract, the account status of the first contract includes a message queue of cross-chain messages, and the query function is used to read the cross-chain messages in the message queue; the first The obtaining unit 62 is configured to obtain first data corresponding to the second transaction from the blockchain, where the first data includes the first cross-chain message in the message queue.
在一种实施方式中,所述装置600还包括,第二获取单元63,配置为,在从所述区块链中获取所述第二交易的第一数据之后,从所述区块链获取所述第一数据的证明数据。In one embodiment, the apparatus 600 further includes a second obtaining unit 63, configured to obtain the first data of the second transaction from the blockchain after obtaining the first data of the second transaction from the blockchain Proof data of the first data.
在一种实施方式中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。In an implementation manner, the query function in the first contract is called with a query parameter as an incoming parameter in the second transaction, and the query parameter is used to indicate the first cross-chain message.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由区块链节点设备执行的任一种方法。Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, when the computer program is executed in a computer, the computer is made to execute any one of the above-mentioned methods executed by a blockchain node device.
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由区块链节点设备执行的任一种方法。Another aspect of this specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned execution by the blockchain node device. a method.
本说明书另一方面提供一种计算机可读存储介质,其上存储有计算机程序,当所述计算机程序在计算机中执行时,令计算机执行上述由链下设备执行的任一种方法。Another aspect of the present specification provides a computer-readable storage medium on which a computer program is stored, and when the computer program is executed in a computer, causes the computer to execute any one of the above-mentioned methods executed by an off-chain device.
本说明书另一方面提供一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序,所述处理器在执行所述计算机程序时,实现上述由链下设备执行的任一种方法。Another aspect of the present specification provides a computing device, including a memory and a processor, where a computer program is stored in the memory, and when the processor executes the computer program, the processor implements any one of the above-mentioned methods executed by an off-chain device .
在根据本说明书实施例的提供跨链消息的方案中,在消息发送合约的账户状态中保存跨链消息,并通过调用消息发送合约的查询函数来查询账户状态中的跨链消息,提供了一种新颖的查询区块链账本的方法,通过该方法,还可以通过在查询函数设置验证程序,还可以验证查询账户是否为允许的预设账户,从而提高了安全性。In the solution for providing cross-chain messages according to the embodiments of this specification, the cross-chain messages are stored in the account state of the message sending contract, and the cross-chain messages in the account state are queried by calling the query function of the message sending contract, providing a A novel method for querying the blockchain ledger, through which a verification procedure can be set in the query function, and it can also be verified whether the query account is an allowed preset account, thereby improving security.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to the partial descriptions of the method embodiments.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. Additionally, the processes depicted in the figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
本领域普通技术人员应该还可以进一步意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,能够以电子硬件、计算机软件或者二者的结合来实现,为了清楚地说明硬件和软件的可互换性,在上述说明中已经按照功能一般性地描述了各示例的组成及步骤。这些功能究竟以硬件还是软件方式来执行,取决于技术方案的特定应用和设计约束条件。本领域普通技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。其中,软件模块可以置于随机存储器(RAM)、内存、只读存储器(ROM)、电可编程ROM、电可擦除可编程ROM、寄存器、硬盘、可移动磁盘、CD-ROM、或技术领域内所公知的任意其它形式的存储介质中。Those of ordinary skill in the art should further realize that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software or a combination of the two, in order to clearly illustrate the hardware and software interchangeability, the components and steps of each example have been generally described in terms of functions in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Persons of ordinary skill in the art may use different methods of implementing the described functionality for each particular application, but such implementations should not be considered beyond the scope of this application. Wherein, the software module can be placed in random access memory (RAM), internal memory, read only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disks, removable disks, CD-ROMs, or technical fields in any other form of storage medium known in the art.
以上所述的具体实施方式,对本说明书实施例的目的、技术方案和有益效果进行了进一步详细说明,所应理解的是,以上所述仅为本说明书实施例的具体实施方式而已,并不用于限定本说明书实施例的保护范围,凡在本说明书实施例的精神和原则之内,所做的任何修改、等同替换、改进等,均应包含在本说明书实施例的保护范围之内。The specific embodiments described above further describe the purposes, technical solutions and beneficial effects of the embodiments of the present specification in detail. It should be understood that the above descriptions are only specific implementations of the embodiments of the present specification, and are not intended to be used for The protection scope of the embodiments of this specification is limited, and any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the embodiments of this specification shall be included within the protection scope of the embodiments of this specification.

Claims (20)

  1. 一种提供跨链消息的方法,所述方法由区块链的节点设备执行,包括:A method for providing cross-chain messages, the method being executed by a node device of a blockchain, comprising:
    获取第一交易,所述第一交易中调用第一合约、并向所述第一合约提供第一跨链消息;Acquire a first transaction, in which the first contract is invoked and a first cross-chain message is provided to the first contract;
    执行第一交易,以在第一合约的账户状态中的消息队列中记录所述第一跨链消息;executing the first transaction to record the first cross-chain message in the message queue in the account state of the first contract;
    获取第二交易,所述第二交易中调用所述第一合约中的查询函数;Obtain a second transaction, in which the query function in the first contract is called;
    执行第二交易,以从所述消息队列中读取所述第一跨链消息;executing a second transaction to read the first cross-chain message from the message queue;
    生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;generating first data corresponding to the second transaction, where the first data includes the first cross-chain message;
    将所述第一数据存储到所述区块链中。The first data is stored in the blockchain.
  2. 根据权利要求1所述的方法,执行第二交易还包括,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。The method of claim 1, performing the second transaction further comprising, after reading the first cross-chain message from the message queue, deleting the first cross-chain message in the message queue.
  3. 根据权利要求1所述的方法,其中,执行第二交易还包括,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。The method according to claim 1, wherein executing the second transaction further comprises verifying whether the sending account of the second transaction is a predetermined account, and in the case that the sending account of the second transaction is a predetermined account, from the Read the first cross-chain message from the message queue.
  4. 根据权利要求1至3中任一项所述的方法,其中,所述第一数据为所述第二交易的收据。The method of any one of claims 1 to 3, wherein the first data is a receipt for the second transaction.
  5. 根据权利要求1至3中任一项所述的方法,其中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。The method according to any one of claims 1 to 3, wherein the blockchain is a Fabric chain, and the first data is a read-write set of the second transaction.
  6. 一种获取跨链消息的方法,所述方法由链下设备执行,包括:A method for obtaining a cross-chain message, the method being executed by an off-chain device, comprising:
    向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述查询函数用于读取所述消息队列中的跨链消息;Send a second transaction to the blockchain, the query function in the first contract is called in the second transaction, the account status of the first contract includes a message queue of cross-chain messages, and the query function is used to read all Describe the cross-chain messages in the message queue;
    从所述区块链中获取与所述第二交易对应的第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。Obtain first data corresponding to the second transaction from the blockchain, where the first data includes the first cross-chain message in the message queue.
  7. 根据权利要求6所述的方法,还包括,在从所述区块链中获取所述第二交易的第一数据之后,从所述区块链获取所述第一数据的证明数据。6. The method of claim 6, further comprising, after obtaining the first data of the second transaction from the blockchain, obtaining attestation data for the first data from the blockchain.
  8. 根据权利要求6所述的方法,其中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。The method according to claim 6, wherein in the second transaction, a query function in the first contract is called with a query parameter as an incoming parameter, and the query parameter is used to indicate the first cross-chain message.
  9. 一种提供跨链消息的装置,所述装置部署于区块链的节点设备,包括:An apparatus for providing cross-chain messages, the apparatus is deployed on a node device of a blockchain, including:
    第一获取单元,配置为,获取第一交易,所述第一交易中调用所述第一合约、并向所述第一合约提供第一跨链消息;a first obtaining unit, configured to obtain a first transaction in which the first contract is invoked and a first cross-chain message is provided to the first contract;
    第一执行单元,配置为,执行第一交易,以在第一合约的账户状态中的消息队列中记录所述第一跨链消息;a first execution unit configured to execute a first transaction to record the first cross-chain message in a message queue in the account state of the first contract;
    第二获取单元,配置为,获取第二交易,所述第二交易中调用所述第一合约中的查询函数;a second obtaining unit, configured to obtain a second transaction, in which the query function in the first contract is called;
    第二执行单元,配置为,执行第二交易,以从所述消息队列中读取所述第一跨链消息;a second execution unit configured to execute a second transaction to read the first cross-chain message from the message queue;
    生成单元,配置为,生成与所述第二交易对应的第一数据,所述第一数据中包括所述第一跨链消息;a generating unit, configured to generate first data corresponding to the second transaction, where the first data includes the first cross-chain message;
    存储单元,配置为,将所述第一数据存储到所述区块链中。A storage unit configured to store the first data in the blockchain.
  10. 根据权利要求9所述的装置,所述第二执行单元还配置为,在从所述消息队列中读取所述第一跨链消息之后,在所述消息队列中删除所述第一跨链消息。The apparatus according to claim 9, wherein the second execution unit is further configured to delete the first cross-chain message in the message queue after reading the first cross-chain message from the message queue information.
  11. 根据权利要求9所述的装置,其中,所述第二执行单元还配置为,验证所述第二交易的发送账户是否为预定账户,在所述第二交易的发送账户为预定账户的情况中,从所述消息队列中读取所述第一跨链消息。The apparatus according to claim 9, wherein the second execution unit is further configured to verify whether the sending account of the second transaction is a predetermined account, in the case that the sending account of the second transaction is a predetermined account , read the first cross-chain message from the message queue.
  12. 根据权利要求9至11中任一项所述的装置,其中,所述第一数据为所述第二交易的收据。11. The apparatus of any one of claims 9 to 11, wherein the first data is a receipt for the second transaction.
  13. 根据权利要求9至11中任一项所述的装置,其中,所述区块链为Fabric链,所述第一数据为所述第二交易的读写集。The apparatus according to any one of claims 9 to 11, wherein the blockchain is a Fabric chain, and the first data is a read-write set of the second transaction.
  14. 一种获取跨链消息的装置,所述装置部署于链下设备,包括:A device for acquiring cross-chain messages, the device is deployed on off-chain devices, including:
    发送单元,配置为,向区块链发送第二交易,所述第二交易中调用第一合约中的查询函数,所述第一合约的账户状态中包括跨链消息的消息队列,所述查询函数用于读取所述消息队列中的跨链消息;a sending unit, configured to send a second transaction to the blockchain, the query function in the first contract is called in the second transaction, the account status of the first contract includes a message queue of cross-chain messages, and the query The function is used to read the cross-chain message in the message queue;
    第一获取单元,配置为,从所述区块链中获取与所述第二交易对应的第一数据,所述第一数据中包括所述消息队列中的第一跨链消息。A first obtaining unit, configured to obtain first data corresponding to the second transaction from the blockchain, where the first data includes the first cross-chain message in the message queue.
  15. 根据权利要求14所述的装置,还包括,第二获取单元,配置为,在从所述区块链中获取所述第二交易的第一数据之后,从所述区块链获取所述第一数据的证明数据。The apparatus of claim 14, further comprising a second obtaining unit configured to obtain the first data from the blockchain after obtaining the first data of the second transaction from the blockchain A proof data of data.
  16. 根据权利要求14所述的装置,其中,所述第二交易中以查询参数为传入参数调用第一合约中的查询函数,所述查询参数用于指示所述第一跨链消息。The device according to claim 14, wherein in the second transaction, a query function in the first contract is called with a query parameter as an incoming parameter, and the query parameter is used to indicate the first cross-chain message.
  17. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行权利要求1至5中任一项的所述的方法。A computer-readable storage medium on which computer programs or instructions are stored, which, when executed in a computer, cause the computer to perform the method of any one of claims 1 to 5.
  18. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令, 所述处理器在执行所述计算机程序或指令时,实现权利要求1至5中任一项所述的方法。A computing device, comprising a memory and a processor, wherein a computer program or instruction is stored in the memory, and the processor implements the method according to any one of claims 1 to 5 when executing the computer program or instruction .
  19. 一种计算机可读存储介质,其上存储有计算机程序或指令,当所述计算机程序或指令在计算机中执行时,令计算机执行权利要求6至8中任一项的所述的方法。A computer-readable storage medium on which computer programs or instructions are stored, which, when executed in a computer, cause the computer to perform the method of any one of claims 6 to 8.
  20. 一种计算设备,包括存储器和处理器,所述存储器中存储有计算机程序或指令,所述处理器在执行所述计算机程序或指令时,实现权利要求6至8中任一项所述的方法。A computing device, comprising a memory and a processor, wherein a computer program or instruction is stored in the memory, and the processor implements the method according to any one of claims 6 to 8 when executing the computer program or instruction .
PCT/CN2022/081760 2021-03-30 2022-03-18 Method and apparatus for providing cross-chain message WO2022206439A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110339722.X 2021-03-30
CN202110339722.XA CN112732800B (en) 2021-03-30 2021-03-30 Method and apparatus for providing cross-chain messages

Publications (1)

Publication Number Publication Date
WO2022206439A1 true WO2022206439A1 (en) 2022-10-06

Family

ID=75596181

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/081760 WO2022206439A1 (en) 2021-03-30 2022-03-18 Method and apparatus for providing cross-chain message

Country Status (2)

Country Link
CN (1) CN112732800B (en)
WO (1) WO2022206439A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112732800B (en) * 2021-03-30 2021-07-13 支付宝(杭州)信息技术有限公司 Method and apparatus for providing cross-chain messages
CN114385756A (en) * 2021-06-17 2022-04-22 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain and block chain link point

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110033244A (en) * 2019-03-15 2019-07-19 阿里巴巴集团控股有限公司 Intelligent contract based on block chain executes method and device and electronic equipment
CN111629039A (en) * 2020-05-20 2020-09-04 中国银联股份有限公司 Block chain consensus method, client, endorsement node and sequencing node
CN111741026A (en) * 2020-08-07 2020-10-02 百度在线网络技术(北京)有限公司 Cross-chain transaction request processing method, device, equipment and storage medium
CN111787072A (en) * 2018-04-03 2020-10-16 阿里巴巴集团控股有限公司 Cross-block-chain interaction method, device, system and electronic equipment
CN112287029A (en) * 2020-11-17 2021-01-29 北京物资学院 Block chain multi-chain cross-chain system and implementation mechanism thereof
CN112491846A (en) * 2020-11-18 2021-03-12 深圳前海微众银行股份有限公司 Cross-chain block chain communication method and device
CN112527893A (en) * 2020-11-26 2021-03-19 暨南大学 Safe and efficient cross-chain service operation method and system based on SGX
CN112732800A (en) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 Method and apparatus for providing cross-chain messages

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111787072A (en) * 2018-04-03 2020-10-16 阿里巴巴集团控股有限公司 Cross-block-chain interaction method, device, system and electronic equipment
CN110033244A (en) * 2019-03-15 2019-07-19 阿里巴巴集团控股有限公司 Intelligent contract based on block chain executes method and device and electronic equipment
CN111629039A (en) * 2020-05-20 2020-09-04 中国银联股份有限公司 Block chain consensus method, client, endorsement node and sequencing node
CN111741026A (en) * 2020-08-07 2020-10-02 百度在线网络技术(北京)有限公司 Cross-chain transaction request processing method, device, equipment and storage medium
CN112287029A (en) * 2020-11-17 2021-01-29 北京物资学院 Block chain multi-chain cross-chain system and implementation mechanism thereof
CN112491846A (en) * 2020-11-18 2021-03-12 深圳前海微众银行股份有限公司 Cross-chain block chain communication method and device
CN112527893A (en) * 2020-11-26 2021-03-19 暨南大学 Safe and efficient cross-chain service operation method and system based on SGX
CN112732800A (en) * 2021-03-30 2021-04-30 支付宝(杭州)信息技术有限公司 Method and apparatus for providing cross-chain messages

Also Published As

Publication number Publication date
CN112732800B (en) 2021-07-13
CN112732800A (en) 2021-04-30

Similar Documents

Publication Publication Date Title
TWI737944B (en) Block chain-based transaction execution method and device, and electronic equipment
TWI694390B (en) Blockchain-based transaction processing method and device, and electronic equipment
US11151236B2 (en) File verification database system
US10764031B2 (en) Blockchain system for pattern recognition
CN111914023B (en) Bill management method and device based on blockchain and electronic equipment
TW202022857A (en) Invoice creating method and device based on block chain and electronic device
WO2022206439A1 (en) Method and apparatus for providing cross-chain message
CN109255056B (en) Data reference processing method, device, equipment and storage medium of block chain
US11139960B2 (en) File redaction database system
CN112835612A (en) Electronic document version management method and device based on block chain
CN111461723A (en) Data processing system, method and device based on block chain
WO2022206454A1 (en) Method and apparatus for providing cross-chain messages
US9565562B1 (en) Knowledge based authentication using mobile devices
WO2022206453A1 (en) Method and apparatus for providing cross-chain private data
US20200204376A1 (en) File provenance database system
CN107633016A (en) Data processing method and device and electronic equipment
CN112200569B (en) Digital seal using method and device based on block chain and electronic equipment
WO2022206438A1 (en) Method and apparatus for providing cross-chain message
CN111552991A (en) Block chain transaction method and device
CN111429250A (en) Data management method and device in escort scene
CN113469815A (en) Data management method and device
CN111915308A (en) Transaction processing method of blockchain network and blockchain network
CN112291321B (en) Service processing method, device and system
CN110033367A (en) Based on the contract record method and device of block chain, electronic equipment
CN109101577A (en) A kind of data circulation method, apparatus and system

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22778622

Country of ref document: EP

Kind code of ref document: A1