Blockchain new node online processing method and device, equipment and storage medium

By synchronizing all blocks on the blockchain to the offline repository of the new node and constructing online data, the problem of the new node being unable to participate in consensus and business in the early stages of its launch is solved, enabling the new node to participate in consensus and business upon launch and reducing the occupation of existing node resources.

CN114996357BActive Publication Date: 2026-02-06ANHUI IFLYTEK INTELLIGENT SYST
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210702940.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-06-21
Publication Date
2026-02-06
Estimated Expiration
2042-06-21

AI Technical Summary

Technical Problem

New nodes need to synchronize blocks from other nodes on the blockchain in the early stages of their launch, which prevents them from participating in consensus and business operations, and also consumes online node resources.

Method used

All blocks on the blockchain are synchronized to the offline repository of the new node. Online data is constructed based on the offline repository, and the new node and the online repository are deployed together on the blockchain, so that the new node can directly load the online data after startup.

Benefits of technology

New nodes can participate in consensus and business operations from the initial stage of going online, avoiding synchronization from online nodes and reducing the occupation of existing node resources.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114996357B_ABST
    Figure CN114996357B_ABST
Patent Text Reader

Abstract

The application provides an online processing method and device of a new node of a blockchain, equipment and a storage medium. The online processing method of the new node of the blockchain comprises the following steps: synchronizing all blocks on the blockchain to an offline storage library of the new node; constructing online data of the new node based on the data in the offline storage library of the new node, and storing the online data of the new node to an online storage library of the new node; and deploying the new node and the online storage library of the new node to the blockchain. The online processing method of the new node of the blockchain provided by the application can construct the data of the new node based on the data in the offline storage library without affecting the existing nodes on the blockchain, the new node directly loads the constructed data when the new node is online, and the synchronization from the online node is avoided, so that the new node can participate in consensus and business in the initial stage of online.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blockchains, and in particular to a method and device for online processing of a new node of a blockchain, an apparatus, and a storage medium. BACKGROUND

[0002] With the expansion of blockchain business, new participants will continue to join, that is, new nodes will continue to be online on the blockchain. At present, the new node needs to synchronize blocks from other nodes on the blockchain at the initial stage of online because it has no historical data, that is, existing blocks on the blockchain.

[0003] When the new node synchronizes blocks from other nodes on the blockchain, it will connect to other nodes on the blockchain, download blocks from other nodes, and thus level up the block height to other nodes. However, the new node cannot participate in consensus and business at the initial stage of online because it needs to level up the block height to other nodes. SUMMARY

[0004] Therefore, the present application provides a method and device for online processing of a new node of a blockchain, an apparatus, and a storage medium to solve the problem that the new node cannot participate in consensus and business at the initial stage of online because it needs to synchronize blocks from other nodes. The technical solution is as follows:

[0005] A method for online processing of a new node of a blockchain, comprising:

[0006] synchronizing all blocks on the blockchain to an offline repository of the new node;

[0007] constructing online data of the new node based on data in the offline repository of the new node, and storing the online data of the new node to an online repository of the new node;

[0008] deploying the new node and the online repository of the new node together on the blockchain, so that the new node directly loads data in the online repository after starting.

[0009] Optionally, the step of synchronizing all blocks on the blockchain to an offline repository of the new node comprises:

[0010] polling online nodes in a configured online node list:

[0011] reading the block height of the online repository of the currently polled online node as the current online block height;

[0012] In a case that the current online block height is greater than the current offline block height: if the current block height difference is less than a preset block height difference threshold, downloading the differential blocks from the online nodes polled in the current round; if the current block height difference is greater than or equal to the block height difference threshold, downloading the differential blocks from the plurality of online nodes in the online node list; wherein the current offline block height is the current block height of the offline repository, and the current block height difference is the difference between the current online block height and the current offline block height;

[0013] writing the downloaded blocks into the offline repository of the new node.

[0014] Optionally, the writing of the downloaded blocks into the offline repository of the new node comprises:

[0015] for each downloaded block:

[0016] parsing the block to obtain a block parsing result of the block, the block parsing result comprising chain configuration, contract information, block body data, block header data and contract business data;

[0017] writing the block parsing result of the block as an offline data unit into the offline repository of the new node.

[0018] Optionally, the online processing method of the new node of the blockchain further comprises:

[0019] for each block parsing result, after successfully writing the block parsing result into the offline repository of the new node, writing, in the offline repository of the new node, a write execution record for the block parsing result, the write execution record indicating that the block parsing result is successfully written;

[0020] for each successfully written block parsing result, performing a verification on the successfully written block parsing result, and after the verification passes, writing, in the offline repository of the new node, a verification execution record for the successfully written block parsing result, the verification execution record indicating that the successfully written block parsing result passes the verification.

[0021] Optionally, the constructing of the online data of the new node based on the data in the offline repository of the new node and the storing of the online data of the new node into the online repository of the new node comprises:

[0022] reconstructing each offline data unit written in the offline repository of the new node into a block with a complete block structure to obtain a plurality of reconstructed blocks, wherein an offline data unit is a block parsing result of a downloaded block, and a reconstructed block contains a block with chain configuration, contract information, block body data, block header data and contract business data;

[0023] performing a verification on the plurality of reconstructed blocks;

[0024] For each reconstructed block that passes verification, an online data unit is constructed based on the reconstructed block, and the online data unit is written into the online repository of the new node. The online data unit contains contract business data but does not contain block body data.

[0025] Optionally, the verification of the plurality of reconstructed blocks includes:

[0026] Offline verification is performed on the aforementioned reconstructed blocks;

[0027] Based on the block information of online nodes, online verification is performed on reconstructed blocks that have passed offline verification.

[0028] Optionally, reconstructing each offline data unit written to the offline repository of the new node into a block with a complete block structure includes:

[0029] For each check range determined based on the set checkpoints, the blocks within the check range are reconstructed based on the offline data units within that check range to obtain the reconstructed blocks within that check range;

[0030] The verification of the plurality of reconstructed blocks includes:

[0031] For each check range determined based on the set checkpoints, perform offline verification on the reconstructed blocks within that check range;

[0032] After the offline verification of the reconstructed blocks within the inspection range passes, the block hash is calculated from the first reconstructed block to the last reconstructed block within the inspection range to obtain the block hash of the last reconstructed block within the inspection range.

[0033] The online verification result of the reconstructed blocks within the inspection scope is determined by comparing the block hash of the last reconstructed block within the inspection scope with the block hash of the same block on any online node on the blockchain.

[0034] Optionally, the method for processing the online connection of new blockchain nodes further includes:

[0035] After the new node comes online, receive data query requests from the new node;

[0036] In the offline repository of the new node, query the data requested by the data query request;

[0037] The retrieved data is then fed back to the new node.

[0038] Optionally, the offline repository also stores mapping relationship information, which includes the relationship between transaction hash and block number, the relationship between block body and block body hash and block number, and the relationship between block hash and block number.

[0039] The data requested by the data query request is queried in the offline repository of the new node, including:

[0040] If the query type contained in the data query request is a transaction, the transaction data requested by the data query request is queried in the offline repository of the new node according to the transaction hash contained in the data query request and the mapping relationship information, wherein the transaction data is non-contract business data.

[0041] If the query type contained in the data query request is a block, the block body requested by the data query request is found according to the block number or block hash contained in the data query request and the mapping relationship information.

[0042] An online processing device of a new node of a block chain, comprising: a block synchronization module, an online data construction module, an online data storage module, and a new node and online repository deployment module.

[0043] The block synchronization module is configured to synchronize all blocks on the block chain to the offline repository of the new node.

[0044] The online data construction module is configured to construct the online data of the new node based on the data in the offline repository of the new node.

[0045] The online data storage module is configured to store the online data of the new node to the online repository of the new node.

[0046] The new node and online repository deployment module is configured to deploy the new node and the online repository of the new node together on the block chain, so that the new node directly loads the data in the online repository after starting.

[0047] An online processing device of a new node of a block chain, comprising: a memory and a processor.

[0048] The memory is configured to store a program.

[0049] The processor is configured to execute the program to implement each step of the online processing method of the new node of the block chain.

[0050] A readable storage medium, wherein a computer program is stored on the readable storage medium, and the computer program is executed by a processor to implement each step of the online processing method of the new node of the blockchain.

[0051] The online processing method, device, equipment and storage medium of the new node of the blockchain provided by the application first synchronize all blocks on the blockchain to the offline storage of the new node, then construct online data of the new node based on data in the offline storage of the new node, store the online data of the new node to the online storage of the new node, and finally deploy the new node and the online storage of the new node to the blockchain. The online processing method of the new node of the blockchain provided by the application can construct the online data of the new node based on the data in the offline storage and store the online data to the online storage of the new node without affecting the existing nodes on the blockchain. The new node can directly load the constructed online data from the online storage when it is online, avoiding synchronization from the online node, which enables the new node to participate in consensus and business at the initial stage of being online. BRIEF DESCRIPTION OF DRAWINGS

[0052] In order to more clearly illustrate the technical solutions in the embodiments of the application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or the prior art description. Obviously, the drawings in the following description only constitute the embodiments of the application, and for those skilled in the art, other drawings can be obtained without creative labor based on the provided drawings.

[0053] Figure 1 The flowchart of the online processing method of the new node of the blockchain provided by the embodiment of the application;

[0054] Figure 2 The schematic diagram of the processing flow example of the online processing method of the new node of the blockchain provided by the embodiment of the application;

[0055] Figure 3 The flowchart of synchronizing all blocks on the blockchain to the offline storage of the new node provided by the embodiment of the application;

[0056] Figure 4 The flowchart of constructing online data of the new node based on data in the offline storage of the new node and storing the online data of the new node to the online storage of the new node provided by the embodiment of the application;

[0057] Figure 5 The schematic diagram of another processing flow example of the online processing method of the new node of the blockchain provided by the embodiment of the application;

[0058] Figure 6 The structural schematic diagram of the online processing device of the new node of the blockchain provided by the embodiment of the application;

[0059] Figure 7 A structural schematic diagram of an online processing device of a new node of a blockchain provided by an embodiment of the present application is shown in FIG. 1. DETAILED DESCRIPTION

[0060] The technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings of the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the scope of protection of the present application.

[0061] In the existing online scheme of a new node of a blockchain, the new node synchronizes historical data from other online nodes of the blockchain in the initial stage of online, during which the new node cannot participate in consensus and business, and the new node synchronizes a large amount of historical data from other online nodes, which will occupy a large amount of network bandwidth, computing resources and disk resources of other online nodes for a certain period of time, which will cause the processing capacity of the existing online nodes to decrease. In view of the defects of the existing online scheme of a new node of a blockchain, the present inventor has conducted research, and finally proposes an online processing method of a new node of a blockchain through continuous research, which perfectly overcomes the defects of the existing online scheme of a new node of a blockchain.

[0062] The online processing method of a new node of a blockchain provided by the present application can be applied to an electronic device with data processing capacity. The electronic device can be a terminal used by a user side, such as a smart phone, a PC, a notebook computer, a tablet computer, a palm computer, etc. The electronic device can also be a server. The server can be a single server, a server cluster composed of multiple servers, or a cloud computing server center. The server can include a processor, a memory, a network interface, etc.

[0063] The terminal or server described above can be processed online according to the online processing method of a new node of a blockchain provided by the present application. Those skilled in the art should understand that the terminal and server described above are only examples. Other existing or future terminals or servers that can be applicable to the present application should also be included in the protection scope of the present application and are included herein by reference.

[0064] Next, the online processing method of a new node of a blockchain provided by the present application will be introduced through the following embodiments.

[0065] Please refer to FIG. 1, which shows a flowchart of the online processing method of a new node of a blockchain provided by an embodiment of the present application. The method can include: Figure 1

[0066] ​Step S101: synchronize all blocks on the blockchain to the offline repository of the new node.

[0067] It should be noted that the blockchain has a plurality of nodes, each node has an online repository, and the online repository of each node stores all blocks on the blockchain. Since the nodes on the blockchain perform consensus, the data in the online repository of each node is the same.

[0068] Synchronizing all blocks on the blockchain to the offline repository of the new node means downloading all blocks from the online nodes on the blockchain, and then storing the downloaded blocks in the offline repository.

[0069] Step S102: based on the data in the offline repository of the new node, construct the online data of the new node, and store the online data of the new node in the online repository of the new node.

[0070] The embodiment is not to synchronize blocks from other nodes on the blockchain after the new node is online, but to synchronize all blocks on the blockchain to the offline repository before the new node is online, and then to construct the online data of the new node based on the data in the offline repository, that is, to pre-construct the online data of the new node.

[0071] Step S103: deploy the new node and the online repository of the new node to the blockchain, so that the new node directly loads the data in the online repository after starting.

[0072] The new node loads the data in the online repository immediately when starting, without the need to synchronize data from other nodes on the blockchain.

[0073] For example, as shown in Figure 2 The nodes on the blockchain include node A, node B and node C, each node has an online repository, and a new node D is pre-connected. First, synchronize all blocks from the nodes on the blockchain to the offline repository, then construct the online data of the new node D based on the data in the offline repository, and write the constructed online data to the online repository of the new node D, finally, deploy the new node D and the online repository of the new node D to the blockchain, and the new node D directly loads the data in the online repository of the new node D after starting, without the need to synchronize data from other nodes on the blockchain.

[0074] The method for online processing of a new node of a blockchain provided by the embodiment of the present application first synchronizes all blocks on the blockchain to the offline repository of the new node, then constructs online data of the new node based on the data in the offline repository of the new node, and stores the online data of the new node to the online repository of the new node, and finally deploys the new node and the online repository of the new node to the blockchain. The method for online processing of a new node of a blockchain provided by the embodiment of the present application can construct the online data of the new node based on the data in the offline repository and store the online data to the online repository without affecting the existing nodes on the blockchain, so that the new node can directly load the constructed online data from the online repository when it is online, avoiding synchronization from the online node, which enables the new node to participate in consensus and business at the initial stage of being online.

[0075] In another embodiment of the present application, the specific implementation process of "step S101: synchronizing all blocks on the blockchain to the offline repository of the new node" in the above embodiment is introduced.

[0076] Please refer to Figure 3 , which shows a flowchart of synchronizing all blocks on the blockchain to the offline repository of the new node, which can include:

[0077] Step S301: polling the online nodes in the configured online node list, reading the block height of the online repository of the current polled online node as the current online block height.

[0078] Among them, the configured online node list can include all online nodes on the blockchain, or can include part of the online nodes on the blockchain, and the online nodes in the online node list can be configured according to specific application scenarios.

[0079] It should be noted that each polling needs to select an online node from the configured online node list as the online node polled this time. For the selection of the online node, the present embodiment provides the following two optional selection strategies: one is a random selection strategy, and the other is a minimum load selection strategy.

[0080] Among them, the random selection strategy means randomly selecting an online node from the candidate online nodes in the online node list, and the minimum load selection strategy means selecting the online node with the minimum load from the candidate online nodes in the online node list. It should be noted that when the minimum load selection strategy is used to select the online node, if there are multiple online nodes with the minimum load, one online node can be randomly selected from the multiple online nodes with the minimum load.

[0081] Step S302a: if the current online block height is greater than the current offline block height, and the difference between the current online block height and the current offline block height is less than the preset block height difference threshold, then downloading the differential block from the current polled online node.

[0082] wherein the current offline block height refers to the current block height of the offline repository.

[0083] For example, the preset block height difference threshold is 10, the current online block height is greater than the current offline block height, and the difference between the current online block height and the current offline block height is 9. Since 9 is less than the preset block height difference threshold 10, 9 difference blocks are directly downloaded from the online nodes polled at the current time.

[0084] Step S302b: If the current online block height is greater than the current offline block height, and the difference between the current online block height and the current offline block height is greater than or equal to the preset block height difference threshold, difference blocks are downloaded from the plurality of online nodes in the online node list.

[0085] When the current online block height is greater than the current offline block height, and the difference between the current online block height and the current offline block height is greater than or equal to the preset block height difference threshold, in order to speed up the download speed, the difference blocks can be downloaded from the plurality of online nodes in the online node list based on a plurality of threads. Specifically, when the difference blocks are downloaded from the plurality of online nodes, different ranges of difference blocks can be downloaded from each online node.

[0086] For example, the preset block height difference threshold is 10, the current online block height is greater than the current offline block height, and the difference between the current online block height and the current offline block height is 100. Since 100 is greater than the preset block height difference threshold 10, 100 difference blocks can be downloaded from the plurality of online nodes in the online node list based on a plurality of threads. Specifically, different ranges of difference blocks are downloaded from each online node. For example, the 100 difference blocks are the 101st to 200th blocks, then thread a can be used to download the 101st to 120th blocks from online node A, thread b can be used to download the 121st to 140th blocks from online node B, thread c can be used to download the 141st to 160th blocks from online node C, thread d can be used to download the 161st to 180th blocks from online node D, and thread e can be used to download the 181st to 200th blocks from online node E.

[0087] It should be noted that if the current online block height is equal to the current offline block height, it means that there are no difference blocks between the online repository of the online node polled at the current time and the offline repository of the new node, and this time of polling does not need to download difference blocks.

[0088] Under normal circumstances, the current online block height is greater than or equal to the current offline block height. However, sometimes the current online block height can be less than the current offline block height. If this happens, it means that the online node polled at the current time is abnormal, and at this time, other nodes are selected to continue this time of polling.

[0089] Step S303: Write the downloaded block into the offline repository of the new node.

[0090] Generally, the offline repository is different from the online repository, for example, the online repository generally adopts a key-value pair database, while the offline repository generally adopts a relational database, which leads to that the downloaded block cannot be directly written into the offline repository of the new node, but first needs to be parsed, and after obtaining the block parsing result, the block parsing result is written into the offline repository of the new node.

[0091] Specifically, the process of writing the downloaded block into the offline repository of the new node can include: for each downloaded block, first parsing the block to obtain the block parsing result of the block, and then writing the block parsing result of the block into the offline repository of the new node in units of blocks, that is, writing the block parsing result of the block as an offline data unit into the offline repository of the new node. Wherein, the block parsing result includes chain configuration, contract information, block body data, block header data and contract business data, that is, a block is parsed into five parts of chain configuration, contract information, block body data, block header data and contract business data.

[0092] The process of synchronizing the offline repository of the new node to the blocks by polling the online nodes is described below with a specific example. Assume that the online node list configured includes online node A, online node B, online node C and online node D on the blockchain, and the minimum load selection strategy is adopted when polling: when polling for the first time, online node A, online node B, online node C and online node D are selected as candidate online nodes, and the online node with the minimum load is selected as the online node polled for the first time from the four online nodes, assuming that online node C has the minimum load, online node C is selected as the online node polled for the first time, the current online block height of online node C is obtained, assuming that the current online block height of online node C is greater than the current offline block height, and the current online block height of online node C is greater than the preset block height difference threshold value, the difference blocks are downloaded from online node A and online node C, and the downloaded difference blocks are written in sequence to the offline repository of the new node (each block is parsed, and the block parsing result of each block is written to the offline repository in units of blocks); when polling for the second time, since online node C has been polled and blocks have been downloaded from online node A, online node B and online node D are selected as candidate online nodes, and the online node with the minimum load is selected as the online node polled for the second time from online node B and online node D, assuming that online node B has the minimum load, online node B is selected as the online node polled for the second time, the current online block height of online node B is obtained, assuming that the current online block height of online node B is greater than the current offline block height, and the current online block height of online node B is greater than the preset block height difference threshold value, the difference blocks are downloaded from online node B and online node D, and the downloaded difference blocks are written in sequence to the offline repository of the new node; when polling for the third time, since blocks have been downloaded from online node A, online node B, online node C and online node D, online node A, online node B, online node C and online node D can be selected as candidate online nodes again, and the online node with the minimum load is selected as the online node polled for the third time from the four online nodes, and so on, until the end polling condition is met.

[0093] Preferably, for each block parsing result, after the block parsing result is successfully written into the offline repository of the new node, a write execution record indicating that the block parsing result is successfully written can be written for the block parsing result in the offline repository of the new node, and the write execution record can include the block number. It should be noted that the successful writing of the block parsing result of a block into the offline repository of the new node indicates that the block is successfully parsed (i.e., the correct parsing result is obtained), and the obtained block parsing result is successfully written into the offline repository of the new node. If a block is not successfully parsed, or although successfully parsed, the block parsing result is not successfully written into the offline repository of the new node, the current polling is ended, and the next polling is restarted from the block.

[0094] Preferably, for each block parsing result successfully written into the offline repository of the new node, the successfully written block parsing result can be checked, and after the check passes, a check execution record indicating that the successfully written block parsing result passes the check can be written for the successfully written block parsing result in the offline repository of the new node, and the check execution record can include the block number. It should be noted that if the check execution record of the block parsing result of a block indicates that the check fails, the current polling is ended, and the next polling is restarted from the block.

[0095] In another embodiment of the present application, the specific implementation process of "step S102: based on the data in the offline repository of the new node, constructing the online data of the new node, and storing the online data of the new node to the online repository of the new node" in the above embodiment is introduced.

[0096] Please refer to Figure 4 , which shows the flowchart of constructing the online data of the new node based on the data in the offline repository of the new node, and storing the online data of the new node to the online repository of the new node, which can include:

[0097] Step S401: reconstructing each offline data unit written in the offline repository of the new node into a block with complete block structure to obtain a plurality of reconstructed blocks.

[0098] Wherein, each offline data unit written in the offline repository of the new node is a block parsing result of a block downloaded from the online node, and the reconstructed block is a block with complete block structure, which includes chain configuration, contract information, block body data, block header data and contract business data.

[0099] The purpose of step S401 is to reconstruct the block parsing result into a block with complete block structure in the memory for subsequent data checking.

[0100] Step S402: checking the obtained plurality of reconstructed blocks.

[0101] The process of checking the reconstructed blocks can include: firstly checking the reconstructed blocks offline, and then checking the reconstructed blocks that pass the offline check online based on the block information of the online node.

[0102] Optionally, when reconstructing the blocks, a checkpoint can be set, and for each check range determined based on the set checkpoint: reconstruct the blocks in the check range based on the offline data units (i.e. block parsing results) in the check range to obtain the reconstructed blocks in the check range, check the reconstructed blocks in the check range offline, and after the reconstructed blocks in the check range pass the offline check, check the reconstructed blocks in the check range online based on the block information of the online node. It should be noted that when checking a reconstructed block offline, the block hash of the reconstructed block can be compared with the previous block hash in the block header of the next reconstructed block, and if they are consistent, the reconstructed block is verified.

[0103] The process of checking the reconstructed blocks in a check range online based on the block information of the online node includes: calculating the block hash from the first reconstructed block in the check range to the last reconstructed block in the check range to obtain the block hash of the last reconstructed block in the check range, comparing the block hash of the last reconstructed block in the check range with the block hash of the same block of the online node, and if they are consistent, determining that the reconstructed blocks in the check range pass the online check.

[0104] The process of reconstructing blocks with complete block structure and checking the reconstructed blocks will be described below with reference to a specific example.

[0105] Suppose the offline repository of the new node stores the blocks 0-1000 downloaded from the online node, and the checkpoints 200, 400, 600, 800, and 1000 are set, and based on these checkpoints, five check ranges [0, 200], [201, 400], [401, 600], [601, 800], and [801, 1000] can be determined:

[0106] For the checking range [0, 200], the block parsing result of each block in the range [0, 200] can be reconstructed into a block with complete block structure (i.e., the reconstructed block includes chain configuration, contract information, block body data, block header data and contract business data) to obtain each reconstructed block in the range [0, 200], each reconstructed block in the range [0, 200] is checked offline, and after the offline verification of each reconstructed block in the range [0, 200] is passed, the block hash is calculated from the 0th reconstructed block to the 200th reconstructed block, so that the block hash of the 200th reconstructed block is obtained. The block hash of the 200th reconstructed block is compared with the block hash of the 200th block of any online node on the block chain, and if the two block hashes are consistent, it indicates that the online verification of the reconstructed blocks in the range [0, 200] is passed. For the checking range [201, 400], the block parsing result of each block in the range [201, 400] can be reconstructed into a block with complete block structure to obtain 200 reconstructed blocks in the range [201, 400], each reconstructed block in the range [201, 400] is checked offline, and after the offline verification of each reconstructed block in the range [201, 400] is passed, the block hash is calculated from the 201st reconstructed block to the 400th reconstructed block, the block hash of the 400th reconstructed block is obtained. The block hash of the 400th reconstructed block is compared with the block hash of the 400th block of any online node on the block chain, and if the two block hashes are consistent, it indicates that the online verification of the 200 reconstructed blocks in the range [201, 400] is passed. The process of reconstructing the block parsing result of the block in other ranges into a block with complete block structure and checking the reconstructed block is similar, which will not be described here.

[0107] Step S403: For each reconstructed block that passes the verification, an online data unit is constructed according to the reconstructed block, and the online data unit is written into the online repository of the new node.

[0108] For each reconstructed block that passes the check: in one possible implementation, the reconstructed block can be directly written as an online data unit in the online repository of the new node; considering that the reconstructed block contains data with high frequency of use and data with low frequency of use, and the contract business data is data with high frequency of use, in order to reduce the amount of online storage data of the new node and improve the running speed of the new node, in another more preferred implementation, an online data unit containing contract business data and not containing block body can be constructed based on the reconstructed block that passes the check, and the online data unit containing contract business data and not containing block body is written into the online repository of the new node. Considering that the storage capacity occupied by the chain configuration, contract information and block header data is small, an online data unit containing the chain configuration, contract information, block header data and contract business data can be constructed, and the online data unit containing the chain configuration, contract information, block header data and contract business data is written into the online repository of the new node, while the block body which occupies the most capacity will not be written into the online repository of the new node.

[0109] The above embodiments mention that, in order to reduce the amount of online storage data of the new node and improve the running speed of the new node, an online data unit containing the chain configuration, contract information, block header data and contract business data and not containing the block body can be constructed based on the reconstructed block that passes the check, and then the constructed online data unit is written into the online repository of the new node. Since the constructed online data unit does not contain the block body, that is, each online data unit in the online repository of the new node does not contain the block body, when the new node needs to use the block body not contained in the online repository or needs to use part of the data in the block body not contained in the online repository, the present embodiment provides the following strategy:

[0110] Receiving a data query request of the new node; querying the data requested by the data query request in the offline repository of the new node; and feeding back the queried data to the new node. For example, as shown in Figure 5 When the data required by the new node D does not exist in the online repository, it will send a data query request to request the data it needs from the offline repository.

[0111] The data query request can include the block number to be queried, the block hash to be queried, the transaction hash to be queried, the timestamp and the query type.

[0112] The above embodiments mention that the block parsing result is stored in the offline repository, and in order to realize data query, some mapping relationship information needs to be stored in the offline repository, which can include: the relationship between the block header random number and the block number, the relationship between the block body and the block body hash and the block number, the relationship between the block header and the block header hash and the block number, the relationship between the block hash and the block number, and the relationship between the transaction hash and the block number. When performing data query, the data requested by the data query request is queried from the offline repository of the new node based on the information in the data query request and the mapping relationship.

[0113] Specifically, the process of querying the data requested by the data query request in the offline repository of the new node can include: obtaining the query type from the data query request; if the query type is a transaction, querying the transaction data requested by the data query request in the offline repository of the new node according to the transaction hash contained in the data query request and the mapping relationship (such as the relationship between the transaction hash and the block number, the relationship between the block body and the block body hash and the block number); it should be noted that the transaction data here is non-contract business data, such as description data of objects involved in non-contract business data; if the query type is a block, the block body requested by the data query request can be found according to the block number or block hash contained in the data query request and the mapping relationship information (such as the relationship between the block body and the block body hash and the block number, the relationship between the block hash and the block number).

[0114] It should be noted that after the new node obtains the feedback data, the obtained data is verified based on the corresponding block header locally, and is used after verification. Specifically, if the new node obtains the feedback transaction data, the obtained transaction data can be calculated by the Merkle tree algorithm, and the calculated hash is matched and verified with the data in the local corresponding block header. If the new node obtains the feedback block body, the obtained block body is assembled with the local corresponding block header and block hash calculation is performed, and the calculated block hash is matched and verified with the block hash of the local corresponding block header.

[0115] The online processing method of the new node of the blockchain provided by the embodiment of the present application synchronizes all blocks on the blockchain to the offline repository before the new node is online, and then constructs the data required by the new node based on the offline repository and stores the data to the online storage, the new node and the online repository of the new node are deployed together on the blockchain, and after the new node is started, the data in the online storage can be directly loaded. This way can avoid the new node occupying the online node resources, and reduce the impact of the synchronized data on the existing nodes. In addition, when constructing the online data, the online data unit containing the contract business data (data with higher frequency of use) and not containing the block body (the block body contains some data with lower frequency of use, and the block body occupies a larger storage capacity) is constructed, and other data is obtained from the offline repository when needed by the new node. This way reduces the amount of data constructed, reduces the amount of online storage data of the new node, and improves the running speed of the new node.

[0116] The embodiment of the present application also provides an online processing device of a new node of a blockchain. The online processing device of the new node of the blockchain provided by the embodiment of the present application is described below, and the online processing device of the new node of the blockchain described below can be correspondingly referred to the online processing method of the new node of the blockchain described above.

[0117] Please refer to Figure 6 , which shows the structure schematic diagram of the online processing device of the new node of the blockchain provided by the embodiment of the present application, which can include: a block synchronization module 601, an online data construction module 602, an online data storage module 603 and a new node and online repository deployment module 604.

[0118] The block synchronization module 601 is used for synchronizing all blocks on the blockchain to the offline repository of the new node.

[0119] The online data construction module 602 is used for constructing the online data of the new node based on the data in the offline repository of the new node.

[0120] The online data storage module 603 is used for storing the online data of the new node to the online repository of the new node.

[0121] The new node and online repository deployment module 604 is used for deploying the new node and the online repository of the new node together on the blockchain, so that the new node directly loads the data in the online repository after starting.

[0122] Optionally, when synchronizing all blocks on the blockchain to the offline repository of the new node, the block synchronization module 601 is specifically used for:

[0123] Polling the online nodes in the configured online node list:

[0124] reading a current online block height of the online repository of the currently polled online node as a current online block height;

[0125] in a case where the current online block height is greater than a current offline block height: if a current block height difference is less than a preset block height difference threshold, downloading a differential block from the currently polled online node; if the current block height difference is greater than or equal to the block height difference threshold, downloading a differential block from a plurality of online nodes in the online node list; wherein the current offline block height is a current block height of the offline repository, and the current block height difference is a difference between the current online block height and the current offline block height;

[0126] writing the downloaded block into the offline repository of the new node.

[0127] Optionally, the block synchronization module 601, when writing the downloaded block into the offline repository of the new node, is specifically configured to:

[0128] for each downloaded block:

[0129] parsing the block to obtain a block parsing result of the block, the block parsing result including chain configuration, contract information, block body data, block header data and contract business data;

[0130] writing the block parsing result of the block as an offline data unit into the offline repository of the new node.

[0131] Optionally, the online processing device of the new node of the block chain provided by the embodiment of the application can further include a write execution record writing module, a block parsing result checking module and a checking execution record writing module.

[0132] The write execution record writing module is configured to, for each block parsing result, write, after the block synchronization module 601 successfully writes the block parsing result into the offline repository of the new node, a write execution record indicating that the block parsing result is successfully written into the offline repository of the new node.

[0133] The block parsing result checking module is configured to, for each successfully written block parsing result, check the successfully written block parsing result.

[0134] The checking execution record writing module is configured to, after the block parsing result checking module checks each successfully written block parsing result, write, into the offline repository of the new node, a checking execution record indicating that the block parsing result is checked through.

[0135] Optionally, the online data construction module 602, when constructing the online data of the new node based on the data in the offline repository of the new node, is specifically configured to:

[0136] reconstruct each offline data unit written in the offline repository of the new node into a block with a complete block structure to obtain a plurality of reconstructed blocks, wherein an offline data unit is a block parsing result of a downloaded block, and a reconstructed block contains a chain configuration, contract information, block body data, block header data, and block of contract service data;

[0137] verify the plurality of reconstructed blocks;

[0138] for each reconstructed block that passes the verification, construct an online data unit according to the reconstructed block, wherein the online data unit contains contract service data and does not contain block body data.

[0139] The online data storage module 603 is specifically configured to, when storing online data of the new node to the online repository of the new node:

[0140] write the online data unit constructed by the online data construction module 602 according to the reconstructed block into the online repository of the new node.

[0141] Optionally, the online data construction module 602 is specifically configured to, when verifying the plurality of reconstructed blocks:

[0142] offline verify the plurality of reconstructed blocks;

[0143] based on block information of the online node, online verify the reconstructed blocks that pass the offline verification.

[0144] Optionally, the online data construction module 602 is specifically configured to, when reconstructing each offline data unit written in the offline repository of the new node into a block with a complete block structure:

[0145] for each check range determined based on the set checkpoint, reconstruct blocks in the check range based on offline data units in the check range to obtain reconstructed blocks in the check range;

[0146] Optionally, the online data construction module 602 is specifically configured to, when verifying the plurality of reconstructed blocks:

[0147] for each check range determined based on the set checkpoint, offline verify the reconstructed blocks in the check range;

[0148] after the reconstructed blocks in the check range pass the offline verification, calculate block hashes from the first reconstructed block in the check range to the last reconstructed block in the check range to obtain the block hash of the last reconstructed block in the check range;

[0149] By comparing the block hash of the last reconstructed block in the check range with the block hash of the same block of any online node on the blockchain, the online check result of the reconstructed block in the check range is determined.

[0150] Optionally, the online processing device for a new node of a blockchain provided by the embodiment of the present application further comprises a data query request receiving module, a data query module and a data feedback module.

[0151] The data query request receiving module is configured to receive a data query request of the new node after the new node is online.

[0152] The data query module is configured to query data requested by the data query request in the offline storage of the new node.

[0153] The data feedback module is configured to feed back the queried data to the new node.

[0154] Optionally, the offline storage further stores mapping relationship information, and the mapping relationship information comprises a relationship between a transaction hash and a block number, a relationship between a block body and a block body hash and a block number, and a relationship between a block hash and a block number.

[0155] When the data query module queries data requested by the data query request in the offline storage of the new node, the data query module is specifically configured to:

[0156] If the query type contained in the data query request is a transaction, the transaction data requested by the data query request is queried in the offline storage of the new node according to the transaction hash contained in the data query request and the mapping relationship information, wherein the transaction data is non-contract business data.

[0157] If the query type contained in the data query request is a block, the block body requested by the data query request is found according to the block number or the block hash contained in the data query request and the mapping relationship information.

[0158] The online processing device of the new node of the blockchain provided by the embodiment of the present application firstly synchronizes all blocks on the blockchain to the offline repository of the new node, then constructs online data of the new node based on data in the offline repository of the new node, stores the online data of the new node to the online repository of the new node, and finally deploys the new node and the online repository of the new node to the blockchain. The online processing device of the new node of the blockchain provided by the embodiment of the present application can construct the online data of the new node based on data in the offline repository and store the online data to the online repository without affecting existing nodes on the blockchain. When the new node is online, the online data can be directly loaded from the online repository, avoiding synchronization from the online node, so that the new node can participate in consensus and business in the initial stage of being online.

[0159] The embodiment of the present application also provides an online processing device of a new node of a blockchain, please refer to Figure 7 , which shows a structural schematic diagram of the online processing device of the new node of the blockchain. The online processing device of the new node of the blockchain can include at least one processor 701, at least one communication interface 702, at least one memory 703 and at least one communication bus 704.

[0160] In the embodiment of the present application, the number of the processor 701, the communication interface 702, the memory 703 and the communication bus 704 is at least one, and the processor 701, the communication interface 702 and the memory 703 complete the communication with each other through the communication bus 704.

[0161] The processor 701 can be a central processing unit CPU, or a specific integrated circuit ASIC (Application Specific Integrated Circuit), or one or more integrated circuits configured to implement the embodiment of the present application, etc.

[0162] The memory 703 can include a high-speed RAM memory, and can also include a non-volatile memory, etc., such as at least one disk memory.

[0163] The memory stores a program, and the processor can call the program stored in the memory, and the program is used for:

[0164] Synchronizing all blocks on the blockchain to the offline repository of the new node;

[0165] Constructing online data of the new node based on data in the offline repository of the new node, and storing the online data of the new node to the online repository of the new node;

[0166] deploy the new node and the online repository of the new node onto the blockchain, so that the new node directly loads the data in the online repository after starting up.

[0167] Optionally, the refinement function and the extension function of the program can refer to the description above.

[0168] The embodiment of the application further provides a readable storage medium, which can store a program suitable for processor execution, and the program is used for:

[0169] synchronizing all blocks on the blockchain to the offline repository of the new node;

[0170] constructing online data of the new node based on the data in the offline repository of the new node, and storing the online data of the new node into the online repository of the new node;

[0171] deploy the new node and the online repository of the new node onto the blockchain, so that the new node directly loads the data in the online repository after starting up.

[0172] Optionally, the refinement function and the extension function of the program can refer to the description above.

[0173] Finally, it should be noted that, in this document, the relationship terms such as first and second are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the terms "include", "contain" or any other variants thereof are intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only includes those elements, but also includes other elements not explicitly listed or inherent to such process, method, article or equipment. Without more limitations, the element defined by the statement "including a" does not exclude the presence of other identical elements in the process, method, article or equipment including the element.

[0174] The various embodiments in the specification are described in a progressive manner, and each embodiment focuses on the difference from other embodiments, and the same or similar parts between various embodiments can be referred to each other.

[0175] The foregoing description of the disclosed embodiments enables a person skilled in the art to make or use the application. Modifications of these embodiments will occur to persons of skill in the art, and that the appended claims are intended to cover all such modifications that do not depart from the true spirit and scope of the application. Therefore, the application is not limited to the embodiments shown but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for online processing of a new node of a blockchain, characterized in that, The method comprises the following steps: polling online nodes in a configured online node list: reading a current online repository block height of an online node currently polled as a current online block height; in a case where the current online block height is greater than a current offline block height: if a current block height difference is less than a preset block height difference threshold, downloading a differential block from the online node currently polled; if the current block height difference is greater than or equal to the block height difference threshold, downloading differential blocks from a plurality of online nodes in the online node list; wherein the current offline block height is a current block height of an offline repository, and the current block height difference is a difference between the current online block height and the current offline block height; and writing the downloaded blocks into an offline repository of a new node; constructing online data of the new node based on data in the offline repository of the new node, and storing the online data of the new node into the offline repository of the new node; deploying the new node and the offline repository of the new node onto the blockchain, so that the new node directly loads data in the offline repository after being started. 2.The method of Claim 1, wherein, The writing of the downloaded blocks into the offline repository of the new node comprises: for each downloaded block: parsing the block to obtain a block parsing result of the block, the block parsing result comprising chain configuration, contract information, block body data, block header data and contract business data; writing the block parsing result of the block as an offline data unit into the offline repository of the new node.

3. The online processing method of the blockchain new node according to claim 2, further comprising: for each block parsing result, after successfully writing the block parsing result into the offline repository of the new node, writing a write execution record indicating that the block parsing result is successfully written into the offline repository of the new node for the block parsing result; for each successfully written block parsing result, verifying the successfully written block parsing result, and after the verification passes, writing a verification execution record indicating that the successfully written block parsing result passes the verification into the offline repository of the new node for the successfully written block parsing result. 4.The method of Claim 1-3, wherein, The constructing of the online data of the new node based on the data in the offline repository of the new node, and the storing of the online data of the new node into the offline repository of the new node, comprises: reconstructing each offline data unit written in the offline repository of the new node into a block with a complete block structure to obtain a plurality of reconstructed blocks, wherein an offline data unit is a block parsing result of a downloaded block, and a reconstructed block contains a block of chain configuration, contract information, block body data, block header data and contract business data; verifying the plurality of reconstructed blocks; for each reconstructed block that passes the verification, constructing an online data unit according to the reconstructed block, and writing the online data unit into the online repository of the new node, wherein the online data unit contains contract business data and does not contain block body data. 5.The method of Claim 4, wherein, The verifying of the plurality of reconstructed blocks comprises: offline verifying the plurality of reconstructed blocks; Based on the block information of the online nodes, the reconstructed blocks that pass the offline verification are subjected to online verification. 6.The method of Claim 4, wherein, The reconstructing each offline data unit written in the offline repository of the new node into a block with a complete block structure comprises: For each checking range determined based on the set checkpoint, reconstruct the blocks in the checking range based on the offline data units in the checking range to obtain reconstructed blocks in the checking range; The verifying the plurality of reconstructed blocks comprises: For each checking range determined based on the set checkpoint, perform offline verification on the reconstructed blocks in the checking range; After the reconstructed blocks in the checking range pass the offline verification, calculate the block hash from the first reconstructed block in the checking range to the last reconstructed block in the checking range to obtain the block hash of the last reconstructed block in the checking range; By comparing the block hash of the last reconstructed block in the checking range with the block hash of the same block on any online node of the blockchain, the online verification result of the reconstructed blocks in the checking range is determined.

7. The method of Claim 4, wherein, Further comprising: After the new node is online, receiving a data query request of the new node; In the offline repository of the new node, querying the data requested by the data query request; Feeding back the queried data to the new node. 8.The method of Claim 7, wherein, The offline repository also stores mapping relationship information, which includes the relationship between transaction hash and block number, the relationship between block body and block body hash and block number, and the relationship between block hash and block number; In the offline repository of the new node, querying the data requested by the data query request comprises: If the query type contained in the data query request is a transaction, according to the transaction hash contained in the data query request and the mapping relationship information, querying the transaction data requested by the data query request in the offline repository of the new node, wherein the transaction data is non-contract business data; If the query type contained in the data query request is a block, according to the block number or block hash contained in the data query request and the mapping relationship information, finding the block body requested by the data query request.

9. An online processing device of a new node of a blockchain, characterized in that, Comprise: Block synchronization module, online data construction module, online data storage module and new node and online repository deployment module; The block synchronization module is configured to poll the online nodes in the configured online node list: read the block height of the online repository of the currently polled online node as the current online block height; In the case where the current online block height is greater than the current offline block height: if the current block height difference is less than a preset block height difference threshold, download the differential blocks from the currently polled online node; if the current block height difference is greater than or equal to the block height difference threshold, download the differential blocks from the plurality of online nodes in the online node list; wherein the current offline block height is the current block height of the offline repository, and the current block height difference is the difference between the current online block height and the current offline block height; write the downloaded blocks into the offline repository of the new node; The online data construction module is configured to construct online data of the new node based on data in an offline repository of the new node. The online data storage module is configured to store the online data of the new node into an online repository of the new node. The new node and online repository deployment module is configured to deploy the new node and the online repository of the new node together on the blockchain, so that the new node directly loads data in the online repository after being started.

10. A device for online processing of a new node of a blockchain, characterized in that, Comprise: a memory and a processor; The memory is configured to store a program; The processor is configured to execute the program to implement each step of the online processing method of the new node of the blockchain according to any one of claims 1-8.

11. A readable storage medium, having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement each step of the online processing method of the new node of the blockchain according to any one of claims 1-8.

Citation Information

Patent Citations

  • Systems and methods of launching new nodes in a blockchain network

    US20200372043A1