Disclosure of Invention
The embodiment of the invention provides a cross-chain processing method, equipment and a system for a multi-chain block chain system, which are used for realizing the cross-chain processing in the multi-chain block chain system and expanding the application range of the multi-chain block chain system.
In a first aspect, an embodiment of the present invention provides a method for processing a cross-chain in a multi-chain blockchain system, applied to a source chain, including:
Receiving a cross-chain transaction inquiry request, wherein the cross-chain transaction inquiry request comprises an identification of a target chain;
acquiring the cross-link transaction data of the target chain from a transfer chain table of the source chain according to the identification of the target chain, wherein the transfer chain table is used for storing the cross-link transaction data to be processed;
and sending the cross-link transaction data of the target chain to the target chain so that the target chain performs cross-link processing according to the cross-link transaction data.
In one possible implementation, after receiving the cross-chain transaction query request, the method further includes:
the signature in the cross-chain transaction query request is verified.
In one possible implementation, the method further includes:
the cross-chain process is recorded in the same ledger in the source chain as the in-chain process.
In one possible implementation, before receiving the cross-chain transaction query request, the method further includes:
receiving transaction request information sent by a client, wherein the transaction request information comprises source account information, target account information and asset transfer information;
acquiring a sub-block chain identifier corresponding to target account information;
determining cross-link transaction data according to the transaction request information and the sub-block link identification;
and adding the cross-chain transaction data into a transit linked list of the source chain.
In a possible implementation manner, obtaining a sub-block chain identifier corresponding to the target account information includes:
an account inquiry request is sent to a system chain, wherein the account inquiry request comprises target account information, so that the system chain determines a sub-block chain identifier corresponding to the target account information according to the target account information, and the system chain comprises a mapping relation between an account and the sub-block chain identifier;
and receiving a sub-block chain identifier corresponding to the target account information returned by the system chain.
In one possible implementation, the method further includes:
acquiring transaction states corresponding to each cross-link transaction data in a transfer linked list;
and if the transaction state corresponding to the cross-link transaction data is successful, deleting the cross-link transaction data from the transfer linked list.
In a second aspect, an embodiment of the present invention provides a method for processing a cross-chain in a multi-chain blockchain system, applied to a target chain, including:
sending a cross-link transaction inquiry request to a source chain, wherein the cross-link transaction inquiry request comprises an identification of a target chain;
receiving cross-link transaction data sent by a source chain, wherein the cross-link transaction data are acquired from a transit linked list of the source chain according to the identification of a target chain;
and performing cross-chain processing according to the cross-chain transaction data.
In one possible implementation, before sending the cross-chain transaction query request to the source chain, the method further includes:
the cross-chain transaction query request is signed.
In one possible implementation, the method further includes:
the cross-chain process is recorded in the same ledger as the in-chain process in the target chain.
In one possible implementation, the method further includes:
and updating the transaction state corresponding to the cross-chain transaction data according to the cross-chain processing result.
In a third aspect, an embodiment of the present invention provides a cross-chain processing apparatus for use in a multi-chain blockchain system, comprising:
the receiving module is used for receiving a cross-link transaction inquiry request, wherein the cross-link transaction inquiry request comprises an identification of a target link;
the acquisition module is used for acquiring the cross-link transaction data of the target chain from a transfer chain table of the source chain according to the identification of the target chain, wherein the transfer chain table is used for storing the cross-link transaction data to be processed;
and the sending module is used for sending the cross-link transaction data of the target link to the target link so as to enable the target link to perform cross-link processing according to the cross-link transaction data.
In a fourth aspect, an embodiment of the present invention provides a cross-chain processing apparatus for use in a multi-chain blockchain system, comprising:
The sending module is used for sending a cross-link transaction inquiry request to the source chain, wherein the cross-link transaction inquiry request comprises the identification of the target chain;
the receiving module is used for receiving the cross-link transaction data sent by the source chain, wherein the cross-link transaction data is obtained from a transit linked list of the source chain according to the identification of the target chain;
and the processing module is used for performing cross-chain processing according to the cross-chain transaction data.
In a fifth aspect, an embodiment of the present invention provides an electronic device, including:
a memory;
a processor; and
a computer program;
wherein the computer program is stored in a memory and configured to be executed by a processor to implement a method of cross-chain processing in a multi-chain blockchain system as in any of the first aspects and/or a method of cross-chain processing in a multi-chain blockchain system as in any of the second aspects.
In a sixth aspect, embodiments of the present invention provide a multi-chain blockchain system including:
a system chain and a plurality of sub-block chains;
the network topology structures, the consensus algorithm and the organization participants of the multiple sub-blockchains are the same;
the system chain comprises a mapping relation between an account number and a sub-block chain identifier, and is used for determining the sub-block chain identifier corresponding to the account number according to the account number;
Source chains of the plurality of sub-blockchains are cross-chain processed using a cross-chain processing method for use in a multi-chain blockchain system as in any of the first aspects;
target chains of the plurality of sub-blockchains are cross-chain processed using a cross-chain processing method as described in any of the second aspects for use in a multi-chain blockchain system.
In a seventh aspect, embodiments of the present invention provide a computer readable storage medium having stored thereon a computer program for execution by a processor to implement a method of cross-chain processing for use in a multi-chain blockchain system as in any of the first aspects and/or a method of cross-chain processing for use in a multi-chain blockchain system as in any of the second aspects.
According to the method, the device and the system for processing the cross-link in the multi-link blockchain system, the cross-link transaction data of the target link is obtained from the transit linked list of the source link according to the identification of the target link by receiving the cross-link transaction query request comprising the identification of the target link, wherein the transit linked list is used for storing the cross-link transaction data to be processed and sending the cross-link transaction data of the target link to the target link, so that the target link performs cross-link processing according to the cross-link transaction data, cross-link processing in the multi-link blockchain system is realized, and the application range of the multi-link blockchain system is expanded. .
Detailed Description
Reference will now be made in detail to exemplary embodiments, examples of which are illustrated in the accompanying drawings. When the following description refers to the accompanying drawings, the same numbers in different drawings refer to the same or similar elements, unless otherwise indicated. The implementations described in the following exemplary examples do not represent all implementations consistent with the invention. Rather, they are merely examples of apparatus and methods consistent with aspects of the invention as detailed in the accompanying claims.
The terms "comprising" and "having" and any variations thereof, in the description and claims, are intended to cover a non-exclusive inclusion. For example, a process, method, system, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus.
The terms "first" and "second" in the present invention are used for identification purposes only and are not to be construed as indicating or implying a sequential relationship, relative importance or implicitly indicating the number of technical features indicated. "plurality" means two or more. "and/or", describes an association relationship of an association object, and indicates that there may be three relationships, for example, a and/or B, and may indicate: a exists alone, A and B exist together, and B exists alone. The character "/" generally indicates that the context-dependent object is an "or" relationship.
Reference throughout this specification to "one embodiment" or "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment is included in at least one embodiment of the present application. Thus, the appearances of the phrases "in one embodiment" or "in an embodiment" in various places throughout this specification are not necessarily all referring to the same embodiment. It should be noted that, without conflict, the embodiments of the present invention and features of the embodiments may be combined with each other.
The embodiment of the invention provides a multi-chain blockchain system, which is a precondition for realizing safe and efficient cross-chain operation. FIG. 1 is a schematic diagram of an embodiment of a multi-chain blockchain system provided by the present invention. As shown in fig. 1, the multi-chain blockchain system provided in this embodiment may include: a system chain and a plurality of sub-block chains.
The network topology, consensus algorithm and organization participants of the multiple sub-blockchains are the same. The system chain comprises a mapping relation between an account number and a sub-block chain identifier, and is used for determining the sub-block chain identifier corresponding to the account number according to the account number.
At least one node in the system chain and each sub-block chain belongs to the same organization, and user information such as identity information, certificates and the like in the system chain and the plurality of sub-block chains are identical in each organization.
Where N represents the number of sub-blockchains included in the multi-chain blockchain system, the specific value may be determined, for example, according to a required throughput, if the required throughput increases, the value of N may be increased, and if the required throughput decreases, the value of N may be decreased, which is not limited in this embodiment. M represents the number of organization participants of the multi-chain blockchain system.
The diamonds in FIG. 1 represent nodes in the system chain and the circles represent nodes in the sub-blockchain. Org1 represents organization participant 1; orgM represents an organization participant M. Org1.p1i represents the ith node in the sub-blockchain 1 and belongs to organization participant 1; org3.p1 (i+2) represents the i+2th node in the sub-blockchain 1 and belongs to organization participant 3; org1.p3i represents the ith node in the sub-blockchain 3 and belongs to organization participant 1.
Alternatively, in each sub-block chain, the identity information of each node participating in the sub-block chain may be registered so that they know each other's existence, for example, the registration may be completed by writing the identity information into the creation block as in Hyperledger fabric.
Alternatively, for the same organization participant, although a plurality of nodes belonging to the organization participant participate in a plurality of different sub-block chain networks respectively, the existence of the identities of the other parties is known. For example, the same certificate authority (Certificate Authority, CA) may be used for the same organization's participants, and certificates and signatures may be authenticated. After the node is started, the information such as identity information, endpoint, participating sub-block chain identification and the like of each node can be registered into each node of the organization through the organization.
Optionally, the system chain is also used to maintain structural information of the multi-chain blockchain system, provide management functions of routing rules,
alternatively, the sub-blockchain may be increased by way of horizontal expansion.
The cross-chain method for the multi-chain blockchain system described in the following embodiments may be used to implement the data flowing between each sub-blockchain in the multi-chain blockchain system provided in the present embodiment. It should be noted that, the method for crossing a multi-chain blockchain system provided in the following embodiments not only can solve the problem of crossing a multi-chain blockchain system provided in the present embodiment, but also can be used in other multi-chain blockchain systems. For example, it may be used in the blockchain solution super ledger (Hyperledger Fabric) that is currently very popular, and multiple organizations may compose a federated blockchain network through Hyperledger Fabric.
In the embodiment of the invention, the source chain is a sub-block chain from which data comes in one-time cross-chain operation, the target chain is a target sub-block chain for data transfer in one-time cross-chain operation, that is, the source chain is a sub-block chain corresponding to source account information, and the target chain is a sub-block chain corresponding to target account information. It will be appreciated that the source and target chains are not fixed, and that a sub-blockchain may be either the source or target chain.
FIG. 2 is a flowchart of one embodiment of a method for cross-chain processing in a multi-chain blockchain system provided by the present invention. The present embodiment may be applied to a source chain, as shown in fig. 2, and the method provided in the present embodiment may include:
s201, receiving a cross-chain transaction inquiry request, wherein the cross-chain transaction inquiry request comprises an identification of a target chain.
The cross-link transaction inquiry request in this embodiment is sent periodically by the target link or triggered by an event, and is used to obtain the cross-link transaction data with the destination address of the source link as the target link.
The cross-chain transaction query request in this embodiment may include an identification of the target chain, e.g., a sub-block chain identification of the target chain may be employed.
S202, acquiring the cross-link transaction data of the target chain from a transfer chain table of the source chain according to the identification of the target chain, wherein the transfer chain table is used for storing the cross-link transaction data to be processed.
The transfer linked list in this embodiment is used to store the cross-link transaction data to be processed, where each cross-link transaction data may include source account information, target account information, asset transfer information, and so on. The following is an exemplary data structure for one particular cross-chain transaction data:
in this embodiment, according to the identifier of the target chain, the cross-chain transaction data of the target chain is obtained from the transit linked list of the source chain. For example, the target link identification of the cross-link transaction data in the transit linked list may be the same cross-link transaction data as the identification of the target link included in the cross-link transaction query request.
S203, the cross-link transaction data of the target link is sent to the target link, so that the target link performs cross-link processing according to the cross-link transaction data.
In this embodiment, after the cross-link transaction data of the target link is determined, the cross-link transaction data of the target link is sent to the target link, so that the target link performs cross-link processing according to the cross-link transaction data.
Optionally, in this embodiment, after determining the cross-link transaction data of the target link, signature processing may be further performed on the corresponding data, so as to improve the security of the cross-link processing.
According to the cross-link processing method for the multi-link blockchain system, the cross-link transaction data of the target link is obtained from the transit linked list of the source link according to the identification of the target link by receiving the cross-link transaction query request comprising the identification of the target link, wherein the transit linked list is used for storing the cross-link transaction data to be processed and sending the cross-link transaction data of the target link to the target link, so that the target link performs cross-link processing according to the cross-link transaction data, cross-link processing in the multi-link blockchain system is achieved, and the application range of the multi-link blockchain system is expanded.
Optionally, after receiving the cross-chain transaction query request, the method may further include: the signature in the cross-chain transaction query request is verified.
It will be appreciated that in order to increase the security of the cross-chain process, the cross-chain transaction query requests sent by the target chain may be signed. After the source link receives the cross-link transaction inquiry request sent by the target link, firstly, verifying the signature in the cross-link transaction inquiry request, and if the verification is passed, executing subsequent cross-link processing; if the verification is not passed, the cross-chain process is terminated.
Optionally, in order to facilitate subsequent tracing of the cross-link processing, on the basis of the foregoing embodiment, the method provided in this embodiment may further include: the cross-chain process is recorded in the same ledger in the source chain as the in-chain process.
The in-chain processing in this embodiment is data processing that occurs inside the source chain. Optionally, to reduce the impact on the service chain code, details of the cross-chain implementation may be accomplished by the relay chain code.
For example, in this embodiment, the link code may record the link record and the service link code in the same account book, which may provide convenience for tracing the link operation later.
On the basis of the foregoing embodiment, the method provided in this embodiment may further include, before receiving the cross-link transaction query request: receiving transaction request information sent by a client, wherein the transaction request information comprises source account information, target account information and asset transfer information; acquiring a sub-block chain identifier corresponding to target account information; determining cross-link transaction data according to the transaction request information and the sub-block link identification; and adding the cross-chain transaction data into a transit linked list of the source chain.
The client in this embodiment may be an application APP installed on a terminal device, receive an instruction input by a user, generate transaction request information according to the user instruction, and send the transaction request information to a source chain. The transaction request information in this embodiment may include source account information, target account information, and asset transfer information, which are used to describe a cross-chain transaction. In this embodiment, after the source chain receives the transaction request information sent by the client, the cross-link transaction data is determined according to the transaction request information and the sub-block chain identifier corresponding to the target account information, and the cross-link transaction data is added into the transit linked list of the source chain, so that the target chain can acquire corresponding cross-link transaction data from the transit linked list according to the identifier of the target chain, and cross-link processing is performed.
In some embodiments, one implementation way of obtaining the sub-blockchain identifier corresponding to the target account information may be: an account inquiry request is sent to a system chain, wherein the account inquiry request comprises target account information, so that the system chain determines a sub-block chain identifier corresponding to the target account information according to the target account information, and the system chain comprises a mapping relation between an account and the sub-block chain identifier; and receiving a sub-block chain identifier corresponding to the target account information returned by the system chain.
The system chain in the embodiment comprises the mapping relation between the account number and the sub-blockchain identifier, so that the function of searching the sub-blockchain identifier corresponding to the account number can be provided.
In this embodiment, after receiving the transaction request information sent by the client, the source chain sends an account query request to the system chain, where the account query request includes the target account information, so that the system chain determines a sub-block chain identifier corresponding to the target account information according to the target account information.
On the basis of any one of the foregoing embodiments, in order to further improve the processing efficiency, the method provided in this embodiment may further include: acquiring transaction states corresponding to each cross-link transaction data in a transfer linked list; and if the transaction state corresponding to the cross-link transaction data is successful, deleting the cross-link transaction data from the transfer linked list.
In the embodiment, the cross-link transaction data which is successful in transaction is deleted from the transfer linked list, so that the data volume in the transfer linked list can be reduced, the processing speed of the cross-link transaction inquiry request is improved, and the problem that the system is slow due to too much data in the transfer linked list is effectively avoided.
In this embodiment, the transaction state corresponding to each cross-link transaction data in the transfer link table may be obtained, for example, by querying the transaction identifier in the target link. This embodiment is not limited thereto.
In order to support information communication across chain processes, there is a need to support underlying trusted transmissions between nodes. FIG. 3 is a schematic diagram of a multi-chain blockchain system provided by the present invention. As shown in FIG. 3, the multi-chain blockchain system provided in this embodiment provides a secure underlying communication mechanism based on the multi-chain blockchain system of FIG. 1.
As shown in fig. 3, in order to ensure that the cross-link processing is safe and reliable, and that the whole cross-link process can be endorsed and traced, in this embodiment, each node organized only believes that the node is organized on other sub-blockchains, so that the cross-link communication only occurs between nodes on different sub-blockchains in the same organization. The node ensures the reliability of the information by authenticating the identity information and the signature of the opposite party. After each node is started, it will monitor the cross-link transaction inquiry requests from other nodes of the organization according to the configuration, and in order to improve the communication efficiency and security, the remote procedure call (Remote Procedure Call, RPC) protocol may be used for communication in this embodiment.
Meanwhile, each node needs to provide an interface for bottom communication for the chain code, so that the chain code can cross-link call the chain code on other sub-block chain networks through the interface. For example, in Hyperledger Fabric, interfaces can be added on an existing basis by augmenting the shim interface in the node code: func (stub chaincacodestub) invoke network chaincode (networked string, chaincodeName string, args [ ] byte, channel string) pb. Alternatively, the interface in fig. 3 may employ a shim interface.
It should be noted that the cross-link communication only occurs in the endorsement stage, and if the endorsement node needs to query the link code information on other sub-blockchains, the cross-link transaction query request is triggered. Moreover, for security reasons, cross-chain processing can only call query interfaces, and cannot call interfaces for write operations.
On the basis of the above embodiments, the present embodiment combines the above embodiments. FIG. 4 is a flowchart of another embodiment of a cross-chain processing method for use in a multi-chain blockchain system provided by the present invention. As shown in fig. 4, the method provided in this embodiment may include:
s401, receiving a cross-link transaction inquiry request, wherein the cross-link transaction inquiry request comprises an identification of a target link.
S402, verifying the signature in the cross-chain transaction inquiry request. If the verification is passed, S403 is executed; if the verification is not passed, the cross-chain process is terminated.
S403, decoding the cross-link transaction inquiry request to acquire cross-link transaction data of the target link.
S404, performing signature processing on the cross-link transaction data of the target chain, and sending the cross-link transaction data after signature processing to the target chain.
In this embodiment, for example, a shim communication interface may be called, and the signed cross-chain transaction data after processing is sent to the target chain.
According to the cross-chain processing method for the multi-chain blockchain system, on the basis of any one of the above embodiments, the security and reliability of the cross-chain processing are further improved by performing signature processing on the cross-chain transaction inquiry request and the cross-chain transaction data.
FIG. 5 is a flowchart of another embodiment of a cross-chain processing method for use in a multi-chain blockchain system provided by the present invention. The method provided in this embodiment may be applied to a target chain, as shown in fig. 5, where the method provided in this embodiment may include:
s501, sending a cross-link transaction inquiry request to a source chain, wherein the cross-link transaction inquiry request comprises an identification of a target chain.
Optionally, in this embodiment, the target chain may first establish an RPC connection with the source chain before sending the cross-chain transaction query request to the source chain.
In this embodiment, the target chain may periodically send a cross-link transaction query request to the source chain, or may send a cross-link transaction query request to the source chain when receiving the trigger type message. The trigger target chain sends trigger type information of the cross-chain transaction inquiry request, and the trigger type information can be triggered by any node in the multi-chain block chain system. The triggering type information does not directly modify any account book data, but only triggers the transfer chain code to transfer data according to the source account number information and the target account number information of the cross-chain transaction data.
S502, receiving cross-link transaction data sent by a source chain, wherein the cross-link transaction data is acquired from a transit chain table of the source chain according to the identification of a target chain.
In this embodiment, the target link receives the cross-link transaction data, which is obtained by the source link from the transit linked list of the source link according to the identifier of the target link.
S503, performing cross-link processing according to the cross-link transaction data.
According to the cross-chain processing method for the multi-chain blockchain system, the cross-chain transaction inquiry request comprising the identification of the target chain is sent to the source chain, the cross-chain transaction data sent by the source chain is received, the cross-chain transaction data are obtained from the transit chain table of the source chain according to the identification of the target chain, and the cross-chain processing is carried out according to the cross-chain transaction data, so that the cross-chain processing in the multi-chain blockchain system is realized, and the application range of the multi-chain blockchain system is expanded.
Optionally, to improve the security and reliability of the cross-chain process, before sending the cross-chain transaction query request to the source chain, the method may further include: the cross-chain transaction query request is signed. The embodiment does not limit the specific implementation of the signature.
Optionally, in order to facilitate subsequent tracing of the cross-link processing, on the basis of the foregoing embodiment, the method provided in this embodiment may further include: the cross-chain process is recorded in the same ledger as the in-chain process in the target chain.
Optionally, the method may further include: and updating the transaction state corresponding to the cross-chain transaction data according to the cross-chain processing result. For example, if the cross-link processing is successful, transferring the corresponding data to the target account, and updating the transaction state corresponding to the cross-link transaction data to Success; if the cross-link processing fails, the corresponding data is returned to the source account, and the transaction state corresponding to the cross-link transaction data is updated to Fail.
On the basis of the above embodiments, the present embodiment combines the above embodiments. FIG. 6 is a flowchart of another embodiment of a cross-chain processing method for use in a multi-chain blockchain system provided by the present invention. As shown in fig. 6, the method provided in this embodiment may include:
S601, establishing RPC connection with a source chain.
In this embodiment, the chain code of the target chain may call a shim. Invoke network code interface, for example, to query an endpoint of a participating node in a sub-blockchain network of the target network corresponding to the organization, and then establish an RPC connection with the node.
S602, signing the cross-link transaction inquiry request, and sending the signed cross-link transaction inquiry request to a source link, wherein the cross-link transaction inquiry request comprises an identifier of a target link.
In order to improve the security and reliability, signature processing is performed on the cross-chain transaction inquiry request in the embodiment. In this embodiment, for example, the signed cross-link transaction query request may be packaged into an RPC request and sent to the source link node.
S603, receiving cross-link transaction data sent by a source chain, wherein the cross-link transaction data is acquired from a transit chain table of the source chain according to the identification of a target chain.
A response message of a source chain to a cross-chain transaction query request is received.
S604, performing signature verification and decoding on the cross-chain transaction data, and performing cross-chain processing according to the decoded cross-chain transaction data.
In this embodiment, after receiving the cross-link transaction data sent by the source link, signature verification is performed on the data, and if the verification is passed, the subsequent cross-link processing is continuously performed; if the verification is not passed, the cross-chain process is terminated. And decoding the cross-chain transaction data with the signature verification passing, and returning the decoded data to the corresponding chain code so as to perform cross-chain processing.
Fig. 7 is a signaling flow diagram of another embodiment of a cross-chain processing method for use in a multi-chain blockchain system provided by the present invention. As shown in fig. 7, the method provided in this embodiment may include:
s701, a client sends transaction request information to a source chain, wherein the transaction request information comprises source account information, target account information and asset transfer information.
For example, when a user needs to transfer 50 units of digital certificates from account a to account B, corresponding instruction information may be input to the client, and the client may generate transaction request information according to the instruction information input by the user and transmit the transaction request information to the source chain.
The transaction request information in this embodiment may include, for example, source account information, account a, target account information, account B, and asset transfer information, i.e., 50 units of digital certificate.
S702, a source chain sends an account query request to a system chain, wherein the account query request comprises target account information.
In this embodiment, after receiving the transaction request information sent by the client, the source chain sends an account query request to the system chain.
S703, the system chain determines the sub-block chain identification corresponding to the target account information according to the target account information.
The system chain in this embodiment may include a mapping relationship between the account number and the sub-block chain identifier, so that a function of searching for the sub-block chain identifier corresponding to the account number can be provided.
S704, the system chain sends the sub-block chain identification corresponding to the target account information to the source chain.
In this embodiment, after determining the sub-blockchain identifier corresponding to the target account information, the system chain sends the sub-blockchain identifier corresponding to the target account information to the source chain. It can be understood that, in this embodiment, the identifier of the sub-blockchain corresponding to the target account information is the identifier of the target chain.
S705, the source chain determines cross-chain transaction data according to the sub-block chain identification corresponding to the transaction request information and the target account information, and adds the cross-chain transaction data into a transfer chain table of the source chain.
For example, the following data structures may be employed for storing cross-chain transaction data.
S706, the source chain sends the sub-block chain identification corresponding to the target account information to the client.
Optionally, the source chain may send the sub-block chain identifier corresponding to the target account information to the client, that is, inform the client of the identifier of the target chain.
S707, the client sends a first trigger message to the target chain, which is used for triggering the target chain to initiate the cross-chain transaction inquiry.
Optionally, the first trigger message may include an identifier of the source chain, so that the target chain sends a cross-chain transaction query request to the source chain.
S708, the target chain sends a cross-chain transaction inquiry request to the source chain, wherein the cross-chain transaction inquiry request comprises the identification of the target chain.
S709, the source chain acquires the cross-chain transaction data of the target chain from the transit chain table of the source chain according to the identification of the target chain.
S710, the source chain sends the cross-chain transaction data of the target chain to the target chain.
S711, the target chain performs cross-chain processing according to the cross-chain transaction data, and updates the transaction state corresponding to the cross-chain transaction data according to the result of the cross-chain processing.
And S712, the client sends a second trigger message to the source chain, and the second trigger message is used for triggering the source chain to initiate cleaning of the transfer chain table.
It should be noted that, the second trigger message in this embodiment may be triggered by the client, or may be triggered periodically.
S713, the source chain sends a transaction state query request to the target chain.
S714, the target chain sends a transaction state response message to the source chain.
S715, the source chain cleans the transfer chain table according to the transaction state response message.
If the transaction state corresponding to the cross-link transaction data is successful, deleting the cross-link transaction data from the transit linked list; if the transaction state corresponding to the cross-link transaction data is failure, returning the asset corresponding to the cross-link transaction data to the source account, and deleting the cross-link transaction data from the transfer linked list.
As shown in fig. 7, a successful cross-chain transaction requires the client to initiate three sub-transactions, and only if at least the first two sub-transactions are successful, a cross-chain transaction is considered successful. It will be appreciated that if the cross-chain transaction fails, the client will typically actively trigger a third sub-transaction in order to facilitate rollback of the digital voucher for the transfer to the source account. The transfer linked list of the source chain is cleaned, so that the problem that the system is slow down due to too much data in the transfer linked list can be effectively prevented. It should be noted that, the cleaning of the transfer chain table may be triggered by the client of the cross-chain transaction source account, or may be triggered periodically by a specific periodic trigger condition.
As shown in fig. 7, in the second and third sub-transactions of this embodiment, the trigger type message is sent by the client. The trigger type message can be sent by any node in the network, and can not directly modify any account book data, but only trigger the transfer of the digital certificate by the transfer code according to the source account number information and the target account number information in the cross-link transaction data, so that the trigger can not interfere the cross-link processing.
Alternatively, once triggered, the entire process may be logged into the ledger of each sub-blockchain participating in the cross-chain process. Because the asset transfer can only be carried out by the transfer chain code according to the source account information and the target account information when the cross-chain transaction is initiated, the occurrence of double-flower situation can be avoided.
FIG. 8 is a flow chart of a method for cross-chain processing in a multi-chain blockchain system according to the present invention. As shown in FIG. 8, a cross-chain process flow between a source chain, sub-blockchain p, and a target chain, sub-blockchain q, is shown.
Optionally, each network node may include a relay link code and a traffic link code. Wherein, the chain transfer code is used as the pre-installed chain code and is installed in the same channel with the service chain code. The cross-link processing is completed by the transfer link code so as to reduce the influence on the service link code, and in order to facilitate the tracing of the cross-link operation later, the transfer link code records the cross-link processing flow of the transfer link code and the service link code in the same account book. As shown in fig. 8, the transfer chain code and the service chain code of the sub-blockchain p will record corresponding data in the ledger of the sub-blockchain p, namely, ledger 1; the transfer chain code and the service chain code of the sub-blockchain q will record corresponding data in the ledger of the sub-blockchain q, i.e. ledger 2.
As shown in fig. 8, the source account information and the target account information mark the source address and the destination address of the data to be transferred, the asset information marks the number of digital certificates to be transferred, and the transfer code will transfer the digital certificates strictly according to the source account information and the target account information, so as to avoid the double-flower situation. If the cross-chain transaction is successful, the digital certificate is transferred to the target account, otherwise, the digital certificate is returned to the source account.
For example, in Hyperledger Fabric, the transcoding provides the following interfaces:
func(stub*ChaincodeStub)Send(sourceChaincodeName string,sourceAccount[][]byte,targetAccount[][]byte,args[][]byte)pb.Response
func (stub) Rcv (targetChaincodeName string, sourceacount [ ] byte, targetAccount [ ] byte, transactionId string) pb.
FIG. 9 is a block diagram illustrating an exemplary embodiment of a cross-chain processing apparatus for use in a multi-chain blockchain system. As shown in fig. 9, the cross-chain processing apparatus 90 for use in a multi-chain blockchain system provided in this embodiment may include: a receiving module 901, an acquiring module 902 and a transmitting module 903.
A receiving module 901, configured to receive a cross-link transaction query request, where the cross-link transaction query request includes an identifier of a target link;
the acquiring module 902 is configured to acquire, according to an identifier of a target chain, cross-link transaction data of the target chain from a transfer link table of a source chain, where the transfer link table is used to store cross-link transaction data to be processed;
the sending module 903 is configured to send the cross-link transaction data of the target link to the target link, so that the target link performs cross-link processing according to the cross-link transaction data.
The device of the present embodiment may be used to implement the technical solution of the method embodiment shown in fig. 2, and its implementation principle and technical effects are similar, and are not described here again.
Optionally, after receiving the cross-chain transaction query request, the signature in the cross-chain transaction query request may also be verified.
Alternatively, the cross-chain process and the in-chain process may also be recorded in the same ledger in the source chain.
Optionally, before receiving the cross-chain transaction query request, the method may further include: receiving transaction request information sent by a client, wherein the transaction request information comprises source account information, target account information and asset transfer information; acquiring a sub-block chain identifier corresponding to target account information; determining cross-link transaction data according to the transaction request information and the sub-block link identification; and adding the cross-chain transaction data into a transit linked list of the source chain.
Optionally, obtaining the sub-blockchain identifier corresponding to the target account information may specifically include: an account inquiry request is sent to a system chain, wherein the account inquiry request comprises target account information, so that the system chain determines a sub-block chain identifier corresponding to the target account information according to the target account information, and the system chain comprises a mapping relation between an account and the sub-block chain identifier; and receiving a sub-block chain identifier corresponding to the target account information returned by the system chain.
Optionally, the method may further include: acquiring transaction states corresponding to each cross-link transaction data in a transfer linked list; and if the transaction state corresponding to the cross-link transaction data is successful, deleting the cross-link transaction data from the transfer linked list.
FIG. 10 is a block diagram of a cross-chain processing apparatus for use in a multi-chain blockchain system according to another embodiment of the present invention. As shown in fig. 10, the cross-chain processing apparatus 100 for use in a multi-chain blockchain system provided in this embodiment may include: a transmission module 1001, a reception module 1002, and a processing module 1003.
A sending module 1001, configured to send a cross-link transaction query request to a source chain, where the cross-link transaction query request includes an identifier of a target chain.
The receiving module 1002 is configured to receive cross-link transaction data sent by a source chain, where the cross-link transaction data is obtained by the source chain from a transit linked list of the source chain according to an identifier of a target chain.
And the processing module 1003 is used for performing cross-chain processing according to the cross-chain transaction data.
The device of the present embodiment may be used to implement the technical solution of the method embodiment shown in fig. 5, and its implementation principle and technical effects are similar, and are not described here again.
Optionally, the cross-chain transaction query request may also be signed before being sent to the source chain.
Alternatively, the cross-chain process and the in-chain process may also be recorded in the same ledger in the target chain.
Optionally, the transaction state corresponding to the cross-link transaction data may be updated according to the result of the cross-link processing.
An embodiment of the present invention further provides an electronic device, and referring to fig. 11, the embodiment of the present invention is illustrated by taking fig. 11 as an example only, and the present invention is not limited thereto. Fig. 11 is a schematic structural diagram of an embodiment of an electronic device according to the present invention. As shown in fig. 11, the electronic device 110 provided in this embodiment may include: memory 1101, processor 1102, and bus 1103. Wherein the bus 1103 is used to implement the connections between the elements.
The memory 1101 stores a computer program that, when executed by the processor 1102, implements the technical solution of any of the method embodiments described above.
Wherein the memory 1101 and the processor 1102 are electrically connected, either directly or indirectly, to enable transmission or interaction of data. For example, the elements may be electrically coupled to each other via one or more communication buses or signal lines, such as via the bus 1103. Stored in memory 1101 is a computer program that implements a cross-chain processing method for use in a multi-chain blockchain system, including at least one software functional module that may be stored in memory 1101 in the form of software or firmware, and processor 1102 performs various functional applications and data processing by executing the software programs and modules stored in memory 1101.
The Memory 1101 may be, but is not limited to, a random access Memory (Random Access Memory, abbreviated as RAM), a Read Only Memory (ROM), a programmable Read Only Memory (Programmable Read-Only Memory, abbreviated as PROM), an erasable Read Only Memory (Erasable Programmable Read-Only Memory, abbreviated as EPROM), an electrically erasable Read Only Memory (Electric Erasable Programmable Read-Only Memory, abbreviated as EEPROM), etc. The memory 1101 is used for storing a program, and the processor 1102 executes the program after receiving an execution instruction. Further, the software programs and modules within the memory 1101 may also include an operating system, which may include various software components and/or drivers for managing system tasks (e.g., memory management, storage device control, power management, etc.), and may communicate with various hardware or software components to provide an operating environment for other software components.
The processor 1102 may be an integrated circuit chip with signal processing capabilities. The processor 1102 may be a general-purpose processor, including a central processing unit (Central Processing Unit, abbreviated as CPU), a network processor (Network Processor, abbreviated as NP), and the like. The disclosed methods, steps, and logic blocks in the embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. It will be appreciated that the configuration of fig. 11 is merely illustrative and may include more or fewer components than shown in fig. 11 or have a different configuration than shown in fig. 11. The components shown in fig. 11 may be implemented in hardware and/or software.
It should be noted that, the electronic device provided in this embodiment includes, but is not limited to, at least one of the following: user side equipment and network side equipment. User-side devices include, but are not limited to, computers, smart phones, tablets, digital broadcast terminals, messaging devices, game consoles, personal digital assistants, and the like. Network-side devices include, but are not limited to, a single network server, a server group of multiple network servers, or a cloud of large numbers of computers or network servers based on cloud computing, where cloud computing is one of distributed computing, and is a super virtual computer consisting of a group of loosely coupled computers.
The electronic device provided in this embodiment may be used to execute the method for processing a cross-link applied to a source chain provided in any one of the method embodiments described above, and/or the method for processing a cross-link applied to a target chain provided in any one of the method embodiments described above, and its implementation principle and technical effect are similar and are not repeated here.
The embodiment of the invention also provides a multi-chain blockchain system, which can comprise: a system chain and a plurality of sub-block chains; the network topology structures, the consensus algorithm and the organization participants of the multiple sub-blockchains are the same; the system chain comprises a mapping relation between an account number and a sub-block chain identifier, and is used for determining the sub-block chain identifier corresponding to the account number according to the account number; source chains of the plurality of sub-blockchains may be cross-chain processed using a cross-chain processing method applied to the source chains for use in a multi-chain blockchain system; target chains of the plurality of sub-blockchains may be cross-chain processed using a cross-chain processing method applied to the target chains for use in a multi-chain blockchain system.
The embodiment of the invention also provides a computer readable storage medium, on which a computer program is stored, which when executed by a processor, can implement the method for cross-chain processing in a multi-chain blockchain system provided by any of the method embodiments. The computer readable storage medium in this embodiment may be any available medium that can be accessed by a computer or a data storage device such as a server, a data center, etc. that contains one or more available medium(s) integrated, and the available medium may be a magnetic medium, (e.g., a floppy disk, a hard disk, a magnetic tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., an SSD), etc.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present invention, and not for limiting the same; although the invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the invention.