Blockchain light node data synchronization method, device and equipment and readable storage medium

By obtaining the block height list of master nodes in the blockchain network, filtering and synchronizing the data of light nodes that are the same as them, the problem of light node data consistency is solved, and automatic synchronization of node data and load equalization are achieved.

CN114416883BActive Publication Date: 2026-01-13CHENGDU PRIME STARK TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210100553.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2026-01-13
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

How to ensure the consistency of local block data between multiple light nodes and the master node in a blockchain network, especially when light nodes do not participate in consensus.

Method used

By obtaining the block height list sent by the master node, it is determined whether the block height of the local node is the same as that of the master node. A second node with the same block height as the master node is selected, and a data synchronization request is sent to it. The block data of the second node is received and verified, the local ledger data is updated, and a synchronization node is randomly selected to reduce the load on the master node.

Benefits of technology

It enables automatic synchronization of nodes in the blockchain network, evenly distributes the data synchronization load, and improves data consistency and the processing capacity of the master node.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416883B_ABST
    Figure CN114416883B_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of blockchain, in particular to a kind of blockchain light node data synchronization method, device and equipment and readable storage medium, the method comprises: obtaining the block height list sent by main node;According to the block height table, judge whether local node block height is same with main node block height, if local node block height is different from the main node block height, and there is at least one light node in the block height list same with the main node block height, then filter out multiple second nodes, and send data synchronization request to any one second node;Receive the corresponding second local block data sent by the selected second node, the present application discloses that the main node in domain publishes block height list regularly, so that each node in the domain automatically updates local block height, and then the effect of each node block data synchronization in the domain is achieved;Light node randomly selects node that meets the condition to synchronize data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and more specifically, to a method, apparatus, and device for synchronizing data of blockchain light nodes, as well as a readable storage medium. Background Technology

[0002] To improve speed, blockchain networks divide nodes into multiple domains. Each domain contains multiple light nodes and one master node. The master node represents the domain in participating in the consensus and voting of the blockchain network. Since the multiple light nodes in the domain do not participate in the consensus of the blockchain network, how to ensure the consistency of the local block data of the multiple light nodes with that of the master node has become an urgent problem to be solved. Summary of the Invention

[0003] The purpose of this invention is to provide a method, apparatus, device, and readable storage medium for synchronizing data of blockchain light nodes, so as to improve the above-mentioned problems.

[0004] To achieve the above objectives, the embodiments of this application provide the following technical solutions:

[0005] On one hand, this application provides a blockchain light node data synchronization method, applied to any light node in a blockchain network. The method includes: obtaining a block height list sent by a master node, wherein the block height list records the block heights of all nodes in the corresponding domain; determining whether the local node's block height is the same as the master node's block height based on the block height list; if the local node's block height is different from the master node's block height, and at least one light node in the block height list has the same block height as the master node, then selecting multiple second nodes and sending a data synchronization request to any one of the second nodes, wherein the data synchronization request is used to trigger the selected second node to send the corresponding second local block data to the corresponding request node, wherein the second node is a node in the domain with the same block height as the master node; and receiving the corresponding second local block data sent by the selected second node.

[0006] Optionally, after receiving the corresponding second local block data sent by the selected second node, the method further includes:

[0007] Generate a second local ledger based on the local block data and the second local block data;

[0008] Send a verification request to the master node, the verification request including the block height value and the corresponding verification hash;

[0009] The verification hash is compared with the hash value corresponding to the second local ledger data. If they are the same, the second local ledger data is used as the new local block data, and the current local block height is sent to the master node so that the master node updates the block height list.

[0010] Optionally, a data synchronization request is sent to any one of the second nodes, the data synchronization request being used to trigger the selected second node to send the corresponding local block data to the corresponding requesting node, including:

[0011] The height of the block to be supplemented is calculated based on the local node block height and the master node block height.

[0012] A data synchronization request is generated based on the height of the block to be supplemented and sent to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node.

[0013] Secondly, this embodiment discloses a blockchain light node data synchronization device, characterized in that it is applied to any light node within a blockchain network, and the device includes:

[0014] The first acquisition module is used to acquire the block height list sent by the master node, wherein the block height list records the block heights of all nodes in the corresponding domain;

[0015] The first calculation module is used to determine whether the local node block height is the same as the master node block height according to the block height table. If the local node block height is different from the master node block height, and there is at least one light node in the block height list that is the same as the master node block height, then multiple second nodes are selected, and a data synchronization request is sent to any one of the second nodes. The data synchronization request is used to trigger the selected second node to send the corresponding second local block data to the corresponding request node. The second node is a node in the domain that is the same as the master node block height.

[0016] The first receiving module is used to receive the corresponding second local block data sent by the selected second node.

[0017] Optionally, the first receiving module further includes:

[0018] The first computing unit is used to generate second local ledger data based on the local block data and the second local block data;

[0019] The second calculation unit is used to send a verification request to the master node. The verification request includes the block height value and the corresponding verification hash.

[0020] The third calculation unit is used to compare whether the verification hash is the same as the hash value corresponding to the second local ledger data. If they are the same, the second local ledger data is used as the new local block data, and the current local block height is sent to the master node so that the master node updates the block height list.

[0021] Optionally, the first computing module includes:

[0022] The fourth calculation unit is used to calculate the height of the block to be supplemented based on the local node block height and the master node block height.

[0023] The fifth calculation unit is used to generate a data synchronization request based on the height of the block to be supplemented and send it to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node.

[0024] Thirdly, embodiments of this application provide a blockchain light node data synchronization device, the device including a memory and a processor.

[0025] The memory is used to store computer programs; the processor is used to execute the computer programs to implement the steps of the above-described blockchain light node data synchronization method.

[0026] Fourthly, embodiments of this application provide a readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the aforementioned blockchain light node data synchronization method.

[0027] The beneficial effects of this invention are as follows:

[0028] This invention uses the master node in the domain to periodically publish the block height list, so that each node in the domain can automatically update its local block height, thereby achieving the effect of synchronizing block data among nodes in the domain.

[0029] Secondly, when synchronizing block data, the data node to be synchronized will randomly search among the nodes that meet the conditions in the domain, instead of always searching for the master node to synchronize data, thereby making the load of each node server in the domain more even.

[0030] Other features and advantages of the invention will be set forth in the following description, and will be apparent in part from the description, or may be learned by practicing embodiments of the invention. The objects and other advantages of the invention may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0031] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.

[0032] Figure 1 This is a schematic diagram of a blockchain light node data synchronization method as described in an embodiment of the present invention;

[0033] Figure 2 This is a schematic diagram of the structure of a blockchain light node data synchronization device as described in an embodiment of the present invention;

[0034] Figure 3 This is a schematic diagram of the structure of a blockchain light node data synchronization device as described in an embodiment of the present invention. Detailed Implementation

[0035] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of the present invention. The components of the embodiments of the present invention described and shown in the accompanying drawings can generally be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.

[0036] It should be noted that similar reference numerals or letters in the following figures indicate similar items; therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. Furthermore, in the description of this invention, terms such as "first," "second," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0037] Example 1

[0038] like Figure 1 As shown, this embodiment provides a blockchain light node data synchronization method, which is applied to any light node in the blockchain network. The method includes steps S1, S2 and S3.

[0039] Step S1. Obtain the block height list sent by the master node. The block height list records the block heights of all nodes in the corresponding domain. A domain can be understood as the smallest unit participating in consensus. There are multiple domains in the blockchain network. Each domain contains one master node and multiple light nodes. Transactions in the blockchain only require the master node in the domain to participate in consensus. The other light nodes can initiate transactions or synchronize the transaction execution results of the master node. The execution results are the block data.

[0040] Step S2. Determine whether the local node block height is the same as the master node block height according to the block height table. If the local node block height is different from the master node block height, and there is at least one light node in the block height list that is the same as the master node block height, then select multiple second nodes and send a data synchronization request to any one of the second nodes. The data synchronization request is used to trigger the selected second node to send the corresponding second local block data to the corresponding request node. The second node is a node in the domain that is the same as the master node block height. In this embodiment, the master node in each domain will maintain and update a height list. When the light node synchronizes data, it will first receive the latest current block height list. Each block will determine whether its local block height is the same as the master node's block height according to the table. If they are different, the data synchronization operation will be triggered.

[0041] Secondly, during the synchronization operation, the light node that needs to synchronize data will randomly send a synchronization request to any node in the domain with the same block height as the master node (including both light nodes and the master node), thereby avoiding the situation where the master node device is overloaded when multiple light nodes synchronize data to the master node at the same time.

[0042] In step S2, the data synchronization operation of the light node does not directly copy the entire public ledger data (including multiple block data) of the second node, but rather performs a partial extraction. The specific operation is as follows:

[0043] Step S21. Calculate the height of the block to be supplemented based on the local node block height and the master node block height. The height of the block to be supplemented is the height value corresponding to the multiple missing block data in the local ledger of the light node.

[0044] Step S22. Generate a data synchronization request based on the height of the block to be supplemented and send it to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node.

[0045] Step S3. Receive the corresponding second local block data sent by the selected second node.

[0046] After step S3, the light node to be supplemented with block data needs to verify the authenticity of the data after receiving the second local block data. The specific verification steps include:

[0047] Step S4. Generate second local ledger data based on the local block data and the second local block data;

[0048] Step S5. Send a verification request to the master node. The verification request includes the block height value and the corresponding verification hash. The verification hash is the hash value of the local ledger data corresponding to the block height value.

[0049] Step S6. Compare whether the verification hash is the same as the hash value corresponding to the second local ledger data. If they are the same, use the second local ledger data as the new local block data and send the current local block height to the master node so that the master node updates the block height list.

[0050] In this implementation, the verification method for the light node that needs to supplement the block data after obtaining the second local block data is to combine the second local block data with the local block data to generate the second local ledger data. The authenticity of the second local block data is then determined by verifying whether the hash value of the second local ledger data is the same as the verification hash.

[0051] Example 2

[0052] like Figure 2 As shown, this embodiment provides a blockchain light node data synchronization device, which is applied to any light node in a blockchain network. The device includes a first acquisition module 71, a first calculation module 72, and a first receiving module 73.

[0053] The first acquisition module 71 is used to acquire the block height list sent by the master node, wherein the block height list records the block heights of all nodes in the corresponding domain;

[0054] The first calculation module 72 is used to determine whether the local node block height is the same as the master node block height according to the block height table. If the local node block height is different from the master node block height, and there is at least one light node in the block height list that is the same as the master node block height, then multiple second nodes are selected, and a data synchronization request is sent to any one of the second nodes. The data synchronization request is used to trigger the selected second node to send the corresponding second local block data to the corresponding request node. The second node is a node in the domain that is the same as the master node block height.

[0055] The first receiving module 73 is used to receive the corresponding second local block data sent by the selected second node.

[0056] In this embodiment, the first receiving module 73 further includes:

[0057] The first computing unit 731 is used to generate second local ledger data based on local block data and the second local block data;

[0058] The second computing unit 732 is used to send a verification request to the master node, the verification request including the block height value and the corresponding verification hash;

[0059] The third calculation unit 733 is used to compare whether the verification hash is the same as the hash value corresponding to the second local ledger data. If they are the same, the second local ledger data is used as the new local block data, and the current local block height is sent to the master node so that the master node updates the block height list.

[0060] In this embodiment, the first computing module 72 includes:

[0061] The fourth calculation unit 721 is used to calculate the height of the block to be supplemented based on the local node block height and the master node block height;

[0062] The fifth calculation unit 722 is used to generate a data synchronization request based on the height of the block to be supplemented and send it to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node.

[0063] It should be noted that the specific manner in which each module performs its operation in the apparatus described in the above embodiments has been described in detail in the embodiments of the method, and will not be elaborated here.

[0064] Example 3

[0065] Corresponding to the above method embodiments, this disclosure also provides a blockchain light node data synchronization device. The blockchain light node data synchronization device described below and the blockchain light node data synchronization method described above can be referred to each other.

[0066] Figure 3 This is a block diagram illustrating a blockchain light node data synchronization device 800 according to an exemplary embodiment. Figure 3 As shown, the electronic device 800 may include a processor 801 and a memory 802. The electronic device 800 may also include one or more of a multimedia component 803, an input / output (I / O) interface 804, and a communication component 805.

[0067] The processor 801 controls the overall operation of the electronic device 800 to complete all or part of the steps in the aforementioned blockchain light node data synchronization method. The memory 402 stores various types of data to support the operation of the electronic device 800. This data may include, for example, instructions for any application or method operating on the electronic device 800, and application-related data such as contact data, sent and received messages, pictures, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. Multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touchscreen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signals may be further stored in memory 802 or transmitted via communication component 805. The audio component also includes at least one speaker for outputting audio signals. I / O interface 804 provides an interface between processor 801 and other interface modules, such as a keyboard, mouse, buttons, etc. These buttons may be virtual or physical buttons. Communication component 805 is used for wired or wireless communication between the electronic device 800 and other devices. Wireless communication may include Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination of these. Therefore, the corresponding communication component 805 may include a Wi-Fi module, a Bluetooth module, or an NFC module.

[0068] In an exemplary embodiment, the electronic device 800 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to perform the aforementioned blockchain light node data synchronization method.

[0069] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, which, when executed by a processor, implement the steps of the blockchain light node data synchronization method described above. For example, the computer-readable storage medium may be the memory 802 including the program instructions described above, which may be executed by the processor 801 of the electronic device 800 to complete the blockchain light node data synchronization method described above.

[0070] Example 4

[0071] Corresponding to the above method embodiments, this disclosure also provides a readable storage medium. The readable storage medium described below can be referred to in conjunction with the blockchain light node data synchronization method described above.

[0072] A readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the blockchain light node data synchronization method described in the above method embodiments.

[0073] Specifically, the readable storage medium can be a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk, or any other readable storage medium capable of storing program code.

[0074] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A method for synchronizing data in a blockchain light node, characterized in that, The method, applied to any light node within a blockchain network, includes: Obtain the block height list sent by the master node, wherein the block height list contains the block heights of all nodes in the corresponding domain; Based on the block height table, determine whether the local node block height is the same as the master node block height. If the local node block height is different from the master node block height, and there is at least one light node in the block height list that has the same block height as the master node, then select multiple second nodes and send a data synchronization request to any one of the second nodes. The data synchronization request is used to trigger the selected second node to send the corresponding second local block data to the corresponding request node. The second node is a node in the domain that has the same block height as the master node. Sending a data synchronization request to any one of the second nodes, the data synchronization request being used to trigger the selected second node to send the corresponding local block data to the corresponding requesting node, including: The height of the block to be supplemented is calculated based on the local node block height and the master node block height. A data synchronization request is generated based on the height of the block to be supplemented and sent to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node. Receive the corresponding second local block data sent by the selected second node.

2. The blockchain light node data synchronization method according to claim 1, characterized in that, After receiving the corresponding second local block data sent by the selected second node, the method further includes: Generate a second local ledger based on the local block data and the second local block data; Send a verification request to the master node, the verification request containing the block height value and the corresponding verification hash; The verification hash is compared with the hash value corresponding to the second local ledger data. If they are the same, the second local ledger data is used as the new local block data, and the current local block height is sent to the master node so that the master node updates the block height list.

3. A blockchain light node data synchronization device, characterized in that, The device is applied to any light node within a blockchain network and includes: The first acquisition module is used to acquire the block height list sent by the master node, wherein the block height list records the block heights of all nodes in the corresponding domain; The first calculation module is used to determine whether the local node's block height is the same as the master node's block height based on the block height table. If the local node's block height is different from the master node's block height, and at least one light node in the block height list has the same block height as the master node, then multiple second nodes are selected, and a data synchronization request is sent to any one of the second nodes. The data synchronization request is used to trigger the selected second node to synchronize its corresponding data. The second local block data is sent to the corresponding request node, and the second node is a node in the domain with the same block height as the master node; The first receiving module is used to receive the corresponding second local block data sent by the selected second node; The first computing module includes: The fourth calculation unit is used to calculate the height of the block to be supplemented based on the local node block height and the master node block height. The fifth calculation unit is used to generate a data synchronization request based on the height of the block to be supplemented and send it to the selected second node, so that the selected second node sends the block data corresponding to the height of the block to be supplemented to the corresponding request node.

4. The blockchain light node data synchronization device according to claim 3, characterized in that, The first receiving module further includes: The first computing unit is used to generate second local ledger data based on the local block data and the second local block data; The second calculation unit is used to send a verification request to the master node. The verification request includes the block height value and the corresponding verification hash. The third calculation unit is used to compare whether the verification hash is the same as the hash value corresponding to the second local ledger data. If they are the same, the second local ledger data is used as the new local block data, and the current local block height is sent to the master node so that the master node updates the block height list.

5. A blockchain light node data synchronization device, characterized in that, include: Memory, used to store computer programs; A processor, configured to implement the steps of the blockchain light node data synchronization method as described in any one of claims 1 to 2 when executing the computer program.

6. A readable storage medium, characterized in that: The readable storage medium stores a computer program that, when executed by a processor, implements the steps of the blockchain light node data synchronization method as described in any one of claims 1 to 2.

Citation Information

Patent Citations

  • Consensus method of block chain, electronic equipment and storage medium

    CN110784521A

  • Block chain system, data storage method, data storage device, equipment and medium

    CN111159295A