CN110737664B - Method and device for synchronizing block chain link points - Google Patents

Method and device for synchronizing block chain link points Download PDF

Info

Publication number
CN110737664B
CN110737664B CN201910999466.XA CN201910999466A CN110737664B CN 110737664 B CN110737664 B CN 110737664B CN 201910999466 A CN201910999466 A CN 201910999466A CN 110737664 B CN110737664 B CN 110737664B
Authority
CN
China
Prior art keywords
target
node
block height
block
contract account
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
CN201910999466.XA
Other languages
Chinese (zh)
Other versions
CN110737664A (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.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
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 WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN201910999466.XA priority Critical patent/CN110737664B/en
Publication of CN110737664A publication Critical patent/CN110737664A/en
Priority to PCT/CN2020/116439 priority patent/WO2021077962A1/en
Application granted granted Critical
Publication of CN110737664B publication Critical patent/CN110737664B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/22Indexing; Data structures therefor; Storage structures
    • G06F16/2228Indexing structures
    • G06F16/2255Hash tables
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/23Updating
    • G06F16/2365Ensuring data consistency and integrity
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor

Abstract

The invention discloses a method and a device for synchronizing block chain link points, wherein the method comprises the following steps: determining a plurality of first target nodes from a blockchain network; determining a target contract account from the system table entry according to the target block height; for each first target node, determining a target contract account requested by the first target node, generating a synchronous request and sending the synchronous request to the first target node; and the first target node determines the state data of the corresponding target contract account on the target block height and returns. The technical scheme is used for improving the efficiency of block synchronization.

Description

Method and device for synchronizing block chain link points
Technical Field
The embodiment of the invention relates to the field of financial technology (Fintech), in particular to a method and a device for synchronizing block link points.
Background
With the development of computer technology, more and more technologies (such as block chain, cloud computing or big data) are applied in the financial field, the traditional financial industry is gradually changing to the financial technology, the block chain technology is no exception, but due to the security and real-time requirements of the financial and payment industries, higher requirements are also put forward on the block chain technology.
When a new node is added in the block chain network, the newly added node can be used as a consensus node to participate in consensus after the state data of the existing node is correctly synchronized. In the prior art, a newly added node synchronizes a block from an existing node, executes a transaction in the block after verifying that the synchronized block is correct, and updates corresponding state data after verifying that a transaction result (modification of block chain state data by the transaction) conforms to expectation. In this way, since the newly added node is required to serially execute all transactions in all blocks from the creation block to update the status data, the block synchronization process takes a long time under the condition that the number of history blocks is large.
Disclosure of Invention
The embodiment of the invention provides a method and a device for synchronizing block link points, which are used for improving the efficiency of block synchronization.
The method for synchronizing the block chain link points provided by the embodiment of the invention comprises the following steps:
determining a plurality of first target nodes from a blockchain network; the state tree roots of all the first target nodes on the target block height are hashed identically; the target block height is determined according to the lowest block height in the current block heights of the first target nodes;
determining a target contract account from a system table entry according to the target block height; the block height when each contract account is created is recorded in the system table entry, and the block height when the target contract account is created is less than or equal to the target block height;
for each first target node, determining a target contract account requested by the first target node, generating a synchronization request and sending the synchronization request to the first target node; and the synchronization request is used for the first target node to determine and return the state data of the corresponding target contract account on the target block height.
In the technical scheme, when a newly added node is added into a block chain network, a target contract account needing state data synchronization is directly determined according to a system table entry instead of synchronizing a block and executing a transaction in the block from an existing node, and then the state data of the target contract account on the target block height is synchronized from each first target node (the state tree root hash of each first target node on the target block height is the same, and the correctness of the state data on each first target node is guaranteed), so that the synchronous data volume is small, and the transaction in the block does not need to be executed again. Furthermore, after the newly added node determines the target contract account needing to synchronize the state data according to the system table entry, the target contract account can be allocated to the plurality of first target nodes, so that the newly added node can synchronize the state data of the target contract account which are not repeated to the plurality of first target nodes at the same time, and the synchronization efficiency is high.
Optionally, after the determining, for each first target node, a target contract account requested from the first target node, generating a synchronization request, and sending the synchronization request to the first target node, the method further includes:
after receiving state data of the corresponding target contract account on the target block height returned by each of the plurality of first target nodes, calculating a second state tree root hash;
if the second state tree root hash is the same as the first state tree root hash, storing state data, on the target block height, of a corresponding target contract account returned by each first target node into a local database; wherein the first state tree root hash is a state tree root hash of each first target node above the target block height.
In the above technical scheme, after the newly added node receives the state data returned by each first target node, the hash value of the state data can be determined according to all the received state data, that is, the hash value of the state tree root corresponding to the target block height is determined, and whether the hash value is consistent with the hash value of the state tree root previously acquired from each first target node is determined, if yes, the acquired state data is determined to be correct data, and the state data can be stored in a disk-dropping manner, so that the synchronous operation of the state data under the target block height is completed.
Optionally, after the storing, in the local database, the state data of the corresponding target contract account returned by each first target node at the target block height, the method further includes:
determining a second target node of which the current block is higher than the target block from the block chain network;
acquiring a first block after the target block height from the second target node;
and executing the transaction in the first block, generating modified state data of the contract account, and updating the modified state data of the contract account into the local database.
In the above technical solution, after the newly added node completes the synchronization operation of the state data of the target block, the flow of synchronizing the subsequent blocks and executing the transaction of the newly added block may be further started, so as to synchronize the newly added block in the block chain network in the state data synchronization operation process, so as to complete the update of the state data corresponding to the newly added block, and realize that the state data of the newly added node is the same as that of other existing nodes, and the newly added node may participate in consensus as a new consensus node.
Optionally, the first target node includes a third target node; the synchronization request sent to the third target node is also used for the third target node to determine system state data and return the system state data.
In the technical scheme, the newly added node synchronizes the system state data and synchronizes the system configuration information in the block chain network, so that the synchronization of all the state data in the block chain network is completed.
Correspondingly, the embodiment of the invention also provides a device for synchronizing the block link points, which comprises:
a determining unit and a processing unit;
the determining unit is used for determining a plurality of first target nodes from the block chain network; the state tree roots of all the first target nodes on the target block height are hashed identically; the target block height is determined according to the lowest block height in the current block heights of the first target nodes;
the determining unit is further configured to determine a target contract account from the system table entry according to the target block height; the block height when each contract account is created is recorded in the system table entry, and the block height when the target contract account is created is less than or equal to the target block height;
the processing unit is used for determining a target contract account requested by each first target node, generating a synchronization request and sending the synchronization request to the first target node; and the synchronization request is used for the first target node to determine and return the state data of the corresponding target contract account on the target block height.
Optionally, the processing unit is further configured to:
after determining a target contract account requested by each first target node, generating a synchronization request and sending the synchronization request to the first target node, and after receiving state data, on the target block height, of the corresponding target contract account returned by each first target node in the plurality of first target nodes, calculating a second state tree root hash;
if the second state tree root hash is the same as the first state tree root hash, storing state data, on the target block height, of a corresponding target contract account returned by each first target node into a local database; wherein the first state tree root hash is a state tree root hash of each first target node above the target block height.
Optionally, the processing unit is further configured to:
after the state data of the corresponding target contract account returned by each first target node on the target block height are stored in a local database, determining a second target node with the current block height higher than the target block height from the block chain network;
acquiring a first block after the target block height from the second target node;
and executing the transaction in the first block, generating modified state data of the contract account, and updating the modified state data of the contract account into the local database.
Optionally, the first target node includes a third target node; the synchronization request sent to the third target node is also used for the third target node to determine system state data and return the system state data.
Correspondingly, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the method for synchronizing the block chain nodes according to the obtained program.
Accordingly, an embodiment of the present invention further provides a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is caused to execute the above method for synchronizing blockchain nodes.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments 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 to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of a system architecture according to an embodiment of the present invention;
fig. 2 is a schematic flowchart of a block link point synchronization method according to an embodiment of the present invention;
fig. 3 is a schematic flowchart of another method for synchronization of blockchain nodes according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of a block link point synchronization apparatus according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
For better explanation of the embodiments of the present invention, the terms or knowledge related to the embodiments of the present invention are described as follows:
classification of block chain state data
The state data of the block chain can be divided into two types, one type is system state data related to the whole state of the block chain, such as the contents of the block chain, such as the high current block, the high and low current block participating in the consensus node list, the block chain configuration (such as the maximum transaction quantity that each block can be packed), and the like; and the other type is contract account data, and the balance of the contract account, the hash of the contract code and the like are recorded. Where contract account data constitutes the vast majority of the state data, but all of the state data (including system state data and contract account data) needs to be synchronized.
Access restriction for blockchain database engine
The database engines mainly used by the current block chain comprise a levelDB and a rocksDB, both of which are NoSQL databases (non-relational databases), and the NoSQL databases are physically stored in a Key value pair mode and only provide a specified Key and traversal operation to obtain related record values. Therefore, if all the state data stored in the key value pair manner on the block chain needs to be acquired, the state data can be acquired only by serially traversing the database instance.
(III) Block chain status data verification scheme
The block chain needs to record the historical numerical Value of the state data, namely, the Value of the same Key under different block heights is recorded. For the state data of a specific block, the root hash (i.e. state tree root hash, stateRoot) of the MPT tree needs to be calculated, and the root hash of the MPT tree is also stored in the Header (Header) of the specific block. In the process of synchronizing the state data, whether the root hash of the MPT tree of the synchronized state data is consistent with the root hash in the block head acquired through other ways needs to be calculated again, and if so, the synchronized state data is correct.
An embodiment of the present invention provides a system architecture to which a method for synchronizing block link nodes is applied, and as shown in fig. 1, the system architecture may be a block link network, where the block link network includes a newly added node and an existing node, and when the newly added node is added to the block link network, the newly added node sends a request for synchronizing state data to the existing node and receives state data responded by the existing node, thereby completing synchronization of the state data.
In addition, the system architecture may further include a plurality of new joining nodes, and each new joining node may send a request for synchronizing the state data to the existing node and receive the state data returned by the existing node, thereby completing synchronization of the state data.
Based on the above description, fig. 2 exemplarily shows a flow of a method for block-link point synchronization according to an embodiment of the present invention, where the flow may be performed by a device for block-link point synchronization, and the device may newly join a node, and may be the newly joined node.
As shown in fig. 2, the process specifically includes:
in step 201, a plurality of first target nodes are determined from a blockchain network.
After a newly added node is added into a block chain network, synchronous operation is triggered, the newly added node acquires the number of existing nodes in the current block chain network and the current block height of each existing node, and determines a plurality of first target nodes for synchronous operation and target block heights, wherein the state tree roots of the first target nodes on the target block heights are the same in hash; the target block height is determined according to the lowest block height among the current block heights of the first target nodes. When determining the target block height according to the lowest block height among the current block heights of the first target nodes, the maximum value that is smaller than the lowest block height and is an integer multiple of a preset value may be taken, for example, if the lowest block height is 3430 and the preset value is 100, the maximum value that is smaller than 3430 and is an integer multiple of 100 is 3400. Alternatively, the lowest block height may be subtracted by a preset value, for example, if the lowest block height is 3430 and the preset value is 5, then the value obtained by subtracting 5 from 3430 is 3425. The preset values in the two modes can be determined empirically.
The number of the first target nodes may be determined according to a consensus algorithm and a total number of existing nodes in the blockchain network. Specifically, N existing nodes may be in a block chain network, and a newly added node determines k first target nodes from the N existing nodes according to different consensus algorithms, where when the consensus algorithm is PBFT (Practical Byzantine Fault Tolerance), the newly added node may determine k = (N-1)/3+1; when the consensus algorithm is POW (Proof of Work), the newly added node may determine k =50% × N +1. Taking PBFT as an example, when 10 existing nodes are included in the block chain network, the newly added node may determine 4 first target nodes.
In the process of determining k first target nodes by a newly added node, the newly added node may sort existing nodes from high to low according to the current block height of each existing node in a block chain network, determine a preset block height according to the current block height of the kth existing node (the preset block height is the same as the target block height determination mode), obtain the state tree root hash of each existing node on the preset block height in the first k existing nodes, and judge whether the k state tree root hashes are the same, if so, determine that the first k existing nodes are k first target nodes, and the preset block height is the target block height; otherwise, updating the preset block height according to the current block height of the k +1 th existing node, acquiring the state tree root hash of each existing node in the k +1 th existing node on the updated preset block height, judging whether k identical state tree root hashes exist, if so, taking the existing node corresponding to the k identical state tree root hashes as k first target nodes, and taking the updated preset block height as a target block height, otherwise, continuously updating the preset block height according to the current block height of the k +2 th existing node until the k identical state tree root hashes and the corresponding k existing nodes are determined, further determining the k existing nodes corresponding to the k identical state tree root hashes as the k first target nodes, and determining the corresponding preset block height as the target block height.
For example, there are four nodes A, B, C and D in the current block chain network, and the current block heights corresponding to A, B, C and D are 3430, 3320, 3450 and 3100, respectively, then there are: determining k =2 according to the PBFT, sorting the current block heights of A, B, C and D from high to low according to C, A, B, D, determining the first 2 existing nodes as C and a, taking the maximum value 3400 which is smaller than 3430 and is an integral multiple of 100 as a preset block height according to the current block height 3430 corresponding to the node a, and if it is determined that the state tree root hash of the node C on the block height 3400 is consistent with the state tree root hash of the node a on the block height 3400, indicating that C and a are correct nodes, taking C and a as two first target nodes, and the preset block height 3400 at this time is the target block height. If it is determined that the state tree root hash of the node C on the block height 3400 is inconsistent with the state tree root hash of the node a on the block height 3400, determining that one of the node a and the node C is an error node (a tampered node), acquiring a node B (a node next to the node a in the current block height sorting) according to a current block height 3320 corresponding to the node B, taking a maximum value 3300 which is smaller than 3320 and is an integral multiple of 100 as a preset block height, further determining whether the state tree root hash of the node B on the block height 3300 is consistent with the state tree root hash of the node a on the block height 3300 or consistent with the state tree root hash of the node C on the block height 3300, and if it is determined that the state tree root hash of the node B on the block height 3300 is consistent with the state tree root hash of the node a on the block height 3300, taking the node B and the node a as two first target nodes, and the preset block height 3300 is the target block height; if it is determined that the state tree root hash of B on the block height 3300 is consistent with the state tree root hash of node C on the block height 3300, node B and node C are taken as two first target nodes, and the preset block height 3300 is the target block height.
Step 202, a target contract account is determined from the system table entries based on the target block height.
Because the level DB or the RocksDB for storing the state data is physically stored in a key value pair mode, when the newly added node requests the state data from the existing node, the existing node can only read the corresponding state data in a traversal mode to return to the newly added node, and the efficiency of synchronizing the state data of the newly added node is low. In order to improve the efficiency of adding new node synchronization state data, the embodiment of the present invention provides a system table entry, where the system table entry is a list used for recording contract Account data, and as an example, as shown in table 1, a block height when each contract Account is created is recorded in the system table entry, for example, when a contract Account2 is created when the block height is 1, a contract Account890 is created when the block height is 3450.
TABLE 1
Contract account Block height
Account0 0
Account1 0
Account2 1
Account3 5
…… ……
Account798 3400
Account799 3400
Account800 3401
…… ……
Account890 3450
According to the system table entry, the new joining node can determine which contract accounts have been created before the target block height in the block chain network, and the new joining node can know which contract account status data should be synchronized from the block chain network. As in Table 1, if the target block height is determined to be 3400, then the contract accounts that have been created before the target block height 3400 and the target block height 3400 may be determined to have Account0 through Account799, i.e., the contract accounts Account0 through Account799 are target contract accounts.
Step 203, aiming at each first target node, determining a target contract account requested from the first target node, generating a synchronization request and sending the synchronization request to the first target node.
After determining the target contract Account, the newly joining node allocates the target contract Account to each first target node according to a preset rule, for example, it is determined that the contract accounts created before the target block height 3400 and the target block height 3400 have Account0 to Account799, and the contract accounts are divided by taking 500 as a data interval, then Account0 to Account499 may be allocated to the node a, account500 to Account799 may be allocated to the node C, then the newly joining node may synchronize the status data of Account0 to Account499 from the node a, and synchronize the status data of Account500 to Account799 from the node C.
The newly joining node generates a synchronization request aiming at each first target node, wherein each synchronization request comprises a target contract account and a target block height which are requested from the corresponding first target node. Specifically, any one of the first target nodes may be used to illustrate that the newly joining node determines a target contract account requested by the first target node, generates a synchronization request corresponding to the first target node, and sends the synchronization request to the first target node, where the synchronization request corresponding to the first target node is used by the first target node to determine state data of the target contract account corresponding to the first target node on a target block height, and returns the state data to the newly joining node. Continuing with the foregoing example as an example, the newly joining node generates a synchronization request sent to node a, where the synchronization request includes Account0 to Account499 as target contract accounts and 3400 as target block height; similarly, the newly joining node generates a synchronization request sent to the node C, where the synchronization request includes target contract accounts of Account500 to Account799, and a target block height of 3400.
In another aspect, after the first target node acquires the synchronization request, the first target node determines the status data according to the target contract Account and the target block height in the synchronization request, for example, if the synchronization request received by the node C includes that the target contract Account is Account500 and the target block height is 3400, the node C determines the status data of Account500 on the target block height 3400, and returns the status data to the newly added node.
In the above embodiment, when a newly added node is added to the blockchain network, instead of synchronizing a block from an existing node and executing a transaction in the block, a target contract account requiring state data synchronization is directly determined according to a system table entry, and then state data of the target contract account on a target block height is synchronized from each first target node (the state tree root hashes of the first target nodes on the target block height are the same, so that the correctness of the state data on the first target nodes is ensured), so that the amount of the synchronized data is small, and the transaction in the block does not need to be executed again. Furthermore, after the newly added node determines the target contract account needing to synchronize the state data according to the system table entry, the target contract account can be allocated to the first target nodes, so that the newly added node can synchronize the state data of the target contract account with the first target nodes without repeating the state data of the target contract account, and the synchronization efficiency is high.
After the newly joining node sends the synchronization request corresponding to each first target node, the newly joining node can also receive the state data of the corresponding target contract account returned by each first target node on the target block height, and after the state data returned by all the first target nodes are determined to be received completely, whether the received state data is correct state data is judged. In specific implementation, a newly added node constructs complete state data, and further calculates the state tree root hash of the complete state data, i.e., the second state tree root hash. After the second state tree root hash is calculated, the second state tree root hash is compared with the first state tree root hash, wherein the first state tree root hash refers to the state tree root hash of each first target node on the target block height, if the first state tree root hash and the first state tree root hash are consistent, the state data synchronized by the newly added node is correct, and the newly added node can store the state data of the corresponding target contract account returned by each first target node on the target block height into a local database, so that the synchronization operation of the state data on the target block height is completed. Of course, if the two are not consistent, the status data synchronized by the newly added node is wrong, and corresponding measures need to be taken.
Continuing to explain by taking the foregoing example as an example, after the newly added node acquires the state data returned by the node a and the node C, the newly added node analyzes and constructs complete state data and calculates the hash of the state tree root, and after the verification is passed, the constructed state data is subjected to disk-dropping storage, and the data state of the node itself at height of 3400 blocks is established. At this time, the data state of the newly added node at 3400 block height is equivalent to the data state of the founder block of the newly added node.
In the above embodiment, after the newly added node receives the state data returned by each first target node, the hash value of the state data may be determined according to all the received state data, that is, the hash value of the state tree root corresponding to the target block height is determined, and it is determined whether the hash value is consistent with the hash value of the state tree root previously obtained from each first target node, if yes, the obtained state data is determined to be correct data, and the disk-dropping storage may be performed, so that the synchronization operation of the state data under the target block height is completed.
And the newly added node stores the state data of the corresponding target contract account on the target block height returned by each first target node into a local database, namely the newly added node completes the synchronous operation of the state data on the target block height, and further, the newly added node starts a process of synchronizing subsequent blocks and executing newly added block transaction for updating the state data of the newly added blocks to the latest state. Specifically, the newly added node determines a second target node that the current block is higher than the target block from the block chain network, acquires the first block after the target block is high from the second target node, executes the transaction in the first block, generates the modified status data of the contract account, and updates the modified status data of the contract account to the local database. Here, the second target node may be at least one, and the newly added node may determine, when determining the second target node, at least one existing node having a current block height greater than the target block height from the block chain network as the second target node, and for example, after the newly added node completes the synchronization operation of the target block height upper state data, the newly added node determines that the current block heights of the nodes A, B, C in the block chain network are all higher than the target block height 3400, and then may determine all the nodes A, B, C as the second target node.
And when the block height of the newly added node is consistent with the highest block height of the existing node, the newly added node is indicated to finish the synchronous operation of the state data of other consensus nodes in the synchronous block chain network and can be used as a new consensus node to participate in consensus. Continuing with the previous example, during the synchronization of the status data on the target block height for the newly added node, the blockchain network continues to block out until the block height of 3455 is reached. After the data state of the newly added node under the block height of 3400 is established, synchronizing blocks of 3401-3455 to the node A, B, C with the current block height higher than 3400 in the block chain network until the block height of the newly added node is consistent with the highest block height of the existing node in the block chain network.
In the above embodiment, after completing the synchronization operation of the state data of the target block, the newly added node may further start the processes of synchronizing the subsequent blocks and executing the transaction of the newly added block, so as to synchronize the newly added block in the block chain network in the state data synchronization operation process, so as to complete the update of the state data corresponding to the newly added block, and implement that the state data of the newly added node is the same as that of other existing nodes, and may participate in consensus as a new consensus node.
In the embodiment of the invention, a newly added node not only needs to synchronize the state data of a contract account, but also needs to synchronize system state data, the newly added node can synchronize the system state data to any one of the first target nodes, the first target node is taken as a third target node, a synchronization request sent by the newly added node to the third target node is also used for the third target node to determine the system state data, the synchronization request can also comprise an identifier of the system state data, and the third target node determines account data of the corresponding contract account on the target block height and determines the system state data according to the received synchronization request and returns the account data to the newly added node. In the above example, the system state data may be distributed to the node C, that is, the newly added node acquires the system state data from the node C. Of course, a third target node may also be determined in the first target node, and is dedicated to the newly added node to obtain the system state data, which is not limited herein. And synchronizing the system state data by the newly added node, and synchronizing the system configuration information in the block chain network, thereby completing the synchronization of all the state data in the block chain network.
In the synchronization process, a newly added node may be used as an execution subject for executing the process, or may be a third party node, where the third party node is used as an intermediate node for interaction between the newly added node and an existing node in the blockchain network, for example, after the third party node determines the newly added node in the blockchain network, it may determine multiple first target nodes from the current blockchain network, determine a target contract account from the system table entry according to the target block height, determine a target contract account requested for each first target node, generate a synchronization request corresponding to each first target node, and send the synchronization request to each first target node. After receiving state data, on the target block height, of a corresponding target contract account returned by each first target node in the plurality of first target nodes, calculating a second state tree root hash; and if the second state tree root hash is the same as the first state tree root hash, sending the state data of the corresponding target contract account returned by each first target node on the target block height to the newly added node so as to enable the newly added node to be stored locally. Other steps are similar and are not described in detail.
The embodiment of the present invention further provides another flow of a method for synchronizing a blockchain node, for example, as shown in fig. 3, a specific flow is as follows, where an execution subject has a newly added node and a first target node.
Step 301, a newly added node determines a target node list and a target block height for pulling state data;
the target node list includes a plurality of first target nodes determined by the newly added node.
Step 302, dividing the state data of the target block height by the newly added node, and distributing the state data to the corresponding first target node;
step 303, the newly added node generates a synchronization request of state data for each first target node;
step 304, the newly added node sends the synchronization request to the corresponding first target node;
305, the first target node generates a response data packet recorded with state data corresponding to the synchronization request according to the received synchronization request;
step 306, the first target node sends the response data packet to the newly joining node;
step 307, the newly added node analyzes the response data packet to generate state data, and the state data is stored in a disk after the verification is passed;
step 308, after the newly added node completes the synchronization of the historical state data, the synchronization process of the subsequent blocks is started.
Based on the same inventive concept, fig. 4 exemplarily shows the structure of a block link point synchronization apparatus provided in an embodiment of the present invention, and the apparatus can perform the flow of the block link point synchronization method.
The device includes:
a determination unit 401 and a processing unit 402;
the determining unit 401 is configured to determine a plurality of first target nodes from a blockchain network; the state tree roots of all the first target nodes on the target block height are hashed identically; the target block height is determined according to the lowest block height in the current block heights of the first target nodes;
the determining unit 401 is further configured to determine a target contract account from system table entries according to the target block height; the block height when each contract account is created is recorded in the system table entry, and the block height when the target contract account is created is less than or equal to the target block height;
the processing unit 402 is configured to, for each first target node, determine a target contract account requested from the first target node, generate a synchronization request, and send the synchronization request to the first target node; and the synchronization request is used for the first target node to determine and return the state data of the corresponding target contract account on the target block height.
Optionally, the processing unit 402 is further configured to:
after the target contract account requested by each first target node is determined, a synchronization request is generated and sent to the first target node, and after state data of the corresponding target contract account on the target block height returned by each first target node in the plurality of first target nodes is received, a second state tree root hash is calculated;
if the second state tree root hash is the same as the first state tree root hash, storing state data of the corresponding target contract account returned by each first target node on the target block height into a local database; wherein the first state tree root hash is a state tree root hash of each first target node above the target block height.
Optionally, the processing unit 402 is further configured to:
after the state data of the corresponding target contract account returned by each first target node on the target block height are stored in a local database, determining a second target node with the current block height higher than the target block height from the block chain network;
acquiring a first block after the target block height from the second target node;
and executing the transaction in the first block, generating modified state data of the contract account, and updating the modified state data of the contract account into the local database.
Optionally, the first target node includes a third target node; the synchronization request sent to the third target node is also used for the third target node to determine system state data and return the system state data.
Based on the same inventive concept, an embodiment of the present invention further provides a computing device, including:
a memory for storing program instructions;
and the processor is used for calling the program instruction stored in the memory and executing the method for synchronizing the block chain nodes according to the obtained program.
Based on the same inventive concept, embodiments of the present invention further provide a computer-readable non-volatile storage medium, which includes computer-readable instructions, and when the computer reads and executes the computer-readable instructions, the computer is caused to execute the above method for synchronizing blockchain nodes.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method of block link point synchronization, comprising:
acquiring a plurality of existing nodes from a block chain network;
sequencing the existing nodes according to the sequence of the current block from high to low;
selecting the first k existing nodes with the same hash of the state tree root on the target block height in the sequence as k first target nodes, wherein the target block height is determined according to the current block height of the kth existing node in the first k existing nodes, and k is a positive integer;
determining a target contract account from a system table entry according to the target block height; the block height when each contract account is created is recorded in the system table entry, and the block height when the target contract account is created is less than or equal to the target block height;
for each first target node, determining a target contract account requested from the first target node, generating a synchronization request and sending the synchronization request to the first target node; and the synchronization request is used for the first target node to determine and return the state data of the corresponding target contract account on the target block height.
2. The method of claim 1, wherein after determining, for each first target node, a target contract account to request from the first target node, generating and sending a synchronization request to the first target node, further comprising:
after receiving state data, on the target block height, of a corresponding target contract account returned by each of the k first target nodes, calculating a second state tree root hash;
if the second state tree root hash is the same as the first state tree root hash, storing state data, on the target block height, of a corresponding target contract account returned by each first target node into a local database; wherein the first state tree root hash is a state tree root hash of each first target node above the target block height.
3. The method as recited in claim 2, further comprising, after said storing the state data of the corresponding target contract account returned by each first target node at the target block height in a local database:
determining a second target node of which the current block is higher than the target block from the block chain network;
acquiring a first block after the target block height from the second target node;
and executing the transaction in the first block, generating modified state data of the contract account, and updating the modified state data of the contract account into the local database.
4. The method of claim 1, wherein the first target node comprises a third target node; the synchronization request sent to the third target node is also used for the third target node to determine system state data and return the system state data.
5. A block link point synchronization apparatus, comprising:
a determining unit and a processing unit;
the determining unit is used for acquiring a plurality of existing nodes from the block chain network; sequencing the existing nodes according to the sequence of the current block from high to low; selecting the first k existing nodes with the same hash of the state tree root on the target block height in the sequence as k first target nodes, wherein the target block height is determined according to the current block height of the kth existing node in the first k existing nodes, and k is a positive integer;
the determining unit is further configured to determine a target contract account from the system table entry according to the target block height; the block height when each contract account is created is recorded in the system table entry, and the block height when the target contract account is created is less than or equal to the target block height;
the processing unit is used for determining a target contract account requested by each first target node, generating a synchronization request and sending the synchronization request to the first target node; and the synchronization request is used for the first target node to determine and return the state data of the corresponding target contract account on the target block height.
6. The apparatus as recited in claim 5, said processing unit to further:
after the target contract account requested by each first target node is determined, a synchronization request is generated and sent to the first target node, and after state data of the corresponding target contract account on the target block height returned by each first target node in the k first target nodes is received, a second state tree root hash is calculated;
if the second state tree root hash is the same as the first state tree root hash, storing state data, on the target block height, of a corresponding target contract account returned by each first target node into a local database; wherein the first state tree root hash is a state tree root hash of each first target node above the target block height.
7. The apparatus as recited in claim 6, said processing unit to further:
after the state data of the corresponding target contract account returned by each first target node on the target block height are stored in a local database, determining a second target node with the current block height higher than the target block height from the block chain network;
acquiring a first block after the target block height from the second target node;
and executing the transaction in the first block, generating modified state data of the contract account, and updating the modified state data of the contract account into the local database.
8. The apparatus of claim 5, wherein the first target node comprises a third target node; the synchronization request sent to the third target node is also used for the third target node to determine system state data and return the system state data.
9. A computing device, comprising:
a memory for storing program instructions;
a processor for calling program instructions stored in said memory to execute the method of any one of claims 1 to 4 in accordance with the obtained program.
10. A computer-readable non-transitory storage medium including computer-readable instructions which, when read and executed by a computer, cause the computer to perform the method of any one of claims 1 to 4.
CN201910999466.XA 2019-10-21 2019-10-21 Method and device for synchronizing block chain link points Active CN110737664B (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201910999466.XA CN110737664B (en) 2019-10-21 2019-10-21 Method and device for synchronizing block chain link points
PCT/CN2020/116439 WO2021077962A1 (en) 2019-10-21 2020-09-21 Method and apparatus for blockchain node synchronization

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910999466.XA CN110737664B (en) 2019-10-21 2019-10-21 Method and device for synchronizing block chain link points

Publications (2)

Publication Number Publication Date
CN110737664A CN110737664A (en) 2020-01-31
CN110737664B true CN110737664B (en) 2022-11-25

Family

ID=69270322

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910999466.XA Active CN110737664B (en) 2019-10-21 2019-10-21 Method and device for synchronizing block chain link points

Country Status (2)

Country Link
CN (1) CN110737664B (en)
WO (1) WO2021077962A1 (en)

Families Citing this family (15)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110059089B (en) * 2019-03-27 2021-01-22 深圳前海达闼云端智能科技有限公司 Data synchronization method and device, storage medium and electronic equipment
CN110737664B (en) * 2019-10-21 2022-11-25 深圳前海微众银行股份有限公司 Method and device for synchronizing block chain link points
CN111432009B (en) * 2020-03-30 2023-04-07 深圳壹账通智能科技有限公司 Method and device for synchronizing block chain data, electronic equipment and storage medium
CN111630830B (en) * 2020-04-15 2023-07-04 支付宝(杭州)信息技术有限公司 Distributed blockchain data storage under account model
EP3844642A4 (en) 2020-04-20 2021-08-25 Alipay (Hangzhou) Information Technology Co., Ltd. Distributed blockchain data storage under account model
CN111949634A (en) * 2020-08-07 2020-11-17 广州科创空间信息科技有限公司 Method for synchronously migrating block chain data
CN113079081B (en) 2020-09-25 2022-08-02 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934996B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111935315B (en) * 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Block synchronization method and device
CN111935314B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Block chain system, message transmission method and device
CN113079079B (en) 2020-09-25 2022-08-02 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111935000B (en) 2020-09-25 2021-01-08 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934997B (en) 2020-09-25 2021-01-12 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN111934998B (en) 2020-09-25 2021-02-09 支付宝(杭州)信息技术有限公司 Message transmission method and device
CN113364847B (en) * 2021-05-31 2022-07-19 新疆大学 Data synchronization method and device of block chain nodes and storage medium

Family Cites Families (14)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
KR101930825B1 (en) * 2017-01-23 2018-12-19 주식회사 데일리인텔리전스 System and method for authenticating users and synchronizing blocks using a block-chain network
CN107103054B (en) * 2017-04-12 2019-03-26 北京航空航天大学 A kind of intelligent contract asynchronous execution storage system and implementation method of privately owned block chain
US10255342B2 (en) * 2017-04-12 2019-04-09 Vijay K. Madisetti Method and system for tuning blockchain scalability, decentralization, and security for fast and low-cost payment and transaction processing
CN107332876B (en) * 2017-05-31 2020-05-08 深圳前海微众银行股份有限公司 Method and device for synchronizing block chain state
GB2572627A (en) * 2018-04-05 2019-10-09 Electroneum Ltd Hybrid blockchain transaction system
CN110400142B (en) * 2018-06-01 2021-06-25 腾讯科技(深圳)有限公司 Data processing method, device and storage medium
CN109325039A (en) * 2018-06-07 2019-02-12 海南新软软件有限公司 A kind of block chain browser and block chain information browsing method
CN109086325A (en) * 2018-06-29 2018-12-25 阿里巴巴集团控股有限公司 Data processing method and device based on block chain
CN109063109A (en) * 2018-07-27 2018-12-21 电子科技大学 A kind of data query system based on ether mill
CN109522362B (en) * 2018-10-17 2020-09-15 北京瑞卓喜投科技发展有限公司 Incomplete data synchronization method, system and equipment based on block chain data
CN109587263B (en) * 2018-12-20 2021-08-03 众安信息技术服务有限公司 Block synchronization method and system
CN109714412B (en) * 2018-12-25 2021-08-10 深圳前海微众银行股份有限公司 Block synchronization method, device, equipment and computer readable storage medium
CN110113408B (en) * 2019-04-30 2020-08-14 杭州复杂美科技有限公司 Block synchronization method, equipment and storage medium
CN110737664B (en) * 2019-10-21 2022-11-25 深圳前海微众银行股份有限公司 Method and device for synchronizing block chain link points

Also Published As

Publication number Publication date
WO2021077962A1 (en) 2021-04-29
CN110737664A (en) 2020-01-31

Similar Documents

Publication Publication Date Title
CN110737664B (en) Method and device for synchronizing block chain link points
CN110602148B (en) Method and device for generating state tree of block and verifying data on chain
EP3678346B1 (en) Blockchain smart contract verification method and apparatus, and storage medium
CN109034809B (en) Block chain generation method and device, block chain node and storage medium
CN110493148B (en) Block processing, block consensus and block synchronization method and device
CN110471923B (en) Processing method and device for blockchain transaction records
CN110517141B (en) Consensus method and device based on block chain system
CN107679863B (en) Block chain system and method for quickly verifying block
CN111008201A (en) Method and apparatus for parallel modification and reading of state trees
CN110597835B (en) Transaction data deleting method and device based on blockchain
CN109063005B (en) Data migration method and system, storage medium and electronic device
CN110187831B (en) Block data storage system and method of block chain alliance chain
WO2021036260A1 (en) Method and apparatus for concurrently executing transactions in blockchain
CN112383610A (en) Synchronous processing method and system for block chain state data
CN114529415A (en) Transaction verification method and device based on block chain and electronic equipment
CN111522811A (en) Database processing method and device, storage medium and terminal
CN112187765B (en) Method and device for selecting target node in block chain
CN110706108B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN113411373A (en) Transaction data storage method, tracking and tracing method and block chain network
CN110825758B (en) Transaction processing method and device
CN114266665A (en) Contract multi-backbone cross-link method, device and storage medium
CN113434599A (en) Block chain account book synchronization method and device based on half nodes
CN112162760A (en) Block consensus transformation method and device
CN111161064A (en) Processing method and device for blockchain transaction records
CN112532713A (en) Block chain anti-bifurcation detection method and device

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