CN113364847B - Data synchronization method and device of block chain nodes and storage medium - Google Patents

Data synchronization method and device of block chain nodes and storage medium Download PDF

Info

Publication number
CN113364847B
CN113364847B CN202110604013.XA CN202110604013A CN113364847B CN 113364847 B CN113364847 B CN 113364847B CN 202110604013 A CN202110604013 A CN 202110604013A CN 113364847 B CN113364847 B CN 113364847B
Authority
CN
China
Prior art keywords
state
data
node
request
block chain
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202110604013.XA
Other languages
Chinese (zh)
Other versions
CN113364847A (en
Inventor
陈权
杨文忠
马红桥
康鹏
李闯
雷景皓
侯温馨
王卓雯
王敏
妥美妹
杨晴雯
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Xinjiang University
Original Assignee
Xinjiang University
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Xinjiang University filed Critical Xinjiang University
Priority to CN202110604013.XA priority Critical patent/CN113364847B/en
Publication of CN113364847A publication Critical patent/CN113364847A/en
Application granted granted Critical
Publication of CN113364847B publication Critical patent/CN113364847B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a data synchronization method and device of a block chain node and a storage medium, which are applied to the technical field of data processing. The method provided by the invention comprises the following steps: acquiring a real-time state of a block chain, and judging a local state based on the real-time state; if the local state is inconsistent with the real-time state, a state synchronization request is initiated to the named data network; receiving a world state tree root of a block chain fed back by the named data network based on the state synchronization request, and initiating a state tree reconstruction request to the named data network based on the world state tree root; and receiving the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and synchronizing the data of the local state according to a preset rule. The invention is used for improving the efficiency of data synchronization of the block link points.

Description

Data synchronization method and device of block chain nodes and storage medium
Technical Field
The present invention relates to the field of data processing technologies, and in particular, to a data synchronization method and apparatus for a blockchain node, and a storage medium.
Background
The blockchain system is a decentralized, distributed shared ledger participated in by multiple nodes, all transactions on the blockchain being maintained by all nodes in the system together. Meanwhile, the blockchain needs to ensure the consistency of respective data through a consensus protocol among nodes by means of all the nodes. When a participating node fails or when a blockchain system has new participating nodes, the data of these nodes may lag the data maintained by other nodes. In order to ensure the consistency of data maintained by all nodes, data synchronization between blockchain nodes needs to be performed.
When a node in the block chain system finds that a node maintained by the node lags behind data of other nodes, a data synchronization request can be initiated, and the other nodes can package and send the data requested by the laggard nodes to the laggard nodes after receiving the data synchronization request.
However, this method needs to pull a large amount of data from the peer node for synchronization, a large amount of network traffic is repeatedly sent, and under the conditions of large amount of synchronized data and many laggard nodes, the efficiency of data synchronization is not high.
Disclosure of Invention
The invention provides a data synchronization method and device of a block chain node and a storage medium, which are used for improving the efficiency of data synchronization of the block chain node.
A method of data synchronisation of blockchain nodes, the method comprising the steps performed by any blockchain node in a blockchain of:
acquiring a real-time state of a block chain, and judging a local state based on the real-time state;
if the judging result is that the local state is inconsistent with the real-time state, a state synchronization request is initiated to the named data network;
receiving a world state tree root of a block chain fed back by the named data network based on the state synchronization request, and initiating a state tree reconstruction request to the named data network based on the world state tree root;
and receiving the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and performing data synchronization on the local state according to a preset rule.
A method of data synchronization of blockchain nodes, the method comprising the following steps performed by a named data network node:
when a state synchronization request initiated by any node of a block chain is received, feeding back a world state tree root to the block chain node point initiating the state synchronization request;
when a state tree reconstruction request initiated by any node of a block chain is received, locally inquiring based on the state tree reconstruction request to obtain state data corresponding to the state tree reconstruction request, wherein the state data is used as state data to be synchronized, and the state data to be synchronized is fed back to a block chain link point initiating the state tree reconstruction request.
A data synchronization device of a block chain node, the device being a block chain node, the block chain node comprising:
the real-time state acquisition module is used for acquiring the real-time state of the block chain and judging the local state based on the real-time state;
the state synchronization request initiating module is used for initiating a state synchronization request to the named data network if the judging result shows that the local state is inconsistent with the real-time state;
the state tree reconstruction request module is used for receiving a world state tree root of a block chain fed back by the named data network based on the state synchronization request and initiating a state tree reconstruction request to the named data network based on the world state tree root;
and the local state synchronization module is used for receiving the state data to be synchronized fed back by the named data network based on the state tree reconstruction request and carrying out data synchronization on the local state according to a preset rule.
A data synchronization apparatus of a blockchain node, the apparatus being a named data network node comprising:
the state synchronization request receiving module is used for feeding back a world state tree root to a block chain link point initiating a state synchronization request when receiving the state synchronization request initiated by any node of a block chain;
And the state data feedback module is used for locally inquiring based on the state tree rebuilding request when receiving the state tree rebuilding request initiated by any node of the block chain, obtaining state data corresponding to the state tree rebuilding request as state data to be synchronized, and feeding back the state data to be synchronized to the block chain node initiating the state tree rebuilding request.
A computer-readable storage medium, which stores a computer program that, when being executed by a processor, carries out the steps of the above-mentioned data synchronization method of a blockchain node.
According to the data synchronization method, device and storage medium of the block chain nodes, provided by the invention, by acquiring the real-time state of the block chain, when the local state of any node of the block chain lags behind the real-time state, a state synchronization request is initiated to a named data network, a world state tree root fed back by the named data network is received, a state tree reconstruction request is initiated based on the world state tree root, and according to the state data to be synchronized returned by the named data network, any node of the block chain synchronizes the local state, so that the data synchronization of the block chain nodes is realized, and the efficiency of performing data synchronization on the block chain link points is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments of the present invention will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without inventive labor.
FIG. 1 is a schematic diagram of an application environment of a block link point data synchronization method according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating a method for data synchronization of block link points according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of a data synchronization device for block link points according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a computer device according to an embodiment of the invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be obtained by a person skilled in the art without inventive step based on the embodiments of the present invention, are within the scope of protection of the present invention.
The data synchronization method of the blockchain node according to the embodiment of the present invention may be applied to the application environment shown in fig. 1, where as shown in fig. 1, the blockchain node 101 is directly connected to the NDN network node 102, and communicates with other blockchain nodes 104 in a P2P manner. The block link point 101 is a block link point whose local state is inconsistent with the latest state of the block chain, and the block link point 104 stores the latest state data for the block chain real-time node.
In an embodiment, as shown in fig. 2, a data synchronization method for blockchain nodes is provided, which is described by taking an application environment of the method in fig. 1 as an example, and the method includes S301 to S306:
s301, the block chain link points acquire the real-time state of the block chain, and the local state is judged based on the real-time state.
The current real-time state information of the block chain is obtained, and whether the local state of the block chain node is consistent with the real-time state information or not is judged according to the real-time state information.
The real-time status of the blockchain is specifically the world status in the etherhouse architecture. World state refers to the mapping of addresses (accounts) to account states, viewed as a global state that is continually updated as transactions are performed. All account information and transaction data for the etherhouse are present in the world state and are maintained by the world state tree. The state data refers to data which includes account information and transaction data and the like and represents the state of the blockchain.
The blocks in the block chain are composed of block heads and block bodies, and the root nodes of the world state tree and the hash values of the root nodes are stored in the block heads. Thus, by obtaining the block that is currently newly generated for the blockchain, the world state tree in the new block stores state data for the latest state of the blockchain.
And S302, if the judgment result of the block link node is that the local state is inconsistent with the real-time state, initiating a state synchronization request to the named data network.
The method comprises the steps that any node in a block chain stores a corresponding amount of state data, and when any node fails or is in an offline state currently, the state data stored by the node is inconsistent with the latest state data of the block chain.
In this embodiment, the local state tree is compared with the real-time state of the block chain, that is, the world state tree of the block chain, that is, hash values of root nodes of the respective state trees are compared, and if the local state of the current node is determined to be behind and inconsistent with the real-time state, a state synchronization request is initiated to the named data network.
Named Data Networking (NDN) is a data content-centric network architecture that distinguishes it from TCP/IP.
The network service provided in the NDN acquires the status data according to the designated name. In this embodiment, when any node of the block chain finds that the local state is inconsistent with the real-time state, the node serving as the node to be synchronized initiates a state synchronization request to request the latest world state data. The state synchronization request initiates requests in a fixed path, for example: "/block/lateststate/root" or "/block/lateststate/block _ number" to request the tree root node of the latest world state tree and the block number of the block storing the latest world state tree.
And S303, the named data network node receives a state synchronization request initiated by any node of the block chain, and feeds back the world state tree root to the block chain link point initiating the state synchronization request.
The named data network receives the corresponding state synchronization request, searches the corresponding state data in the content temporary storage assembly, and returns the state data to the block link point initiating the state synchronization request.
In this embodiment, the communication in the NDN is communicated from the receiving end, e.g., a data consumer, via two different types of packets, namely an interest packet and a data packet. In order to implement the forwarding function of interest packets and data packets, each NDN router has three data structures and one forwarding policy.
The pending interest table stores interest packets which are forwarded by the router but are not met yet, and each pending interest entry records a data name carried in the interest packet. The forwarding tables themselves are populated by routing protocols for name prefixes, and there may be multiple interfaces per prefix. The content buffer is used to buffer the data packets received by the router, because the source and forwarding path of the data packets in the NDN are independent, they can be buffered to satisfy the future interest packets.
S304, the block chain link point receives the universal state tree root of the block chain fed back by the named data network based on the state synchronization request, and initiates a state tree rebuilding request to the named data network based on the universal state tree root.
The world state tree root refers to a root node of a world state tree stored in a block, and hash values corresponding to all data pointed by the whole world state tree are stored in the root node.
And after receiving the world state tree root, initiating a state tree rebuilding request by taking the world state tree root as a data naming basis to acquire data pointed by the world state tree root. And after the corresponding data is obtained, performing hash value calculation on the data to update the hash value of each layer of nodes of the Merck tree, thereby achieving the aim of reconstructing a local state tree and achieving the synchronization of the data.
S305, when the named data network node receives a state tree rebuilding request initiated by any node of the block chain, the named data network node locally queries based on the state tree rebuilding request, and feeds back state data corresponding to the state tree rebuilding request to a block chain node point initiating the state tree rebuilding request.
The named data network acquires a node hash value corresponding to the target state data according to the state tree reconstruction request, and inquires corresponding state data in a content temporary storage component of the NDN router.
And S306, the block link nodes receive the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and perform data synchronization on the local state according to a preset rule.
The state data to be synchronized specifically refers to any node of the block chain, which is not locally stored. When a state tree reconstruction request is initiated based on the world state tree root, the child nodes of the state tree root are obtained according to the hash value of the world state tree root, so that state data pointed by the child nodes are obtained, wherein the form of the state data is embodied in the form of node hash values.
In the binary merkel tree structure, the root node is the 0 th layer, two child nodes of the root node are the 1 st layer, and if the block link point locally stores only the data of the right-handed tree of the 1 st layer, the block link point locally needs to confirm the data of the left-handed tree of the 1 st layer according to the hash value of the root node. And the block chain nodes calculate the node hash values of the left node on the layer 1 and the right node on the layer 1 to obtain the hash value of the root node, so that the data synchronization is realized.
The world state tree stores data in the form of a merkel tree. Any change to the data pointed to by the merkel tree causes a change to the hash of the node. The hash value stored in each parent node depends on the data contained in the child node.
In this embodiment, the real-time status of the blockchain is obtained to determine whether the local status of the blockchain node is consistent with the real-time status, and if not, a state synchronization request is initiated to the named data network to obtain a world state root, a state tree rebuild request is initiated based on the world state root, so as to obtain the state data which is not stored locally in the block chain link point, the state data is used as the data to be synchronized, the block chain link point updates the local state of the block chain node according to the data to be synchronized, and the corresponding state data is acquired through the named data network, so that the state data is prevented from being directly acquired from other peer block chain nodes, the state data which is not locally stored is acquired by the network flow block chain nodes through the named data network when the data is transmitted, the data volume needing to be synchronized is reduced, and the efficiency of data synchronization of the block chain nodes is improved.
The named data network returns the state data of the block chain request to the block chain nodes based on the request initiated by the block chain nodes, a large amount of state data are cached in the NDN nodes, the request to the real-time block chain nodes is not needed, the load of providing the state data by the real-time block chain nodes is reduced, and the stability and the reliability of the block chain network are further improved.
In some optional implementation manners in this embodiment, in S301, acquiring a real-time state of the block chain by using the block link point, and determining the local state based on the real-time state includes S3011 to S3013:
s3011, obtaining block broadcast information of the block chain, and determining a world state root of a newly generated block in the block chain according to the block broadcast information.
The block broadcast information is the propagation information of the block generated in the block chain, and the block number of the newly generated block and the world state tree stored in the block header and the root node of the world state tree are obtained from the block broadcast information.
S3012, compare the hash value of the world state root with the hash value of the local state root, and if the hash values of the two are not consistent, compare the block number of the newly generated block with the block number of the local block.
S3013, if the comparison result is that the block number of the newly generated block is greater than the block number of the local block, it is determined that the local state lags behind the real-time state.
And if the block number of the newly generated block is greater than that of the local block, the local state is confirmed to be behind the real-time state.
As an alternative, a local state tree may also exist in the block link points to point to the state data stored in the block chain.
The hash value stored in each parent node in the merkel tree depends on the data contained in the child node, so that the change of the data in the child node causes the change of the hash value of the parent node. The structural features of the merkel tree are such that the merkel tree has the following properties: when judging whether the data pointed by the two Mercker trees are completely the same, each leaf node does not need to be compared, and only the hash value stored in the root node needs to be compared.
Therefore, after the world state tree root of the block chain is obtained, the root node hash value of the world state tree is compared with the root node hash value of the local state tree stored by the block chain node point to judge whether the two merkel trees are the same or not, so as to determine whether the local state of the block chain node is consistent with the real-time state of the block chain.
In S3011 to S3013, by comparing the hash value of the root node of the world state tree with the hash value of the root node of the local state tree of the blockchain node, it is determined whether the local state of the blockchain node is inconsistent with the real-time state of the blockchain, so as to initiate a state synchronization request for data synchronization.
In some alternatives of the present embodiment, in S304, the receiving, by the tile chain node, the world state tree root of the tile chain fed back by the named data network based on the state synchronization request, and the initiating, by the tile chain node, the state tree rebuilding request to the named data network based on the world state tree root includes S3041 to S3042:
s3041, obtaining the corresponding block chain state data according to the world state tree root, and comparing the block chain state data with the local state data.
As an optional mode, the corresponding root node hash value is obtained from the world state tree root, and the purpose of initiating the state reconstruction request by using the root node hash value as the query index is to obtain the state data pointed by the root node hash value. The hash value of the root node is used as a query index, so that the storage information corresponding to the root node can be conveniently queried by a named data network, and a state tree reconstruction request initiated by a block chain node can be responded more quickly.
S3042, if the comparison result indicates that the block chain state data cannot be concatenated with the local state data, based on the block chain state data, a state tree rebuilding request is initiated to the named data to request sub-state data of the block chain state data.
And judging the hash value of each node according to the structural characteristics of the Merckel tree, and determining whether state data can be lent or not through the hash value.
And if the comparison result is that the sub-state data to be synchronized of the feedback block chain world state and the local state tree data can be merged and continuously connected, the sub-state data obtained by the request is considered to be complete.
If the block chain world state data cannot be merged and continuously connected, taking the hash of the non-leaf node in the block chain world state sub-state data to be synchronized as the query index to initiate the world state synchronization request again; and repeating the process until the world state trees can be merged and spliced, and reconstructing the world state trees based on the feedback to-be-synchronized sub-state data sets.
In S3041 to S3042, by determining whether the fed back status data and the local status data can be merged and spliced, only the status data whose local status does not exist is requested, so as to implement incremental synchronization of the block chain and improve the efficiency of data synchronization of the block chain link points.
In some optional implementation manners of this embodiment, in S305, when a named data network node receives a state tree rebuilding request initiated by any node of a block chain, the named data network node performs local query based on the state tree rebuilding request to obtain state data corresponding to the state tree rebuilding request, and the obtaining, as to-be-synchronized state data, includes the following steps:
When a state tree rebuilding request initiated by a block chain node is received, querying is carried out in a local cache assembly based on the state tree rebuilding request, and a query result is obtained.
And if the query result is that the state data corresponding to the state tree rebuilding request is cached in the local cache assembly, taking the state data corresponding to the state tree rebuilding request in the local cache assembly as the state data to be synchronized.
And if the query result is that the local cache component does not cache the state data corresponding to the state tree reconstruction request, forwarding the state tree reconstruction request to the real-time block link node, and receiving the to-be-synchronized state data fed back by the real-time block link node.
And when the real-time block chain link point receives a state tree rebuilding request initiated by a named data network node, returning the state data corresponding to the state tree rebuilding request to the named data network node as state data to be synchronized.
After the NDN router receives the state tree reconstruction request, that is, receives the interest packet, the NDN router may first query whether there is corresponding state data in a content temporary storage component in the NDN router, and if so, return the corresponding state data to the interest packet initiator, which in this embodiment refers to a block link point that initiates the state tree reconstruction request. And if the content temporary storage component does not have corresponding state data, sending the requested state data to the block chain real-time node, requesting the block chain real-time node to pack the corresponding state data, and when the NDN router receives the state data returned by the block chain real-time node, returning the state data to the block chain link point initiating the state tree reconstruction request, and storing the corresponding state data in the content temporary storage component.
In some optional manners of this embodiment, in S306, the receiving, by the block node, the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and performing data synchronization on the local state according to the preset rule includes S3061 to S3063:
s3061, child node information corresponding to the world state tree root and fed back by the named data network is received.
Taking the structure of the merkel tree as an example, after the root node of the 0 th layer is obtained, the hash value of the child node of the 1 st layer under the root node is obtained according to the hash value of the root node.
S3062, a state obtaining request is initiated based on the child node information, and corresponding state data fed back by the named data network are received.
The method comprises the steps of initiating a state acquisition request to a named data network based on child node information, namely initiating an interest packet to the named data network by virtue of child node information naming, and receiving corresponding state data returned by the named data network.
S3063, when receiving all state data without local state, reconstructing the local state tree based on the Hash transformation rule, and realizing data synchronization of the local state.
And if the state data corresponding to the child node is not found, the child node is used as a query index to initiate a state tree reconstruction request again.
As some optional embodiments, in S3063, the following steps a to b are included:
and a, determining a sub-node hash value corresponding to the sub-node based on the sub-node information.
And b, searching the node hash value in the local state, and if the corresponding node hash value is not searched, initiating a state data acquisition request to the named data network by taking the node hash value as a query index.
In S3061 to S3063, based on the hierarchical structure of the merkel tree, it is determined layer by layer whether the block link point locally stores the state data corresponding to each hierarchical child node, and if the corresponding state data does not exist locally, a state tree rebuilding request is initiated by the child node to obtain the corresponding state data, so that the block link point only needs to request the named data network for the locally nonexistent state data, thereby reducing the network traffic for transmitting all the state data, greatly reducing the load of the block link node, and improving the efficiency of the block link point in data synchronization.
In this embodiment, the state data is cached through the named data network, so that the network load of the blockchain real-time node caused by the fact that the blockchain real-time node receives data synchronization requests initiated by a plurality of blockchain nodes is avoided, and the stability of the blockchain network is ensured.
It should be understood that, the sequence numbers of the steps in the foregoing embodiments do not imply an execution sequence, and the execution sequence of each process should be determined by functions and internal logic of the process, and should not limit the implementation process of the embodiments of the present invention in any way.
In one embodiment, a data synchronization device for a blockchain node is provided, and the data synchronization device for the blockchain node corresponds to the data synchronization method for the blockchain nodes in the above embodiments one to one. As shown in fig. 3, the data synchronization apparatus of the blockchain node includes a blockchain node, and the blockchain node includes:
a real-time status obtaining module 51, configured to obtain a real-time status of the block chain, and determine a local status based on the real-time status;
a state synchronization request initiating module 52, configured to initiate a state synchronization request to the named data network if the determination result indicates that the local state is inconsistent with the real-time state;
a state tree rebuilding request module 53, configured to receive a world state tree root of a block chain fed back by the named data network based on the state synchronization request, and initiate a state tree rebuilding request to the named data network based on the world state tree root;
and a local state synchronization module 54, configured to receive state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and perform data synchronization on a local state according to a preset rule.
In some optional implementations of this embodiment, the real-time status obtaining module 51 includes the following units:
and the block broadcast acquisition unit is used for acquiring the block broadcast information of the block chain and determining the world state root of the newly generated block in the block chain according to the block broadcast information.
And the block number comparison unit is used for comparing the hash value of the world state root with the hash value of the local state root, and if the hash values of the world state root and the local state root are inconsistent, comparing the block number of the newly generated block with the block number of the local block.
And the state determining unit is used for determining that the local state lags behind the real-time state if the comparison result shows that the block number of the newly generated block is greater than the block number of the local block.
In some optional implementations of this embodiment, the state tree rebuilding request module 53 includes the following units:
and the state data comparison unit is used for acquiring corresponding block chain state data according to the world state tree root and comparing the block chain state data with the local state data. And the state tree reconstruction request initiating unit is used for initiating a state tree reconstruction request to the named data based on the block chain state data and requesting the sub-state data of the block chain state data if the comparison result shows that the block chain state data cannot be subjected to state data splicing with the local state data.
In some optional implementations of this embodiment, the local state synchronization module 54 includes the following units:
and the child node information receiving unit is used for receiving child node information which is fed back by the named data network and corresponds to the world state tree root.
And the state data receiving unit is used for initiating a state acquisition request based on the child node information and receiving corresponding state data fed back by the named data network.
And the state tree reconstruction unit is used for reconstructing the local state tree based on the Hash transformation rule when receiving the state data of which all the local states do not exist, so as to realize the data synchronization of the local states.
In some optional implementations of this embodiment, the state tree reconstruction unit includes the following sub-units:
and the hash value determining subunit is used for determining the hash value of the child node corresponding to the child node based on the child node information.
And the state data acquisition subunit is used for searching the node hash value in the local state, and if the corresponding node hash value is not searched, initiating a state data acquisition request to the named data network by taking the node hash value as a query index.
In one embodiment, a data synchronization device for a blockchain node is provided, and the data synchronization device for the blockchain node corresponds to the data synchronization method for the blockchain node in the above embodiments one to one. As shown in fig. 3, the data synchronization apparatus of the blockchain node includes a named data network node including:
And the state synchronization request module 61 is configured to receive a state synchronization request initiated by any node of the block chain, and feed back the world state tree root to the block chain node initiating the state synchronization request.
And a state data feedback module 62, configured to, when receiving a state tree reconstruction request initiated by any node of the block chain, perform local query based on the state tree reconstruction request, and feed back state data corresponding to the state tree reconstruction request to a block chain node that initiates the state tree reconstruction request.
In some optional implementations of the present embodiment, the state data feedback module 62 includes the following units:
and the cache query unit is used for querying the local cache component based on the state tree rebuilding request when receiving the state tree rebuilding request initiated by the block chain node.
And the state data feedback unit is used for feeding back the state data to the block link nodes if the state data corresponding to the state tree rebuilding request is cached.
And the interest packet initiating unit is used for sending the state data serving as the interest packet to the real-time block link node if the state data corresponding to the state tree rebuilding request is not cached.
Wherein the meaning of "first" and "second" in the above modules/units is only to distinguish different modules/units, and is not used to define which module/unit has higher priority or other defining meaning. Furthermore, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or modules is not necessarily limited to those steps or modules explicitly listed, but may include other steps or modules not explicitly listed or inherent to such process, method, article, or apparatus, and such that a division of modules presented in this application is merely a logical division and may be implemented in a practical application in a further manner.
For specific definition of the data synchronization apparatus of the blockchain node, reference may be made to the data synchronization method for the blockchain node in the foregoing, and the method is applied to definition of any node in the blockchain, and is not described herein again. The modules in the data synchronization apparatus of the above block chain node may be wholly or partially implemented by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, the internal structure of which may be as shown in fig. 4. The computer device includes a processor, a memory, a network interface, and a database connected by a system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing a data synchronization method of blockchain nodes, and the method is applied to data involved in any node in a blockchain. The network interface of the computer device is used for communicating with an external terminal through a network connection. The computer program is executed by a processor to implement the data synchronization method of the blockchain node as shown in fig. 2.
In one embodiment, a computer device is provided, which includes a memory, a processor and a computer program stored on the memory and running on the processor, and when the processor executes the computer program, the processor implements the steps of the data synchronization method of the block link point in the above embodiments, such as the steps S301 to S306 shown in fig. 2 and the extensions of other extensions and related steps of the method, or when the processor executes the computer program, the processor implements the functions of the modules/units of the data synchronization apparatus of the block link point in the above embodiments, such as the functions of the modules 51 to 54 shown in fig. 3, and the functions of the modules 61 to 62. To avoid repetition, further description is omitted here.
The Processor may be a Central Processing Unit (CPU), other general purpose Processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), an off-the-shelf Programmable Gate Array (FPGA) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component, etc. The general purpose processor may be a microprocessor or the processor may be any conventional processor or the like, the processor being the control center of the computer apparatus, various interfaces and lines connecting the various parts of the overall computer apparatus.
The memory may be used to store the computer programs and/or modules, and the processor may implement various functions of the computer device by running or executing the computer programs and/or modules stored in the memory and invoking data stored in the memory. The memory may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required by at least one function (such as a sound playing function, an image playing function, etc.), and the like; the storage data area may store data (such as audio data, video data, etc.) created according to the use of the cellular phone, etc.
The memory may be integrated in the processor or may be provided separately from the processor.
In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which when executed by a processor implements the steps of the data synchronization method of the block link points in the above-described embodiments, such as the steps S301 to S306 shown in fig. 2 and extensions of other extensions and related steps of the method. Alternatively, the computer program is executed by the processor to implement the functions of the modules/units of the data synchronization device of the block link point in the above-described embodiment, such as the functions of the modules 51 to 56 shown in fig. 3, and the functions of the modules 61 to 62. To avoid repetition, further description is omitted here.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, storage, database, or other medium used in the embodiments provided herein may include non-volatile and/or volatile memory, among others. Non-volatile memory can include read-only memory (ROM), Programmable ROM (PROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), or flash memory. Volatile memory can include Random Access Memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Link DRAM (SLDRAM), Rambus Direct RAM (RDRAM), direct bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-mentioned division of the functional units and modules is illustrated, and in practical applications, the above-mentioned function distribution may be performed by different functional units and modules according to needs, that is, the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-mentioned functions.
The above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; such modifications and substitutions do not substantially depart from the spirit and scope of the embodiments of the present invention, and are intended to be included within the scope of the present invention.

Claims (10)

1. A data synchronization method for blockchain nodes is characterized in that the method comprises the following steps executed by any blockchain node in a blockchain:
Acquiring a real-time state of a block chain, and judging a local state based on the real-time state;
if the judging result is that the local state is inconsistent with the real-time state, a state synchronization request is initiated to the named data network;
receiving a world state tree root of a block chain fed back by the named data network based on the state synchronization request, and initiating a state tree reconstruction request to the named data network based on the world state tree root;
and receiving the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and synchronizing the data of the local state according to a preset rule.
2. The method according to claim 1, wherein the step of acquiring a real-time status of the blockchain and determining a local status based on the real-time status comprises:
acquiring block broadcast information of a block chain, and determining a world state root of a newly generated block in the block chain according to the block broadcast information;
comparing the hash value of the world state root with the hash value of the local state root, and if the hash values of the world state root and the local state root are inconsistent, comparing the block number of the newly generated block with the block number of the local block;
And if the comparison result is that the block number of the newly generated block is larger than the block number of the local block, determining that the local state lags behind the real-time state.
3. The method for data synchronization of blockchain nodes according to claim 1, wherein the step of receiving a world state tree root of a blockchain fed back by the named data network based on the state synchronization request and initiating a state tree rebuild request based on the world state tree root comprises:
acquiring corresponding block chain state data according to the world state tree root, and comparing the block chain state data with local state data;
and if the comparison result shows that the block chain state data cannot be subjected to state data splicing with the local state data, initiating a state tree reconstruction request to the named data network based on the block chain state data, and requesting the sub-state data of the block chain state data.
4. The method according to claim 1, wherein the step of receiving the state data to be synchronized fed back by the named data network based on the state tree rebuilding request, and performing data synchronization on the local state according to a preset rule comprises:
Receiving child node information corresponding to the world state tree root fed back by the named data network;
initiating a state acquisition request based on the child node information, and receiving corresponding state data fed back by the named data network;
and when receiving state data of which all local states do not exist, reconstructing the local state tree based on the Hash transformation rule to realize data synchronization of the local states.
5. The method according to claim 4, wherein the step of initiating a status acquisition request based on the child node information and receiving corresponding status data fed back by the named data network comprises:
determining a sub-node hash value corresponding to the sub-node based on the sub-node information;
and searching the node hash value in a local state, and if the corresponding node hash value is not searched, initiating a state data acquisition request to the named data network by taking the node hash value as a query index.
6. A method for data synchronization of blockchain nodes, the method comprising the steps performed by a named data network node of:
when a state synchronization request initiated by any node of a block chain is received, feeding back a world state tree root to the block chain node point initiating the state synchronization request;
When a state tree rebuilding request initiated by any node of a block chain is received, locally inquiring based on the state tree rebuilding request to obtain state data corresponding to the state tree rebuilding request, taking the state data as to-be-synchronized state data, and feeding back the to-be-synchronized state data to a block chain node initiating the state tree rebuilding request.
7. The method for synchronizing data of block chain nodes according to claim 6, wherein the step of locally querying based on the state tree reestablishment request when receiving the state tree reestablishment request initiated by any node of the block chain to obtain the state data corresponding to the state tree reestablishment request, as the state data to be synchronized, comprises:
when a state tree reconstruction request initiated by a block chain node is received, querying in a local cache component based on the state tree reconstruction request to obtain a query result;
if the query result is that the state data corresponding to the state tree rebuilding request is cached in the local cache assembly, taking the state data corresponding to the state tree rebuilding request in the local cache assembly as the state data to be synchronized;
and if the query result is that the state data corresponding to the state tree rebuilding request is not cached in the local cache assembly, forwarding the state tree rebuilding request to a real-time block link node, and receiving the to-be-synchronized state data fed back by the real-time block link node.
8. A device for synchronizing data of a blockchain node, the device being a blockchain node, the blockchain node comprising:
the real-time state acquisition module is used for acquiring the real-time state of the block chain and judging the local state based on the real-time state;
the state synchronization request initiating module is used for initiating a state synchronization request to the named data network if the judging result shows that the local state is inconsistent with the real-time state;
the state tree reconstruction request module is used for receiving a world state tree root of a block chain fed back by the named data network based on the state synchronization request and initiating a state tree reconstruction request to the named data network based on the world state tree root;
and the local state synchronization module is used for receiving the state data to be synchronized fed back by the named data network based on the state tree rebuilding request and carrying out data synchronization on the local state according to a preset rule.
9. An apparatus for data synchronization of blockchain nodes, the apparatus being a named data network node comprising:
the state synchronization request receiving module is used for feeding back a world state tree root to a block chain link point initiating a state synchronization request when receiving the state synchronization request initiated by any node of a block chain;
And the state data feedback module is used for locally inquiring based on the state tree rebuilding request when receiving the state tree rebuilding request initiated by any node of the block chain, obtaining state data corresponding to the state tree rebuilding request as state data to be synchronized, and feeding back the state data to be synchronized to the block chain node initiating the state tree rebuilding request.
10. A computer-readable storage medium, in which a computer program is stored which, when being executed by a processor, carries out the steps of the data synchronization method of a blockchain node according to any one of claims 1 to 5 or which, when being executed by a processor, carries out the steps of the data synchronization method of a blockchain node according to any one of claims 6 to 7.
CN202110604013.XA 2021-05-31 2021-05-31 Data synchronization method and device of block chain nodes and storage medium Active CN113364847B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110604013.XA CN113364847B (en) 2021-05-31 2021-05-31 Data synchronization method and device of block chain nodes and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110604013.XA CN113364847B (en) 2021-05-31 2021-05-31 Data synchronization method and device of block chain nodes and storage medium

Publications (2)

Publication Number Publication Date
CN113364847A CN113364847A (en) 2021-09-07
CN113364847B true CN113364847B (en) 2022-07-19

Family

ID=77530535

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110604013.XA Active CN113364847B (en) 2021-05-31 2021-05-31 Data synchronization method and device of block chain nodes and storage medium

Country Status (1)

Country Link
CN (1) CN113364847B (en)

Families Citing this family (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111539829B (en) 2020-07-08 2020-12-29 支付宝(杭州)信息技术有限公司 To-be-filtered transaction identification method and device based on block chain all-in-one machine
CN111541784B (en) 2020-07-08 2021-07-20 支付宝(杭州)信息技术有限公司 Transaction processing method and device based on block chain all-in-one machine
CN111541789A (en) * 2020-07-08 2020-08-14 支付宝(杭州)信息技术有限公司 Data synchronization method and device based on block chain all-in-one machine
CN112492002B (en) 2020-07-08 2023-01-20 支付宝(杭州)信息技术有限公司 Transaction forwarding method and device based on block chain all-in-one machine
CN111541726B (en) 2020-07-08 2021-05-18 支付宝(杭州)信息技术有限公司 Replay transaction identification method and device based on block chain all-in-one machine
CN114218232B (en) * 2022-02-21 2022-05-24 浙商银行股份有限公司 Method and device for storing world state fragments based on increment barrel
CN114866567B (en) * 2022-05-26 2023-06-02 成都质数斯达克科技有限公司 Disaster-tolerant multi-level blockchain network block synchronization method and device
CN115052006B (en) * 2022-08-12 2022-11-18 佛山赛思禅科技有限公司 Data synchronization method and system based on leader node

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105207825A (en) * 2015-10-19 2015-12-30 上海斐讯数据通信技术有限公司 Fast synchronizing system and synchronizing method for network elements
CN110059089A (en) * 2019-03-27 2019-07-26 深圳前海达闼云端智能科技有限公司 Data synchronization method and device, storage medium and electronic equipment

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107317842B (en) * 2017-05-31 2019-11-22 北京大学深圳研究生院 Block chain synchronous method and device based on NDN
US10956444B2 (en) * 2019-07-31 2021-03-23 Advanced New Technologies Co., Ltd. Block chain state data synchronization method, apparatus, and electronic device
CN110493325B (en) * 2019-07-31 2020-12-29 创新先进技术有限公司 Block chain state data synchronization method and device and electronic equipment
CN110688377B (en) * 2019-08-30 2020-07-17 阿里巴巴集团控股有限公司 Method and device for updating state Merck tree
CN110737664B (en) * 2019-10-21 2022-11-25 深圳前海微众银行股份有限公司 Method and device for synchronizing block chain link points
CN110837505B (en) * 2019-11-06 2022-07-19 杭州复杂美科技有限公司 State data storage method, state data synchronization device and storage medium
CN112800050A (en) * 2019-11-13 2021-05-14 北京清红微谷技术开发有限责任公司 Transaction data storage method, system and device based on state tree and P2P network
CN110912707B (en) * 2019-11-22 2021-09-10 腾讯科技(深圳)有限公司 Block chain-based digital certificate processing method, device, equipment and storage medium
CN111209346B (en) * 2020-04-24 2020-07-28 腾讯科技(深圳)有限公司 Block chain data archiving method and device and computer readable storage medium
CN111651300B (en) * 2020-06-05 2023-03-21 成都质数斯达克科技有限公司 Block chain data recovery method, device, equipment and medium
CN112380209B (en) * 2020-10-29 2021-08-20 华东师范大学 Block chain multi-channel state data-oriented structure tree aggregation method

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105207825A (en) * 2015-10-19 2015-12-30 上海斐讯数据通信技术有限公司 Fast synchronizing system and synchronizing method for network elements
CN110059089A (en) * 2019-03-27 2019-07-26 深圳前海达闼云端智能科技有限公司 Data synchronization method and device, storage medium and electronic equipment

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
联盟区块链中成员动态权限管理方法的设计与实现;黄方蕾;《中国优秀硕士学位论文全文数据库信息科技辑》;20190115(第1期);全文 *

Also Published As

Publication number Publication date
CN113364847A (en) 2021-09-07

Similar Documents

Publication Publication Date Title
CN113364847B (en) Data synchronization method and device of block chain nodes and storage medium
US7076555B1 (en) System and method for transparent takeover of TCP connections between servers
EP2705645B1 (en) Name-based neighbor discovery and multi-hop service discovery in information-centric networks
EP2813060B1 (en) A method for collaborative caching for content-oriented networks
EP2086206A1 (en) System for operating a peer-to-peer network taking into account access network subscriber information
TWI536789B (en) Method of internet protocol (ip) management, system, client terminal and server thereof
EP2410770A1 (en) Method, user node and server for requesting position information of resource on network
WO2019170114A1 (en) Method for sending packet, network device, and computer-readable storage medium
CN102404387B (en) A kind of for carrying out the method for synchronizing information, device and equipment with other nodes
EP2612487B1 (en) Method and arrangement in a peer-to-peer network
CN101102250A (en) Distributed hashing mechanism for self-organizing networks
CN112055048B (en) P2P network communication method and system for high-throughput distributed account book
CN103457999A (en) P2P document transmission method based on NDN network architecture
US9407687B2 (en) Method, apparatus, and network system for acquiring content
US20220103476A1 (en) Network routing method and apparatus
CN110830601B (en) Distributed system NAT (network Address translation) penetration method, device, equipment and storage medium
WO2012065531A1 (en) Method, device, and system for implementing relay selection
CN112491717A (en) Service routing method and device
US20210368006A1 (en) Request response method, device, and system applied to bit torrent system
WO2022141021A1 (en) File storage method, apparatus, system and device
CN108989220B (en) Routing method and routing system
CN107370809A (en) Method of data synchronization and data search system
CN109525678A (en) Block chain network system and corresponding node device find method
CN107872538B (en) Service processing method, reverse proxy and service server for decoupling TCP long connection
US20200186463A1 (en) Method and system for name-based in-networking processing

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant