Data migration methods, apparatus and devices applied to blockchain

CN116841988BActive Publication Date: 2026-08-14ANTCHAIN TECHNOLOGY PTE LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-28
Publication Date
2026-08-14

Smart Images

  • Figure CN116841988B_ABST
    Figure CN116841988B_ABST
Patent Text Reader

Abstract

This specification provides a data migration method, apparatus, and device applied to blockchain. The method includes: acquiring historical transaction data to be migrated from the original blockchain; constructing a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated; wherein the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated; and executing the new transaction in the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.
Need to check novelty before this filing date? Find Prior Art

Description

[0001] This patent application is a divisional application of Chinese patent application No. 201910348981.1, filed on April 28, 2019, entitled "Data Migration Method, Apparatus and Device Applied to Blockchain". Technical Field

[0002] This document relates to the field of computer technology, and in particular to a data migration method, apparatus, and device applied to blockchain. Background Technology

[0003] In blockchain, data migration is necessary when the blockchain platform is upgraded. For example, if the underlying data storage of the blockchain platform is upgraded, the data needs to be migrated to the upgraded database to avoid incompatibility issues. Similarly, if the upper-layer data structure of the blockchain platform is upgraded, data migration is required to prevent the blockchain platform from being unable to parse the data based on the upgraded upper-layer data structure. Therefore, it is necessary to provide a technical solution for migrating data in the blockchain. Summary of the Invention

[0004] This specification provides a data migration method applied to blockchain. The method includes constructing a new transaction on the target blockchain corresponding to the historical transaction data to be migrated from the original blockchain, according to the transaction data structure of the target blockchain. The new transaction is executed on the target blockchain to migrate the historical transaction data to the target blockchain. A contract call transaction is executed on the target blockchain to associate and store a first hash value of the historical transaction data and a second hash value of the new transaction on the target blockchain through a called association contract. The associated and stored first and second hash values ​​are used for querying the historical transaction content corresponding to the historical transaction data in the target blockchain.

[0005] This specification provides a data migration device applied to blockchain. The device includes a transaction construction module, which constructs a new transaction on the target blockchain corresponding to the historical transaction data to be migrated from the original blockchain, according to the transaction data structure of the target blockchain. The device also includes a transaction execution module, which executes the new transaction on the target blockchain to migrate the historical transaction data to the target blockchain. Furthermore, the device includes a hash association module, which executes a contract call transaction on the target blockchain to associate and store a first hash value of the historical transaction data and a second hash value of the new transaction on the target blockchain through the invoked association contract. The associated and stored first and second hash values ​​are used for querying the historical transaction content corresponding to the historical transaction data on the target blockchain.

[0006] This specification provides a data migration device for blockchain applications, comprising: a processor; and a memory arranged to store computer-executable instructions, which, when executed, cause the processor to construct a new transaction in the target blockchain corresponding to historical transaction data to be migrated from the original blockchain, according to the transaction data structure of the target blockchain. The new transaction is executed in the target blockchain to migrate the historical transaction data to the target blockchain. A contract call transaction is executed in the target blockchain to associate and store a first hash value of the historical transaction data and a second hash value of the new transaction in the target blockchain through a called associated contract. The associated and stored first and second hash values ​​are used for querying historical transaction content corresponding to the historical transaction data in the target blockchain.

[0007] This specification provides a storage medium for storing computer-executable instructions. When executed, these instructions construct a new transaction on the target blockchain that corresponds to historical transaction data to be migrated from the original blockchain, according to the transaction data structure of the target blockchain. The new transaction is executed on the target blockchain to migrate the historical transaction data. A contract call transaction is executed on the target blockchain to associate and store a first hash value of the historical transaction data and a second hash value of the new transaction on the target blockchain through a called associated contract. The associated and stored first and second hash values ​​are used for querying historical transaction content corresponding to the historical transaction data on the target blockchain. Attached Figure Description

[0008] To more clearly illustrate the technical solutions in the embodiments or prior art of this specification, the drawings used in the description of the embodiments or prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in this specification. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0009] Figure 1 This is a flowchart illustrating a data migration method applied to blockchain, as provided in one embodiment of this specification.

[0010] Figure 2 A flowchart illustrating a data migration method applied to blockchain, as provided in another embodiment of this specification;

[0011] Figure 3 A flowchart illustrating a data migration method applied to blockchain, as provided in another embodiment of this specification;

[0012] Figure 4A flowchart illustrating a data migration method applied to blockchain, as provided in another embodiment of this specification;

[0013] Figure 5 This is a schematic diagram of the module composition of a data migration device provided in one embodiment of this specification;

[0014] Figure 6 This is a schematic diagram of the module composition of a data migration device provided in another embodiment of this specification;

[0015] Figure 7 This is a schematic diagram of a data migration device applied to blockchain, provided as an embodiment of this specification. Detailed Implementation

[0016] To enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this specification, and not all embodiments. Based on the embodiments in this specification, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of this specification.

[0017] The purpose of this specification is to provide a data migration method, apparatus, and device for blockchain applications, for migrating data within a blockchain. The data migration method can be applied in consortium blockchain scenarios to achieve blockchain data migration within such scenarios. The methods described in this specification can be executed by a specific data migration plugin, which can run on a standalone computer device or on the target blockchain platform to which the data is being migrated.

[0018] Figure 1 This is a flowchart illustrating a data migration method applied to blockchain according to an embodiment of this specification, as shown below. Figure 1 As shown, the method includes the following steps:

[0019] Step S102: Obtain the historical transaction data to be migrated from the original blockchain;

[0020] Step S104: According to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, construct a new transaction in the target blockchain corresponding to the historical transaction data to be migrated; wherein, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated.

[0021] Step S106: Execute a new transaction on the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.

[0022] In this embodiment, the historical transaction data to be migrated from the original blockchain is first obtained. Then, according to the transaction data structure of the target blockchain to which the historical transaction data is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain. This new transaction represents the historical transaction content corresponding to the historical transaction data to be migrated. Finally, the new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated. Therefore, through this embodiment, historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data within the blockchain.

[0023] In step S102 above, each block in the original blockchain is traversed sequentially to obtain historical transaction data from the original blockchain, and this historical transaction data is used as the historical transaction data to be migrated. The historical transaction data to be migrated includes, but is not limited to, transfer data between accounts and account creation data.

[0024] In step S104 above, according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, specifically as follows:

[0025] (a1) Parse the transaction data structure of the target blockchain to obtain the names of each transaction field included in the transaction data structure of the target blockchain;

[0026] (a2) Extract the field values ​​corresponding to each transaction field name from the historical transaction data to be migrated;

[0027] (a3) According to the transaction data structure of the target blockchain, the field values ​​corresponding to each transaction field name are concatenated in the target blockchain to obtain a new transaction.

[0028] In a specific example, the historical transaction data to be migrated is: "On March 1, 2019, Zhang San transferred 10 yuan to Li Si." The transaction data structure of the target blockchain is "Transferor-Recipient-Transfer Time-Transfer Amount." In this example, firstly, the transaction data structure of the target blockchain is parsed to obtain the names of the various transaction fields, which are: Transferor, Recipient, Transfer Time, and Transfer Amount. Then, the field values ​​corresponding to each transaction field name are extracted from the historical transaction data to be migrated, resulting in "Zhang San" for "Transferor," "Li Si" for "Recipient," "March 1, 2019" for "Transfer Time," and "10 yuan" for "Transfer Amount." Finally, according to the transaction data structure of the target blockchain, the field values ​​corresponding to each transaction field name are concatenated in the target blockchain to obtain a new transaction, which is "Zhang San-Li Si-March 1, 2019-10 yuan."

[0029] In this embodiment, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated. That is, the new transaction is the same as the historical transaction content corresponding to the historical transaction data to be migrated. The difference between the new transaction and the historical transaction data to be migrated is that the new transaction matches the transaction data structure of the target blockchain, while the historical transaction data to be migrated matches the transaction data structure of the original blockchain.

[0030] As can be seen, this embodiment takes into account the difference between the transaction data structure of the original blockchain and the data transaction structure of the target blockchain. According to the transaction data structure of the target blockchain, a new transaction corresponding to the historical transaction data to be migrated can be constructed in the target blockchain, and the new transaction can represent the historical transaction content corresponding to the historical transaction data to be migrated.

[0031] In step S106 above, a new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated to the target blockchain. Since the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated, executing the new transaction on the target blockchain is equivalent to re-executing all the historical transactions to be migrated on the target blockchain, thereby achieving the purpose of migrating the historical transaction data to be migrated to the target blockchain.

[0032] As can be seen from the embodiments in this specification, historical transaction data to be migrated can be migrated to the target blockchain through transaction replay. Here, transaction replay can be understood as the re-execution of transactions.

[0033] In this embodiment, after the target blockchain executes a new transaction, it can also verify whether the historical transaction data to be migrated has been successfully migrated. If successful, it is determined that the data migration is complete.

[0034] Furthermore, considering that historical transactions and new transactions have different hash values, Figure 2 This is a flowchart illustrating another embodiment of a data migration method applied to blockchain provided in this specification, such as... Figure 2 As shown, the method is in Figure 1 In addition to the above, the following steps are also included:

[0035] Step S108: Obtain the first hash value of the historical transaction data to be migrated and the second hash value of the new transaction mentioned above;

[0036] Step S110: Construct an association contract for associating the first hash value and the second hash value, and construct a contract call transaction for invoking the association contract;

[0037] Step S112: Execute the contract call transaction on the target blockchain to associate and store the first hash value and the second hash value on the target blockchain.

[0038] Specifically, firstly, the first hash value of the historical transaction data to be migrated and the second hash value of the new transaction are obtained. Then, an association contract is constructed to link the first and second hash values. The association contract stores the first hash value, the second hash value, and the correspondence between the first and second hash values. If a new transaction corresponding to a certain second hash value is constructed based on the historical transaction data to be migrated corresponding to a certain first hash value, then the second hash value and the first hash value correspond to each other. That is, among the corresponding first and second hash values, the new transaction corresponding to the second hash value is constructed based on the historical transaction data to be migrated corresponding to the first hash value.

[0039] Furthermore, a contract invocation transaction is constructed to invoke the associated contract. Finally, the contract invocation transaction is executed on the target blockchain, thereby invoking the aforementioned associated contract. By invoking the associated contract, the first hash value and the second hash value are associated and stored on the target blockchain. Specifically, storing the first hash value and the second hash value on the target blockchain involves storing the first hash value, the second hash value, and the correspondence between them in the target blockchain.

[0040] Furthermore, considering the problem that using the hash value of a new transaction is not conducive to finding historical transaction content, Figure 3 This is a flowchart illustrating another embodiment of a data migration method applied to blockchain provided in this specification, such as... Figure 3 As shown, the method is in Figure 2 In addition to the above, the following steps are also included:

[0041] Step S114: Obtain the first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried;

[0042] Step S116: Invoke the associated contract to determine the second hash value associated with the obtained first hash value;

[0043] Step S118: Locate the new transaction corresponding to the associated second hash value in the target blockchain;

[0044] Step S120: Obtain the aforementioned historical transaction content to be queried from the corresponding new transaction.

[0045] Specifically, the historical transaction content to be queried is first determined, and the historical transaction data to be migrated corresponding to the historical transaction content is determined, that is, the historical transaction data to be migrated used to record the historical transaction content is determined, and the first hash value of the historical transaction data to be migrated is obtained.

[0046] Next, the aforementioned associated contract is invoked to determine the second hash value associated with the obtained first hash value. During this process, the second hash value corresponding to the obtained first hash value can be found in the correspondence between the first and second hash values ​​stored in the aforementioned associated contract, and the found second hash value is used as the second hash value associated with the obtained first hash value.

[0047] Then, the new transaction corresponding to the associated second hash value is searched in the target blockchain; that is, a new transaction with the hash value of the associated second hash value is searched. Since the new transaction is used to represent the historical transaction content of the historical transaction data to be migrated, the aforementioned historical transaction content to be queried can be obtained from the corresponding new transaction found.

[0048] As can be seen, this embodiment enables the storage of hash values ​​of new and old transactions based on the construction of associated contracts, and the query of historical transaction content based on these associated contracts.

[0049] In a specific embodiment, for evidence storage transactions, the process first iterates through all historical evidence storage transactions. Based on the transaction data structure of the target blockchain, a corresponding new transaction is constructed for each historical evidence storage transaction. A contract is then written that associates the historical transaction hash with the new transaction hash, and a contract call transaction is constructed to invoke this contract. Finally, the new transaction and the contract call transaction are executed, thereby completing the transaction data migration. When the business side queries evidence storage data using the historical transaction hash, it can first obtain the new transaction hash by invoking the contract, and then query the evidence storage data using the new transaction hash.

[0050] In summary, the embodiments of this specification have at least the following advantages:

[0051] 1. Historical transaction data migration was achieved by constructing and executing new transactions, while ensuring the integrity of the historical transaction data migration.

[0052] 2. The storage of new and old transaction hash values ​​is realized by constructing a related contract, and the search of historical transaction content is realized based on the related contract.

[0053] Furthermore, this specification also provides a data migration method for blockchain applications, which can be applied in consortium blockchain scenarios to achieve blockchain data migration within those scenarios. The method in this specification embodiment can be executed by a specific data migration plugin, which can run on a separate computer device or on the target blockchain platform to which the data is being migrated.

[0054] Figure 4 This is a flowchart illustrating another embodiment of a data migration method applied to blockchain provided in this specification, such as... Figure 4 As shown, the method includes the following steps:

[0055] Step S402: Obtain the state data to be migrated from the original blockchain, and determine whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain.

[0056] Step S404: If yes, write the state data to be migrated to the target blockchain; otherwise, transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain, and write the transformed state data to be migrated to the target blockchain.

[0057] In the embodiments of this specification, the state data to be migrated from the original blockchain is obtained, and it is determined whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain. If they are homogeneous, the state data to be migrated is written to the target blockchain; if they are not homogeneous, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain. Therefore, through the embodiments of this specification, state data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data from the blockchain.

[0058] In step S402 above, the state data to be migrated from the original blockchain is obtained. For ordinary accounts, the state data to be migrated includes the account balance. For contract accounts, the state data to be migrated includes the account balance and contract variables, etc.

[0059] In step S402 above, it is determined whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain. A homogeneous blockchain refers to a blockchain with consistent data structure, storage, and other designs, while a heterogeneous blockchain (also known as a dissimilar blockchain) refers to a blockchain with inconsistent data structure, storage, and other designs.

[0060] If the target blockchain and the original blockchain are homogeneous, it means that their data structure, storage, and other designs are consistent. Therefore, in step S406, the state data to be migrated can be directly written to the target blockchain. If the target blockchain and the original blockchain are not homogeneous, it means that their data structure, storage, and other designs are inconsistent. Therefore, in step S406, the data storage structure of the state data to be migrated needs to be transformed into the data storage structure of the target blockchain, and then the transformed state data to be migrated is written to the target blockchain.

[0061] In this embodiment, the data storage structure of the state data to be migrated is a key-value structure, and the data storage structure of the target blockchain is a table structure; or, the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key-value structure.

[0062] In this embodiment, transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain can be achieved by: transforming the data storage structure of the state data to be migrated into the core data structure of the underlying blockchain, and then, based on this core data storage structure, transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain. The core data structure of the underlying blockchain can be a tree structure.

[0063] In one embodiment, the data storage structure of the state data to be migrated is a key-value structure, the data storage structure of the target blockchain is a table structure, and the core data structure of the underlying blockchain is a tree structure. The process of transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain involves: traversing the state data to be migrated according to the key-value structure; determining the value of each node and the child node index of each node in the tree structure based on the traversed data indexes and their values; combining the values ​​of each node and their child node indexes to transform the data storage structure of the state data to be migrated into a tree structure; traversing the transformed state data to be migrated according to the tree structure; determining the fields and their values ​​in the table structure based on the values ​​of each node and their child node indexes; and combining the fields and their values ​​to transform the data storage structure of the state data to be migrated into a table structure.

[0064] In another embodiment, the data storage structure of the state data to be migrated is a table structure, the data storage structure of the target blockchain is a key-value structure, and the core data structure of the underlying blockchain is a tree structure. The process of transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain involves: traversing the state data to be migrated according to the table structure; determining the value of each node in the tree structure and the child node index of each node based on the traversed fields and their values; combining the values ​​of each node and the child node indexes to transform the data storage structure of the state data to be migrated into a tree structure; traversing the transformed state data to be migrated according to the tree structure; determining the data indexes and data values ​​of each data index in the key-value structure based on the traversed node values ​​and their child node indexes; and combining the data indexes and their data values ​​to transform the data storage structure of the state data to be migrated into a key-value structure.

[0065] In a specific embodiment, when migrating state data, the system first traverses each account in the original blockchain. If a regular account is reached, its balance value is read, the regular account is created in the target blockchain, and the balance value is migrated. If a contract account is reached, its balance value and contract variables are read, the contract account is created in the target blockchain, and the balance value and contract variables are migrated.

[0066] As can be seen, the method in this embodiment can achieve data migration between homogeneous chains, as well as data migration between dissimilar chains. In specific implementation, the migration state data (also known as world state) or transaction data can be determined first. If the migration is transaction data, then the above-mentioned... Figures 1 to 3 The method described above is used to implement this; if migration status data is involved, then it is done through the above... Figure 4 The method described above is used for implementation. It is understandable that if implemented through the above... Figures 1 to 3 If the transaction data is migrated using the method described in the article, the world state will also be migrated synchronously.

[0067] Corresponding to the above Figures 1 to 3 In addition to the data migration method described above, this specification also provides a data migration device applied to blockchain, which is used to implement the above-mentioned data migration method. Figures 1 to 3 Data migration methods in [the context of data migration]. Figure 5 This is a schematic diagram of the module composition of a data migration device provided in one embodiment of this specification, as shown below. Figure 5 As shown, the device includes:

[0068] The transaction acquisition module 51 is used to acquire the historical transaction data to be migrated from the original blockchain;

[0069] The transaction construction module 52 is used to construct a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated; wherein, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated;

[0070] The transaction execution module 53 is used to execute the new transaction on the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.

[0071] Optionally, the transaction construction module 52 is specifically used to: parse the transaction data structure of the target blockchain to obtain the names of each transaction field included in the transaction data structure of the target blockchain; extract the field values ​​corresponding to each transaction field name from the historical transaction data to be migrated; and concatenate the field values ​​corresponding to each transaction field name in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.

[0072] Optionally, it also includes a hash association module, configured to: obtain a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; construct an association contract for associating the first hash value and the second hash value, and construct a contract call transaction for invoking the association contract; execute the contract call transaction on the target blockchain to associate and store the first hash value and the second hash value on the target blockchain.

[0073] Optionally, it also includes a transaction lookup module, configured to: obtain a first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried; call the associated contract to determine a second hash value associated with the obtained first hash value; search for a new transaction corresponding to the associated second hash value in the target blockchain; and obtain the historical transaction content to be queried from the corresponding new transaction.

[0074] In this embodiment, the historical transaction data to be migrated from the original blockchain is first obtained. Then, according to the transaction data structure of the target blockchain to which the historical transaction data is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain. This new transaction represents the historical transaction content corresponding to the historical transaction data to be migrated. Finally, the new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated. Therefore, through this embodiment, historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data within the blockchain.

[0075] It should be noted that the data migration device in this embodiment can achieve the aforementioned... Figures 1 to 3The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0076] Corresponding to the above Figure 4 In addition to the data migration method described above, this specification also provides a data migration device applied to blockchain, which is used to implement the above-mentioned data migration method. Figure 4 Data migration methods in [the context of data migration]. Figure 6 This is a schematic diagram of the module composition of a data migration device provided in another embodiment of this specification, such as... Figure 6 As shown, the device includes:

[0077] The state acquisition module 61 is used to acquire the state data to be migrated from the original blockchain, and to determine whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain.

[0078] The state transition module 62 is used to write the state data to be migrated into the target blockchain if the state data is to be migrated, and to transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain if the state data is not to be migrated, and to write the transformed state data to be migrated into the target blockchain.

[0079] Optionally, the data storage structure of the state data to be migrated is a key-value structure, and the data storage structure of the target blockchain is a table structure; or, the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key-value structure.

[0080] Optionally, the state transition module 62 is specifically used to: transform the data storage structure of the state data to be migrated into the core data structure of the underlying blockchain; and based on the core data storage structure, transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain.

[0081] In the embodiments of this specification, the state data to be migrated from the original blockchain is obtained, and it is determined whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain. If they are homogeneous, the state data to be migrated is written to the target blockchain; if they are not homogeneous, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain. Therefore, through the embodiments of this specification, state data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data from the blockchain.

[0082] It should be noted that the data migration device in this embodiment can achieve the aforementioned Figure 4The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0083] Furthermore, embodiments of this specification also provide a data migration device applied to blockchain. Figure 7 This is a schematic diagram of the structure of a data migration device applied to blockchain according to one embodiment of this specification, as shown below. Figure 7 As shown, data migration devices applied to blockchain can vary significantly due to differences in configuration or performance. They may include one or more processors 901 and memory 902, with memory 902 storing one or more applications or data. Memory 902 can be temporary or persistent storage. The applications stored in memory 902 may include one or more modules (not shown), each module including a series of computer-executable instructions for the data migration device applied to blockchain. Furthermore, processor 901 may be configured to communicate with memory 902, executing the series of computer-executable instructions in memory 902 on the data migration device applied to blockchain. Data migration devices applied to blockchain may also include one or more power supplies 903, one or more wired or wireless network interfaces 904, one or more input / output interfaces 905, one or more keyboards 906, etc.

[0084] In one specific embodiment, a data migration device applied to a blockchain includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the data migration device applied to the blockchain, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:

[0085] Obtain the historical transaction data to be migrated from the original blockchain;

[0086] According to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain; wherein, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated;

[0087] The new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.

[0088] Optionally, when the computer-executable instructions are executed, according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be constructed, a new transaction corresponding to the historical transaction data to be migrated is constructed in the target blockchain, including: parsing the transaction data structure of the target blockchain to obtain the names of each transaction field included in the transaction data structure of the target blockchain; extracting the field values ​​corresponding to each transaction field name from the historical transaction data to be migrated; and concatenating the field values ​​corresponding to each transaction field name in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.

[0089] Optionally, when the computer-executable instructions are executed, they further include: obtaining a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; constructing an association contract for associating the first hash value and the second hash value, and constructing a contract invocation transaction for invoking the association contract; and executing the contract invocation transaction on the target blockchain to associate and store the first hash value and the second hash value on the target blockchain.

[0090] Optionally, when the computer-executable instructions are executed, they further include: obtaining a first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried; invoking the associated contract to determine a second hash value associated with the obtained first hash value; searching for a new transaction corresponding to the associated second hash value in the target blockchain; and obtaining the historical transaction content to be queried from the corresponding new transaction.

[0091] In this embodiment, the historical transaction data to be migrated from the original blockchain is first obtained. Then, according to the transaction data structure of the target blockchain to which the historical transaction data is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain. This new transaction represents the historical transaction content corresponding to the historical transaction data to be migrated. Finally, the new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated. Therefore, through this embodiment, historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data within the blockchain.

[0092] It should be noted that the data migration device in this embodiment is capable of achieving the aforementioned... Figures 1 to 3 The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0093] In another specific embodiment, the data migration device applied to the blockchain includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the data migration device applied to the blockchain, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:

[0094] Obtain the state data to be migrated from the original blockchain, and determine whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain;

[0095] If yes, the state data to be migrated is written to the target blockchain; otherwise, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain.

[0096] Optionally, when the computer-executable instructions are executed, the data storage structure of the state data to be migrated is a key-value structure, and the data storage structure of the target blockchain is a table structure; or, the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key-value structure.

[0097] Optionally, when the computer-executable instructions are executed, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, including: transforming the data storage structure of the state data to be migrated into the core data structure of the blockchain's underlying layer; and based on the core data storage structure, transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain.

[0098] In the embodiments of this specification, the state data to be migrated from the original blockchain is obtained, and it is determined whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain. If they are homogeneous, the state data to be migrated is written to the target blockchain; if they are not homogeneous, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain. Therefore, through the embodiments of this specification, state data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data from the blockchain.

[0099] It should be noted that the data migration device in this embodiment is capable of achieving the aforementioned... Figure 4The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0100] Furthermore, embodiments of this specification also provide a storage medium for storing computer-executable instructions. In one specific embodiment, the storage medium can be a USB flash drive, optical disc, hard disk, etc. When the computer-executable instructions stored in the storage medium are executed by a processor, they can achieve the following process:

[0101] Obtain the historical transaction data to be migrated from the original blockchain;

[0102] According to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain; wherein, the new transaction is used to represent the historical transaction content corresponding to the historical transaction data to be migrated;

[0103] The new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated to the target blockchain.

[0104] Optionally, when the computer-executable instructions stored in the storage medium are executed by a processor, they construct a new transaction corresponding to the historical transaction data to be migrated in the target blockchain according to the transaction data structure of the target blockchain to which the historical transaction data to be migrated is to be constructed. This includes: parsing the transaction data structure of the target blockchain to obtain the names of each transaction field included in the transaction data structure of the target blockchain; extracting the field values ​​corresponding to each transaction field name in the historical transaction data to be migrated; and concatenating the field values ​​corresponding to each transaction field name in the target blockchain according to the transaction data structure of the target blockchain to obtain the new transaction.

[0105] Optionally, when the computer-executable instructions stored in the storage medium are executed by the processor, they further include: obtaining a first hash value of the historical transaction data to be migrated and a second hash value of the new transaction; constructing an association contract for associating the first hash value and the second hash value, and constructing a contract invocation transaction for invoking the association contract; and executing the contract invocation transaction on the target blockchain to associate and store the first hash value and the second hash value on the target blockchain.

[0106] Optionally, when the computer-executable instructions stored in the storage medium are executed by the processor, they further include: obtaining a first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried; invoking the associated contract to determine a second hash value associated with the obtained first hash value; searching for a new transaction corresponding to the associated second hash value in the target blockchain; and obtaining the historical transaction content to be queried from the corresponding new transaction.

[0107] In this embodiment, the historical transaction data to be migrated from the original blockchain is first obtained. Then, according to the transaction data structure of the target blockchain to which the historical transaction data is to be migrated, a new transaction corresponding to the historical transaction data to be migrated is constructed on the target blockchain. This new transaction represents the historical transaction content corresponding to the historical transaction data to be migrated. Finally, the new transaction is executed on the target blockchain to migrate the historical transaction data to be migrated. Therefore, through this embodiment, historical transaction data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data within the blockchain.

[0108] It should be noted that the storage medium in this embodiment is capable of achieving the aforementioned... Figures 1 to 3 The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0109] In another specific embodiment, the data migration device applied to the blockchain includes a memory and one or more programs, wherein the one or more programs are stored in the memory, and the one or more programs may include one or more modules, and each module may include a series of computer-executable instructions for the data migration device applied to the blockchain, and is configured to be executed by one or more processors. The one or more programs include computer-executable instructions for performing the following:

[0110] Obtain the state data to be migrated from the original blockchain, and determine whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain;

[0111] If yes, the state data to be migrated is written to the target blockchain; otherwise, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain.

[0112] Optionally, when the computer-executable instructions stored in the storage medium are executed by a processor, the data storage structure of the state data to be migrated is a key-value structure, and the data storage structure of the target blockchain is a table structure; or, the data storage structure of the state data to be migrated is a table structure, and the data storage structure of the target blockchain is a key-value structure.

[0113] Optionally, when the computer-executable instructions stored in the storage medium are executed by the processor, they transform the data storage structure of the state data to be migrated into the data storage structure of the target blockchain, including: transforming the data storage structure of the state data to be migrated into the core data structure of the blockchain's underlying layer; and based on the core data storage structure, transforming the data storage structure of the state data to be migrated into the data storage structure of the target blockchain.

[0114] In the embodiments of this specification, the state data to be migrated from the original blockchain is obtained, and it is determined whether the target blockchain to which the state data to be migrated is homogeneous with the original blockchain. If they are homogeneous, the state data to be migrated is written to the target blockchain; if they are not homogeneous, the data storage structure of the state data to be migrated is transformed into the data storage structure of the target blockchain, and the transformed state data to be migrated is written to the target blockchain. Therefore, through the embodiments of this specification, state data to be migrated can be migrated from the original blockchain to the target blockchain, thereby achieving the purpose of migrating data from the blockchain.

[0115] It should be noted that the storage medium in this embodiment is capable of achieving the aforementioned... Figure 4 The various processes of the data migration method in [the text], and how to achieve the same function and effect, will not be repeated here.

[0116] In the 1990s, improvements to a technology could be clearly distinguished as either hardware improvements (e.g., improvements to the circuit structure of diodes, transistors, switches, etc.) or software improvements (improvements to the methodology). However, with technological advancements, many methodological improvements today can be considered direct improvements to the hardware circuit structure. Designers almost always obtain the corresponding hardware circuit structure by programming the improved methodology into the hardware circuit. Therefore, it cannot be said that a methodological improvement cannot be implemented using a hardware physical module. For example, a Programmable Logic Device (PLD) (e.g., a Field Programmable Gate Array (FPGA)) is such an integrated circuit whose logic function is determined by the user programming the device. Designers can program a digital system themselves to "integrate" it onto a PLD, without needing chip manufacturers to design and manufacture dedicated integrated circuit chips. Furthermore, nowadays, instead of manually manufacturing integrated circuit chips, this programming is mostly implemented using "logic compiler" software. Similar to the software compiler used in program development, the original code before compilation must be written in a specific programming language, called a Hardware Description Language (HDL). There are many HDLs, such as ABEL (Advanced Boolean Expression Language), AHDL (Altera Hardware Description Language), Confluence, CUPL (Cornell University Programming Language), HDCal, JHDL (Java Hardware Description Language), Lava, Lola, MyHDL, PALASM, and RHDL (Ruby Hardware Description Language). Currently, the most commonly used are VHDL (Very-High-Speed ​​Integrated Circuit Hardware Description Language) and Verilog. Those skilled in the art should understand that by simply performing some logic programming on the method flow using one of these hardware description languages ​​and programming it into an integrated circuit, the hardware circuit implementing the logical method flow can be easily obtained.

[0117] The controller can be implemented in any suitable manner. For example, it can take the form of a microprocessor or processor and a computer-readable medium storing computer-readable program code (e.g., software or firmware) executable by the (micro)processor, logic gates, switches, application-specific integrated circuits (ASICs), programmable logic controllers, and embedded microcontrollers. Examples of controllers include, but are not limited to, the following microcontrollers: ARC 625D, Atmel AT91SAM, Microchip PIC18F26K20, and Silicon Labs C8051F320. A memory controller can also be implemented as part of the control logic of the memory. Those skilled in the art will also recognize that, in addition to implementing the controller in purely computer-readable program code form, the same functionality can be achieved by logically programming the method steps to make the controller take the form of logic gates, switches, application-specific integrated circuits, programmable logic controllers, and embedded microcontrollers. Therefore, such a controller can be considered a hardware component, and the means included therein for implementing various functions can also be considered as structures within the hardware component. Alternatively, the means for implementing various functions can be considered as both software modules implementing the method and structures within the hardware component.

[0118] The systems, devices, modules, or units described in the above embodiments can be implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, a computer can be, for example, a personal computer, laptop computer, cellular phone, camera phone, smartphone, personal digital assistant, media player, navigation device, email device, game console, tablet computer, wearable device, or any combination of these devices.

[0119] For ease of description, the above devices are described in terms of function, divided into various units. Of course, in implementing this specification, the functions of each unit can be implemented in one or more software and / or hardware components.

[0120] Those skilled in the art will understand that embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0121] This specification is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this specification. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create a machine for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0122] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0123] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0124] In a typical configuration, a computing device includes one or more processors (CPU), input / output interfaces, network interfaces, and memory.

[0125] Memory may include non-persistent storage in computer-readable media, such as random access memory (RAM) and / or non-volatile memory, such as read-only memory (ROM) or flash RAM. Memory is an example of computer-readable media.

[0126] Computer-readable media includes both permanent and non-permanent, removable and non-removable media that can store information using any method or technology. Information can be computer-readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, CD-ROM, digital versatile optical disc (DVD) or other optical storage, magnetic tape, magnetic magnetic disk storage or other magnetic storage devices, or any other non-transferable medium that can be used to store information accessible by a computing device. As defined herein, computer-readable media does not include transient computer-readable media, such as modulated data signals and carrier waves.

[0127] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.

[0128] Those skilled in the art will understand that the embodiments of this specification can be provided as methods, systems, or computer program products. Therefore, this specification may take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this specification may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0129] This specification can be described in the general context of computer-executable instructions that are executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc., that perform a specific task or implement a specific abstract data type. This specification can also be practiced in distributed computing environments, where tasks are performed by remote processing devices connected via a communication network. In distributed computing environments, program modules can reside in local and remote computer storage media, including storage devices.

[0130] The various embodiments in this specification are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the system embodiments are basically similar to the method embodiments, so the description is relatively simple; relevant parts can be referred to the descriptions in the method embodiments.

[0131] The above description is merely an embodiment of this document and is not intended to limit the scope of this document. Various modifications and variations can be made to this document by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this document should be included within the scope of the claims of this document.

Claims

1. A data migration method applied to blockchain, comprising: Based on the transaction data structure of the target blockchain, a new transaction is constructed on the target blockchain that corresponds to the historical transaction data to be migrated from the original blockchain; The new transaction is executed on the target blockchain to migrate the historical transaction data to the target blockchain; A contract call transaction is executed on the target blockchain to associate and store the first hash value of the historical transaction data and the second hash value of the new transaction on the target blockchain through the associated contract. The associated and stored first hash value and second hash value are used to query the historical transaction content corresponding to the historical transaction data on the target blockchain.

2. The method according to claim 1, wherein constructing a new transaction in the target blockchain corresponding to the historical transaction data to be migrated in the original blockchain according to the transaction data structure of the target blockchain includes: The transaction data structure of the target blockchain is parsed to obtain the names of each transaction field included in the transaction data structure of the target blockchain; Extract the field values ​​corresponding to each transaction field name from the historical transaction data to be migrated; According to the transaction data structure of the target blockchain, the field values ​​corresponding to each transaction field name are concatenated in the target blockchain to obtain the new transaction.

3. The method according to claim 1 or 2, wherein before the contract call transaction is executed on the target blockchain, the method further comprises: Obtain the first hash value of the historical transaction data to be migrated and the second hash value of the new transaction; Construct the associated contract for associating the first hash value and the second hash value, and construct the contract invocation transaction for invoking the associated contract.

4. The method according to claim 1, further comprising: Obtain the first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried; Invoke the associated contract to determine the second hash value associated with the obtained first hash value; Search the target blockchain for the new transaction corresponding to the associated second hash value; Obtain the historical transaction content to be queried from the corresponding new transaction.

5. A data migration device for blockchain applications, comprising: The transaction construction module constructs a new transaction on the target blockchain that corresponds to the historical transaction data to be migrated from the original blockchain, according to the transaction data structure of the target blockchain. The transaction execution module executes the new transaction on the target blockchain to migrate the historical transaction data to the target blockchain; The hash association module executes a contract call transaction on the target blockchain to associate and store the first hash value of the historical transaction data and the second hash value of the new transaction on the target blockchain through the invoked association contract; the associated and stored first and second hash values ​​are used to query the historical transaction content corresponding to the historical transaction data on the target blockchain.

6. The apparatus according to claim 5, The transaction construction module parses the transaction data structure of the target blockchain to obtain the names of each transaction field included in the transaction data structure of the target blockchain; and, Extract the field values ​​corresponding to each transaction field name from the historical transaction data to be migrated; According to the transaction data structure of the target blockchain, the field values ​​corresponding to each transaction field name are concatenated in the target blockchain to obtain the new transaction.

7. The apparatus according to claim 5 or 6, The hash association module also obtains the first hash value of the historical transaction data to be migrated and the second hash value of the new transaction; and, Construct the associated contract for associating the first hash value and the second hash value, and construct the contract call transaction for invoking the associated contract.

8. The apparatus according to claim 5, further comprising: The transaction lookup module retrieves the first hash value of the historical transaction data to be migrated corresponding to the historical transaction content to be queried. as well as, Invoke the associated contract to determine the second hash value associated with the obtained first hash value; Search the target blockchain for the new transaction corresponding to the associated second hash value; Obtain the historical transaction content to be queried from the corresponding new transaction.

9. A data migration device for blockchain applications, comprising: processor; and memory arranged to store computer-executable instructions, which, when executed, cause the processor to: Based on the transaction data structure of the target blockchain, a new transaction is constructed on the target blockchain that corresponds to the historical transaction data to be migrated from the original blockchain; The new transaction is executed on the target blockchain to migrate the historical transaction data to the target blockchain; A contract call transaction is executed on the target blockchain to associate and store the first hash value of the historical transaction data and the second hash value of the new transaction on the target blockchain through the associated contract. The associated and stored first hash value and second hash value are used to query the historical transaction content corresponding to the historical transaction data on the target blockchain.

10. A storage medium for storing computer-executable instructions, which, when executed by a processor, perform the following process: Based on the transaction data structure of the target blockchain, a new transaction is constructed on the target blockchain that corresponds to the historical transaction data to be migrated from the original blockchain; The new transaction is executed on the target blockchain to migrate the historical transaction data to the target blockchain; A contract call transaction is executed on the target blockchain to associate and store the first hash value of the historical transaction data and the second hash value of the new transaction on the target blockchain through the associated contract. The associated and stored first hash value and second hash value are used to query the historical transaction content corresponding to the historical transaction data on the target blockchain.

Citation Information

Patent Citations

  • Data migration method, equipment and storage medium for block chain system

    CN107577427A