Blockchain business migration method, device, platform and electronic equipment
By creating a new blockchain at the end of the life cycle of the blockchain and synchronizing data, the performance degradation and intensified maintenance costs caused by blockchain data accumulation are solved, and the immutable and traceable characteristics of the blockchain are maintained.
Patent Information
- Application Number
- CN202111527917.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-14
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2041-12-14
AI Technical Summary
Blockchain data accumulation leads to performance degradation and increased maintenance costs, and directly archived data will destroy the immutable and traceable characteristics of the blockchain.
At the end of the life cycle of the first blockchain, the processing is blocked and the second blockchain is created with the last block as the Genesis block, synchronizes the smart contract and blockchain account, and replaces the first blockchain based on the second blockchain to provide services.
It effectively solves the problems of performance degradation and intensified maintenance costs caused by blockchain data accumulation, while maintaining the immutable and traceability characteristics of blockchain.
Smart Images

Figure CN114265826B_ABST
Abstract
Description
Technical Field
[0001] This document belongs to the field of information processing technology, and in particular, relates to a blockchain business migration method, device, platform and electronic equipment. Background Art
[0002] Blockchain is essentially a distributed database. It is increasingly widely used due to its characteristics of "immutability", "full traceability", "traceability", "openness and transparency" and "collective maintenance". As time goes by and the business volume increases, the data that blockchain needs to maintain will become larger and larger, which will inevitably lead to performance degradation.
[0003] Although in actual applications, only a small amount of data or time-sensitive data in the blockchain will be used, directly archiving the data in the blockchain will destroy the "traceability" and "immutability" characteristics of the blockchain. Therefore, how to solve the problems caused by the accumulation of blockchain data is a difficult problem that needs to be overcome urgently. Summary of the invention
[0004] The purpose of the embodiments of this specification is to provide a method, device, platform and electronic device for migrating blockchain business, which can migrate the blockchain business of the original blockchain to a new blockchain without destroying the characteristics of the blockchain, thereby solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc.
[0005] In a first aspect, a method for migrating a blockchain service is provided, including:
[0006] At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension;
[0007] Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0008] Based on the second blockchain, the first blockchain is replaced to provide blockchain services.
[0009] In a second aspect, a migration device for a blockchain service is provided, including:
[0010] A first blockchain suspension module, which suspends the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension;
[0011] A first blockchain creation module, which, at the end of the life cycle of the first blockchain, suspends the first blockchain, wherein the first blockchain uses the last block in the first blockchain as the genesis block, creates a second blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0012] The first blockchain service migration module replaces the first blockchain to provide blockchain services based on the second blockchain.
[0013] In a third aspect, a blockchain business platform is provided, wherein the blockchain business platform is provided with a first blockchain to provide blockchain services, and the blockchain business platform includes:
[0014] A second blockchain suspension module is configured to suspend the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension;
[0015] A second blockchain creation module, which, at the end of the life cycle of the first blockchain, blocks the first blockchain, wherein the first blockchain uses the last block in the first blockchain as the genesis block to create a second blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0016] The second blockchain service migration module replaces the first blockchain to provide blockchain services based on the second blockchain.
[0017] In a fourth aspect, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor:
[0018] At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension;
[0019] Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0020] Based on the second blockchain, the first blockchain is replaced to provide blockchain services.
[0021] In a fifth aspect, a computer-readable storage medium is provided, wherein a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
[0022] At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension;
[0023] Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0024] Based on the second blockchain, the first blockchain is replaced to provide blockchain services.
[0025] The solution of the embodiment of this specification creates a second blockchain with the last block in the first blockchain as the genesis block at the end of the life cycle of the first blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain, thereby continuing the blockchain business of the first blockchain by creating a new second blockchain, thereby effectively solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc. Since the solution does not transfer and archive the blocks in the blockchain, it will not destroy the characteristics of the blockchain such as "traceability" and "immutability". BRIEF DESCRIPTION OF THE DRAWINGS
[0026] In order to more clearly illustrate the embodiments of this specification or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of this specification. For ordinary relevant responsible persons in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0027] Figure 1 A first flowchart of a blockchain-based business migration method provided in an embodiment of this specification.
[0028] Figure 2 A second flow chart of the method for migrating blockchain services provided in the embodiments of this specification.
[0029] Figure 3 A third flow chart of the blockchain service migration method provided in the embodiments of this specification.
[0030] Figure 4 A schematic diagram of the structure of a migration device for blockchain services provided in an embodiment of this specification.
[0031] Figure 5 This is a schematic diagram of the structure of the blockchain business platform provided in the embodiments of this specification.
[0032] Figure 6This is a schematic diagram of the structure of an electronic device provided in an embodiment of this specification. DETAILED DESCRIPTION
[0033] In order 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 described clearly and completely below in conjunction with the drawings in the embodiments of this specification. Obviously, the described embodiments are only part of the embodiments of this specification, not all of the embodiments. Based on the embodiments in this specification, all other embodiments obtained by ordinary relevant responsible persons in this field without creative work should fall within the scope of protection of this specification.
[0034] As mentioned above, as time goes by and the business volume of blockchain increases, the data maintained on the chain will become larger and larger, which will inevitably lead to a series of problems such as performance degradation and increased maintenance costs. Although in actual applications, only a small amount of data or time-sensitive data in the blockchain will be used, directly archiving the data in the blockchain will destroy the "traceability" and "immutability" characteristics of the blockchain, which will lose the meaning of using the blockchain as a data storage medium.
[0035] In this context, this document aims to propose a technical solution to continue the original blockchain business by replacing the new blockchain, which can solve a series of problems caused by the accumulation of blockchain data and does not have the disadvantage of destroying the characteristics of the blockchain.
[0036] Figure 1 This is a flowchart of a blockchain-based evidence collection method according to an embodiment of this specification. Figure 1 As shown, the method may include the following steps:
[0037] S102, when the life cycle of the first blockchain ends, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension.
[0038] It should be understood that the end of the life cycle of the first blockchain described in this embodiment means that a new blockchain needs to be replaced to continue the blockchain business of the first blockchain, so it can be but is not limited to the following situations:
[0039] The performance indicators of the first blockchain do not meet the pre-set performance requirements;
[0040] The data storage volume of the first blockchain reaches a preset data storage volume threshold;
[0041] The number of blocks of the first blockchain reaches a preset block number threshold.
[0042] Here, this article does not specifically limit the judgment mechanism for the end of the life cycle of the first blockchain.
[0043] In addition, blocking the first blockchain means stopping the first blockchain from receiving client requests, thereby ensuring that the first blockchain no longer generates new blocks. In practical applications, the access rights of the first blockchain can be set to be closed to the client by initiating a blocking transaction to the first blockchain. Among them, the way to set access rights is not unique. As an exemplary introduction, the access rights of the first blockchain can be set to allow access by a specified IP address (excluding the client), or the access rights of the first blockchain can be set to provide a key for access (the key is not open to the client). S104, using the last block in the first blockchain as the genesis block, create a second blockchain, and synchronize the smart contracts and blockchain accounts in the first blockchain to the second blockchain.
[0044] It should be understood that smart contracts are computer protocols for blockchains to execute blockchain services. After synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain, the second blockchain can provide the blockchain services of the first blockchain to the original blockchain accounts of the first blockchain through smart contracts based on the transaction data in the genesis block. In addition, the second blockchain can also expand new blockchain accounts based on the genesis block and generate new blocks to record the blockchain data of the new blockchain accounts.
[0045] Specifically, if the blockchain business of the first blockchain needs to be upgraded, this step can update the smart contract in the first blockchain based on the business logic corresponding to the upgraded blockchain business; then, synchronize the updated smart contract in the first blockchain to the second blockchain.
[0046] In addition, considering that most of the inactive data in the blockchain is generally not used, this step can synchronize the blockchain accounts whose active index values in the first blockchain reach the preset active index threshold to the second blockchain.
[0047] The embodiments of this specification are described in terms of the update frequency of the blockchain data corresponding to the blockchain account in the first blockchain. It should be understood that the blockchain account generally updates the blockchain data in the following situations:
[0048] As the active initiator of blockchain business, blockchain data changes occur after completing blockchain business;
[0049] As a passive invitee of blockchain business, blockchain data changes occur after completing blockchain business.
[0050] That is to say, the update frequency of blockchain data can effectively reflect the activity of blockchain accounts. In addition, the activity index value can also be calculated based on the frequency of blockchain accounts being accessed in the first blockchain, and the text will not be repeated here one by one.
[0051] In addition, it should be understood that this step uses the last block of the first blockchain as the genesis block of the second blockchain, that is, only the transaction data of the last block of the first blockchain is imported into the second blockchain, so the data that needs to be synchronized is relatively small.
[0052] Of course, if there are special requirements, more transaction data from the first blockchain can also be imported into the second blockchain. Here, assuming that there are N blocks when the first blockchain is suspended, the N-1th block in the first blockchain can be used as the genesis block of the second blockchain, and the Nth block in the first blockchain can be used as the second block of the second blockchain; and so on, the N-2th block in the first blockchain can also be used as the genesis block of the second blockchain, and correspondingly, the N-1th block in the first blockchain can be used as the second block of the second blockchain, and the Nth block in the first blockchain can be used as the third block of the second blockchain.
[0053] It has been found in practice that only the last block of the first blockchain needs to be used as the genesis block of the second blockchain to meet the usage requirements of most scenarios. Therefore, the embodiments of this specification do not need to synchronize too much transaction data of the first blockchain to the second blockchain.
[0054] S106, based on the second blockchain, replace the first blockchain to provide blockchain services.
[0055] It should be understood that replacing the first blockchain to provide blockchain services based on the second blockchain means that when a blockchain client subsequently requests blockchain services, the second blockchain is used to process the client request. Specifically, the IP address pointed to by the interface of the blockchain service can be set to the IP address of the second blockchain, so that after receiving the client request for the blockchain service of the first blockchain, the service interface submits the client request to the second blockchain for processing.
[0056] Exemplarily, the process of providing blockchain services to the second blockchain is as follows:
[0057] In response to a target client request for initiating a blockchain service, query the second blockchain for blockchain data of a target blockchain account required to process the target client request, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; if no query hits the second blockchain, query the first blockchain for blockchain data corresponding to the target blockchain account, and after the query hits the first blockchain, process the target client request based on the blockchain data corresponding to the target blockchain account.
[0058] Among them, the above process involves the step of the second blockchain accessing the first blockchain to query blockchain data, so the second blockchain needs to have the access rights of the first blockchain. As mentioned above, in order to stop the first blockchain from receiving client requests, the access rights of the first blockchain are set to allow access by a specified IP address, or to provide a key for access. Correspondingly, if access is allowed by a specified IP address, the IP address of each node of the second blockchain needs to be dynamically maintained in the access rights of the first blockchain; if access is provided by providing a key, the key can be assigned to each node of the second blockchain.
[0059] Furthermore, since the genesis block of the second blockchain is the last block of the first blockchain, when the blockchain data requested by the target client is not found in the second blockchain, it can be determined whether the blockchain data is in the first blockchain based on the genesis block of the second blockchain. If it is determined that the blockchain data exists in the first blockchain, the target client request is submitted to the first blockchain through the second blockchain. If it is determined that the blockchain data does not exist in the first blockchain, the query failure result is directly fed back to the target client, and resources are no longer wasted on querying in the first blockchain.
[0060] In addition, if the blockchain data of the target blockchain account is queried in the first blockchain, it means that the target blockchain account was not synchronized to the second blockchain due to insufficient activity in the previous S104, but now the target blockchain account has started to use the blockchain service again. In order to avoid frequent calls to the first blockchain to query the data of the target blockchain account, the target blockchain account can be synchronized to the second blockchain.
[0061] Of course, in actual applications, it is not necessary to synchronize all smart contracts of the first blockchain to the second blockchain. For example, for the target blockchain business that no longer develops new customers, since there are fewer and fewer customers and the demand for use is not great, it is possible to choose not to synchronize the smart contract of the target blockchain business to the second blockchain. However, if the customer who previously handled the target blockchain business initiates a transaction to call the smart contract of the target blockchain business through the client, the contract code of the smart contract is queried from the first blockchain and the client's transaction is executed; at the same time, if there is a demand, such as the smart contract of the target blockchain business will be called again in the future, the smart contract of the target blockchain business can be deployed to the second blockchain, thereby reducing the number of visits to the first blockchain.
[0062] In other words, the newly generated second blockchain can continue the blockchain business of the first blockchain. Although the first blockchain stops providing blockchain services, it can serve as a data support medium for the blockchain business provided by the second blockchain in a few scenarios, so it will not affect the original blockchain business.
[0063] In addition, in order to ensure that blockchain services are not affected, this step can add client requests for blockchain services received after the first blockchain is blocked to the migration transition queue before the second blockchain replaces the first blockchain to provide blockchain services. After the second blockchain replaces the first blockchain to provide blockchain services, the client requests in the migration transition queue are processed based on the second blockchain.
[0064] It can be seen that the method of the embodiment of this specification creates a second blockchain with the last block in the first blockchain as the genesis block at the end of the life cycle of the first blockchain, and synchronizes the smart contract and blockchain account in the first blockchain to the second blockchain, thereby continuing the blockchain business of the first blockchain by creating a new second blockchain, thereby effectively solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc. Since the solution does not transfer and archive the blocks in the blockchain, it will not destroy the characteristics of the blockchain such as "traceability" and "immutability".
[0065] In actual application scenarios, as blockchain services are developed, more and more blockchains will be generated by executing blockchain service migration. For example, at the end of the life cycle of the second blockchain, the last block in the second blockchain can be used as the genesis block to create a third blockchain, and the smart contracts and blockchain accounts in the second blockchain can be synchronized to the third blockchain, thereby replacing the second blockchain to provide blockchain services based on the third blockchain. For another example, at the end of the life cycle of the third blockchain, the last block in the third blockchain can be used as the genesis block to create a fourth blockchain, and the smart contracts and blockchain accounts in the third blockchain can be synchronized to the fourth blockchain, thereby replacing the third blockchain to provide blockchain services based on the fourth blockchain...
[0066] Based on the above method, the newly generated blockchain can retain relatively recent blockchain data of active users. Figure 2 As shown, the first blockchain has three blockchain accounts, Alice, Bob, and Tom, when it stops providing blockchain services. If Tom no longer uses blockchain services for a long time, the migrated second blockchain will only synchronize the two blockchain accounts of Alice and Bob. In the subsequent life cycle of the second blockchain, a new blockchain account Mark can be introduced. Of course, if Tom resumes using blockchain services, the second blockchain will first provide blockchain services to Tom based on the latest blockchain data retrieved from the first blockchain, and configure Tom's blockchain account in the second blockchain. When the blockchain services are completed, the second blockchain generates the latest block recording Tom's blockchain data. Similarly, the second blockchain has three blockchain accounts, Alice, Bob, and Mark, when it stops providing blockchain services. If Bob no longer uses blockchain services for a long time, after migrating the blockchain services to the third blockchain, the third blockchain will only synchronize the two blockchain accounts of Alice and Mark.
[0067] Further references Figure 3, take the blockchain account Alice that exists in the first blockchain, the second blockchain, and the third blockchain as an example, in descending order of time, Alice has made three transactions in the life cycle of the first blockchain, and the corresponding transaction data are tx1, tx2, and tx3. Assuming that the latest transaction data tx3 does not belong to the last block of the first blockchain, tx1, tx2, and tx3 will not be synchronized to the second blockchain after the life cycle of the first blockchain ends. Similarly, Alice has made two transactions in the life cycle of the second blockchain, and the corresponding transaction data are tx4 and tx5. Among them, the latest tx5 belongs to the last block of the second blockchain, then only tx5 will be synchronized to the third blockchain after the life cycle of the second blockchain ends. Obviously. Based on this mechanism, only time-sensitive transaction data will be synchronized to the latest block with the migration of blockchain business, thereby ensuring the utilization of data. At the same time, the original outdated transaction data and a small number of time-sensitive transaction data that have not been synchronized can still be traced based on the previous blockchain. Although the previous blockchain no longer provides blockchain services, it still has the characteristic of "traceability" and can also provide data support for the subsequent blockchain to process blockchain business.
[0068] In addition, corresponding to Figure 4 The method shown, the embodiment of the present invention also provides a migration device for blockchain business. Figure 4 4 is a schematic diagram of the structure of a migration device 400 according to an embodiment of the present invention, comprising:
[0069] The first blockchain suspension module 410 suspends the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension.
[0070] The first blockchain creation module 420 suspends the first blockchain at the end of its life cycle, wherein the first blockchain uses the last block in the first blockchain as the genesis block to create a second blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain.
[0071] The first blockchain service migration module 430 replaces the first blockchain to provide blockchain services based on the second blockchain.
[0072] At the end of the life cycle of the first blockchain, the device of the embodiment of this specification creates a second blockchain with the last block in the first blockchain as the genesis block, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain, thereby continuing the blockchain business of the first blockchain by creating a new second blockchain, thereby effectively solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc. Since the solution does not transfer and archive the blocks in the blockchain, it will not destroy the characteristics of the blockchain such as "traceability" and "immutability".
[0073] Optionally, the first blockchain business migration module 430 is specifically used to: in response to a target client request initiating the blockchain business, query the blockchain data of the target blockchain account required to process the target client request in the second blockchain, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; if no query hits in the second blockchain, query the blockchain data corresponding to the target blockchain account in the first blockchain, and after the query hits in the first blockchain, process the target client request based on the blockchain data corresponding to the target blockchain account.
[0074] Optionally, the first blockchain creation module 420 specifically synchronizes the blockchain accounts whose activity index values in the first blockchain reach a preset activity index threshold to the second blockchain. The activity index value of the blockchain account in the first blockchain is determined based on the update frequency of the blockchain data corresponding to the blockchain account in the first blockchain.
[0075] In addition, if the blockchain data corresponding to the target blockchain account is not queried and hit in the second blockchain, and the target blockchain account is not synchronized to the second blockchain, the first blockchain creation module 420 can also synchronize the target blockchain account to the second blockchain when querying and hitting the blockchain data corresponding to the target blockchain account in the first blockchain.
[0076] Optionally, the first blockchain creation module 420 is specifically used to: if the blockchain business of the first blockchain needs to be upgraded, update the smart contract in the first blockchain based on the business logic corresponding to the upgraded blockchain business; then, synchronize the updated smart contract in the first blockchain to the second blockchain.
[0077] Optionally, the first blockchain service migration module 430 may also add client requests for blockchain services received after the first blockchain is blocked to a migration transition queue before replacing the first blockchain to provide blockchain services based on the second blockchain; and after replacing the first blockchain to provide blockchain services based on the second blockchain, process client requests in the migration transition queue based on the second blockchain.
[0078] Optionally, the first blockchain suspension module 410 specifically sends a suspension transaction to the first blockchain to set the access permission of the first blockchain to allow access by a specified IP address or by providing a key, so that the first blockchain refuses to receive client requests.
[0079] Optionally, some smart contracts in the first blockchain are synchronized to the second blockchain, and the target client request is a transaction to call the target smart contract. If the second blockchain does not deploy the target smart contract, the first blockchain business migration module 43 queries the contract code of the target smart contract in the first blockchain to process the transaction; and synchronizes the target smart contract in the first blockchain to the second blockchain.
[0080] Obviously, the migration device in the embodiment of this specification can be used as the above Figure 1 The execution subject of the method shown in FIG. Figure 1 The steps and functions implemented are not described in detail in this article because the principles are the same.
[0081] In addition, corresponding to Figure 1 As shown in the method, an embodiment of the present invention also provides a blockchain business platform, which is provided with a first blockchain to provide blockchain services. Figure 5 : is a schematic diagram of the structure of a forensics device 500 according to an embodiment of the present invention, comprising:
[0082] The second blockchain suspension module 510 suspends the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension;
[0083] The second blockchain creation module 520 is configured to suspend the first blockchain at the end of its life cycle, wherein the first blockchain uses the last block in the first blockchain as the genesis block to create a second blockchain, and synchronize the smart contracts and blockchain accounts in the first blockchain to the second blockchain;
[0084] The second blockchain service migration module 530 replaces the first blockchain to provide blockchain services based on the second blockchain.
[0085] At the end of the life cycle of the first blockchain, the blockchain business platform of the embodiment of this specification creates a second blockchain with the last block in the first blockchain as the genesis block, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain, thereby continuing the blockchain business of the first blockchain by creating a new second blockchain, thereby effectively solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc. Since the solution does not transfer and archive the blocks in the blockchain, it will not destroy the characteristics of the blockchain such as "traceability" and "immutability".
[0086] Optionally, the second blockchain business migration module 530 is specifically used to: in response to a target client request initiating the blockchain business, query the blockchain data of the target blockchain account required to process the target client request in the second blockchain, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; if no query hits in the second blockchain, query the blockchain data corresponding to the target blockchain account in the first blockchain, and after the query hits in the first blockchain, process the target client request based on the blockchain data corresponding to the target blockchain account.
[0087] Optionally, the second blockchain creation module 520 specifically synchronizes the blockchain accounts whose activity index values in the first blockchain reach a preset activity index threshold to the second blockchain. The activity index value of the blockchain account in the first blockchain is determined based on the update frequency of the blockchain data corresponding to the blockchain account in the first blockchain.
[0088] In addition, if the blockchain data corresponding to the target blockchain account is not queried and hit in the second blockchain, and the target blockchain account is not synchronized to the second blockchain, the second blockchain creation module 520 can also synchronize the target blockchain account to the second blockchain when querying and hitting the blockchain data corresponding to the target blockchain account in the first blockchain.
[0089] Optionally, the second blockchain creation module 520 is specifically used to: if the blockchain business of the first blockchain needs to be upgraded, update the smart contract in the first blockchain based on the business logic corresponding to the upgraded blockchain business; then, synchronize the updated smart contract in the first blockchain to the second blockchain.
[0090] Optionally, the second blockchain service migration module 530 may also add client requests for blockchain services received after the first blockchain is blocked to a migration transition queue before replacing the first blockchain to provide blockchain services based on the second blockchain; and after replacing the first blockchain to provide blockchain services based on the second blockchain, process client requests in the migration transition queue based on the second blockchain.
[0091] Obviously, the blockchain business platform of the embodiment of this specification can be used as the above Figure 1 The execution subject of the method shown in FIG. Figure 1 The steps and functions implemented are not described in detail in this article because the principles are the same.
[0092] Figure 6 This is a schematic diagram of the structure of an electronic device according to an embodiment of this specification. Figure 6 At the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. The memory may include a memory, such as a high-speed random access memory (RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk storage. Of course, the electronic device may also include hardware required for other services.
[0093] The processor, network interface and memory can be interconnected through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 6 Only one bidirectional arrow is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0094] The memory is used to store the program. Specifically, the program may include a program code, and the program code includes a computer operation instruction. The memory may include a memory and a non-volatile memory, and provides instructions and data to the processor.
[0095] The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a migration device for blockchain business at the logical level. The processor executes the program stored in the memory and is specifically used to perform the following operations:
[0096] At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension.
[0097] The second blockchain is created using the last block in the first blockchain as the genesis block, and the smart contracts and blockchain accounts in the first blockchain are synchronized to the second blockchain.
[0098] Based on the second blockchain, the first blockchain is replaced to provide blockchain services.
[0099] At the end of the life cycle of the first blockchain, the electronic device of the embodiment of this specification creates a second blockchain with the last block in the first blockchain as the genesis block, and synchronizes the smart contract and blockchain account in the first blockchain to the second blockchain, thereby continuing the blockchain business of the first blockchain by creating a new second blockchain, thereby effectively solving a series of problems caused by the accumulation of blockchain data, such as performance degradation, increased maintenance costs, etc. Since the solution does not transfer and archive the blocks in the blockchain, it will not destroy the characteristics of the blockchain such as "traceability" and "immutability".
[0100] The above is as in this manual Figure 1The evidence collection method disclosed in the illustrated embodiment can be applied to a processor or implemented by a processor. The processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in the processor or an instruction in the form of software. The above processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be implemented or executed. The general-purpose processor can be a microprocessor or the processor can also be any conventional processor, etc. The steps of the method disclosed in the embodiments of this specification can be directly embodied as a hardware decoding processor for execution, or a combination of hardware and software modules in the decoding processor for execution. The software module can be located in a storage medium mature in the art such as a random access memory, a flash memory, a read-only memory, a programmable read-only memory, or an electrically erasable programmable memory, a register, etc. The storage medium is located in the memory, and the processor reads the information in the memory and completes the steps of the above method in combination with its hardware.
[0101] It should be understood that the electronic device of the embodiment of this specification can implement the above-mentioned evidence collection method in Figure 1 The functions of the embodiments shown in the figure are the same and will not be described in detail herein.
[0102] Of course, in addition to software implementation, the electronic device of this specification does not exclude other implementation methods, such as logic devices or a combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, but can also be hardware or logic devices.
[0103] In addition, an embodiment of the present specification also proposes a computer-readable storage medium, which stores one or more programs, and the one or more programs include instructions.
[0104] When the instruction is executed by a portable electronic device including multiple application programs, the portable electronic device can execute Figure 1 The method of the embodiment shown is specifically used to perform the following steps:
[0105] At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension.
[0106] The second blockchain is created using the last block in the first blockchain as the genesis block, and the smart contracts and blockchain accounts in the first blockchain are synchronized to the second blockchain.
[0107] Based on the second blockchain, the first blockchain is replaced to provide blockchain services.
[0108] Relevant responsible persons in this field should understand that the embodiments of this specification can be provided as methods, systems or computer program products. Therefore, this specification can take the form of a complete hardware embodiment, a complete software embodiment or an embodiment combining software and hardware. Moreover, this specification can take the form of a computer program product implemented 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.
[0109] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0110] The above are only embodiments of this specification and are not intended to limit this specification. For relevant persons in charge in this field, this specification may have various changes and variations. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of the claims of this specification. In addition, all other embodiments obtained by ordinary relevant persons in charge in this field without making creative work should fall within the scope of protection of this document.
Claims
1. A method for migrating blockchain services, comprising: At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension; Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain; Based on the second blockchain, replacing the first blockchain to provide blockchain services; In response to a target client request for initiating the blockchain service, querying in the second blockchain the blockchain data of a target blockchain account required to process the target client request, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; If there is no query hit in the second blockchain, the blockchain data corresponding to the target blockchain account is queried in the first blockchain, and after the query hit is found in the first blockchain, the target client request is processed based on the blockchain data corresponding to the target blockchain account.
2. The method according to claim 1, Synchronizing the blockchain account in the first blockchain to the second blockchain includes: The blockchain accounts whose activity index values in the first blockchain reach a preset activity index threshold are synchronized to the second blockchain.
3. The method according to claim 2, The activity index value of the blockchain account in the first blockchain is determined based on the update frequency of the blockchain data corresponding to the blockchain account in the first blockchain.
4. The method according to claim 3, further comprising: If the blockchain data corresponding to the target blockchain account is not queried and hit in the second blockchain, and the target blockchain account is not synchronized to the second blockchain, then when the blockchain data corresponding to the target blockchain account is queried and hit in the first blockchain, the target blockchain account is synchronized to the second blockchain.
5. The method according to claim 1, The part of the smart contracts in the first blockchain is synchronized to the second blockchain, the target client request is a transaction to call the target smart contract, and the method further includes: If the target smart contract is not deployed in the second blockchain, querying the contract code of the target smart contract in the first blockchain to execute the transaction; as well as, Synchronize the target smart contract to the second blockchain.
6. The method according to claim 1, Suspending the first blockchain includes: A suspension transaction is sent to the first blockchain to set the access permission of the first blockchain to allow access by a specified IP address or by providing a key, so that the first blockchain refuses to receive client requests.
7. The method according to claim 1, further comprising: Synchronizing the smart contract in the first blockchain to the second blockchain includes: If the blockchain service of the first blockchain needs to be upgraded, the smart contract in the first blockchain is updated based on the business logic corresponding to the upgraded blockchain service; Synchronize the updated smart contract in the first blockchain to the second blockchain.
8. The method according to claim 1, further comprising: Before replacing the first blockchain with the blockchain service based on the second blockchain, adding the client requests for the blockchain service received after the first blockchain is suspended to the migration transition queue; After the first blockchain is replaced to provide blockchain services based on the second blockchain, client requests in the migration transition queue are processed based on the second blockchain.
9. The method according to claim 1, The end of the life cycle of the first blockchain refers to at least one of the following situations: The performance indicators of the first blockchain do not meet the preset performance requirements; The data storage capacity of the first blockchain reaches a preset data storage capacity threshold; The number of blocks of the first blockchain reaches a preset block number threshold.
10. A blockchain service migration device, comprising: A first blockchain suspension module, which suspends the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension; A first blockchain creation module, which, at the end of the life cycle of the first blockchain, suspends the first blockchain, wherein the first blockchain uses the last block in the first blockchain as the genesis block, creates a second blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain; The first blockchain service migration module replaces the first blockchain to provide blockchain services based on the second blockchain.
11. A blockchain business platform, wherein the blockchain business platform is provided with a first blockchain to provide blockchain services, and the blockchain business platform comprises: A second blockchain suspension module is configured to suspend the first blockchain at the end of its life cycle, wherein the first blockchain stops providing blockchain services after suspension; A second blockchain creation module, which, at the end of the life cycle of the first blockchain, blocks the first blockchain, wherein the first blockchain uses the last block in the first blockchain as the genesis block to create a second blockchain, and synchronizes the smart contracts and blockchain accounts in the first blockchain to the second blockchain; The second blockchain service migration module replaces the first blockchain to provide blockchain services based on the second blockchain, including: in response to a target client request initiating the blockchain service, querying the second blockchain for blockchain data of a target blockchain account required to process the target client request, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; if no query hits the second blockchain, querying the first blockchain for blockchain data corresponding to the target blockchain account, and after the query hits the first blockchain, processing the target client request based on the blockchain data corresponding to the target blockchain account.
12. An electronic device comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the computer program is executed by the processor: At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein the first blockchain stops providing blockchain services after the suspension; Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain; Based on the second blockchain, replacing the first blockchain to provide blockchain services; In response to a target client request for initiating the blockchain service, querying in the second blockchain the blockchain data of a target blockchain account required to process the target client request, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; If there is no query hit in the second blockchain, the blockchain data corresponding to the target blockchain account is queried in the first blockchain, and after the query hit is found in the first blockchain, the target client request is processed based on the blockchain data corresponding to the target blockchain account.
13. A computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the following steps: At the end of the life cycle of the first blockchain, the first blockchain is suspended, wherein: The first blockchain stops providing blockchain services after being blocked; Using the last block in the first blockchain as the genesis block, creating a second blockchain, and synchronizing the smart contracts and blockchain accounts in the first blockchain to the second blockchain; Based on the second blockchain, replacing the first blockchain to provide blockchain services; In response to a target client request for initiating the blockchain service, querying in the second blockchain the blockchain data of a target blockchain account required to process the target client request, wherein the target client request carries an identifier of the target blockchain account, and the target blockchain account is a blockchain account in the first blockchain; If there is no query hit in the second blockchain, the blockchain data corresponding to the target blockchain account is queried in the first blockchain, and after the query hit is found in the first blockchain, the target client request is processed based on the blockchain data corresponding to the target blockchain account.
Citation Information
Patent Citations
Blockchain management method, device, electronic equipment and storage medium
CN110517041A
Data processing method in blockchain system and related equipment
CN112291376A