A node synchronization method and device for blockchain

By generating a state snapshot of the block and transmitting the ledger result information, the problem of low synchronization efficiency of new nodes in the blockchain network is solved, and a more efficient node synchronization process is achieved.

CN114116896BActive Publication Date: 2025-03-25WEBANK (CHINA)
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202111369356.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-15
Publication Date
2025-03-25
Estimated Expiration
2041-11-15

AI Technical Summary

Technical Problem

In the prior art, new nodes in blockchain networks are less efficient when synchronizing block data, especially when the amount of data is large.

Method used

By generating a state snapshot of the block, the ledger result information is directly transmitted to the node to be joined, rather than transmitting the complete block data. The data amount of the status snapshot is smaller than the data amount of the block data, and the ledger result information of each account during block generation can be accurately transmitted.

Benefits of technology

It improves the synchronization efficiency of new nodes, reduces the amount of data transmission, and reduces resource consumption during synchronization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114116896B_ABST
    Figure CN114116896B_ABST
Patent Text Reader

Abstract

The present invention discloses a node synchronization method and device of a blockchain, wherein the method is as follows: a joined node of the blockchain obtains a synchronization request from a node to be joined, the synchronization request indicates at least one block to be synchronized; the joined node generates a state snapshot of at least one block, wherein the state snapshot of the first block is used to obtain the account book result information of each account when the first block is generated, the joined node sends the state snapshot of at least one block to the node to be joined, and the state snapshot of at least one block is used for the node to be joined to synchronize the account book result information of each account when at least one block is generated. When the above method is applied to financial technology (Fintech), the node to be joined can maintain the same account book result information as at least one block without obtaining the block data of at least one specific block, thereby improving the synchronization efficiency of the node to be joined.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain in the field of financial technology (Fintech), and in particular to a node synchronization method and device of blockchain. Background Art

[0002] With the development of computer technology, more and more technologies are applied in the financial field. The traditional financial industry is gradually transforming to financial technology (Fintech). However, due to the security and real-time requirements of the financial industry, higher requirements are also placed on technology. At present, based on the immutability of blockchain, transactions are often conducted through blockchain in the field of financial technology.

[0003] New nodes may be added to the blockchain network, and they can only be successfully added after being synchronized with the blockchain network. In the current method, since all blockchain nodes in the blockchain network store the same block data, when a new node needs to join the blockchain network, it will synchronize all existing block data in the blockchain network until the block data of the new node is consistent with all existing block data in the blockchain network before it can join the consensus of the blockchain network. However, when the new node needs to synchronize more blocks, the amount of block data is large, resulting in low node synchronization efficiency, which is a problem that needs to be solved urgently. Summary of the invention

[0004] The present invention provides a node synchronization method and device for a blockchain, which solves the problem of low node synchronization efficiency in the prior art.

[0005] In a first aspect, the present invention provides a node synchronization method of a blockchain, comprising:

[0006] The joined node of the blockchain obtains a synchronization request from the to-be-joined node, wherein the synchronization request indicates at least one block to be synchronized;

[0007] The joined node generates a state snapshot of the at least one block, wherein the state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0008] The joined node sends the state snapshot of the at least one block to the node to be joined, and the state snapshot of the at least one block is used by the node to be joined to synchronize the ledger result information of each account when the at least one block is generated.

[0009] In the above manner, after the joined node of the blockchain obtains the synchronization request from the node to be joined, it does not directly send the block data of at least one block to the node to be joined, but generates a state snapshot of the at least one block. For any block in the at least one block, the state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, so that there is no need to transmit specific transaction data in the block, and the state snapshot that can obtain the ledger result information of the at least one block can be directly transmitted, and the state snapshot of the at least one block with a smaller data volume is sent to the node to be joined, so that the node to be joined can synchronize the ledger result information of each account when the at least one block is generated, so that the node to be joined can maintain the same ledger result information as the at least one block without obtaining the specific block data of the at least one block, thereby improving the synchronization efficiency of the node to be joined.

[0010] Optionally, the state snapshot of the first account in the first block is specifically the ledger result information of the first account when the first block is generated.

[0011] Optionally, the joined node generates a state snapshot of the at least one block, including:

[0012] The joined node obtains a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated;

[0013] The joined node obtains a status snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first status snapshot.

[0014] In the above method, since the joined node obtains the state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot, the ledger result information of each account starting from the synchronization can be indicated and verified according to the first state snapshot, so that the state snapshot of the at least one block can be made more accurate.

[0015] Optionally, the data format of the first state snapshot is a first state vector, and the joined node obtains the state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot, including:

[0016] For the first block in the at least one block, the joined node obtains the transaction modification vector of each account in the first block according to the ledger result information of each account in the first block and the predecessor state vector of the first block; obtains the state vector of the first block according to the transaction modification vector of each account in the first block and the predecessor state vector of the first block; wherein, if the first block is the first block of the at least one block, the predecessor state vector of the first block is the first state vector, and if the first block is not the first block of the at least one block, the predecessor state vector of the first block is the state vector of the previous block of the first block;

[0017] The joined node obtains a state matrix according to the first state vector and the state vector of the at least one block as a state snapshot of the at least one block.

[0018] In the above manner, by introducing the vector, a simpler and more structured mapping relationship can be established with the ledger result information of each account, thereby improving the traceability of the ledger result information of each account during the synchronization process, and making the state snapshot of the at least one block more reliable and simple.

[0019] Optionally, the joined node sends the state snapshot of the at least one block to the node to be joined, including:

[0020] The joined node merges the state snapshot of the at least one block into a state block; the joined node sends the state block to the node to be joined.

[0021] In the above manner, the joined node merges the status snapshot of the at least one block into one status block, so that the status snapshot of the at least one block is included in only one status block and sent to the node to be joined, thereby reducing the number of blocks and further improving the synchronization efficiency.

[0022] Optionally, the synchronization request includes the block height of the block that the node to be added has synchronized and the number of blocks that the node to be added needs to synchronize this time.

[0023] In the above manner, since the block height of the synchronized blocks and the data volume of the number of blocks that the node to be added needs to synchronize this time are relatively small and can accurately indicate at least one block, the node synchronization efficiency is further improved.

[0024] In a second aspect, the present invention provides a node synchronization method of a blockchain, comprising:

[0025] The node to be joined sends a synchronization request to the joined node of the blockchain, wherein the synchronization request indicates at least one block to be synchronized;

[0026] The node to be joined obtains a state snapshot of at least one block from the joined node, wherein the state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0027] The node to be joined synchronizes the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block.

[0028] Optionally, the node to be joined synchronizes the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block, including:

[0029] For the first account of the first block in the at least one block, the node to be joined modifies the account value of the first account in the node to be joined according to the ledger result information of the first account when the first block is generated.

[0030] In a third aspect, the present invention provides a node synchronization device for a blockchain, comprising:

[0031] An acquisition module, configured to acquire a synchronization request from a node to be added, wherein the synchronization request indicates at least one block to be synchronized;

[0032] A processing module, configured to generate a state snapshot of the at least one block, wherein the state snapshot of a first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0033] And used to send the state snapshot of the at least one block to the node to be added, and the state snapshot of the at least one block is used by the node to be added to synchronize the ledger result information of each account when the at least one block is generated.

[0034] Optionally, the processing module is specifically used to: obtain a first status snapshot, where the first status snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; and obtain the status snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first status snapshot.

[0035] Optionally, the data format of the first state snapshot is a first state vector, and the processing module is specifically used to: for the first block in the at least one block, obtain the transaction modification vector of each account in the first block according to the ledger result information of each account in the first block and the predecessor state vector of the first block; obtain the state vector of the first block according to the transaction modification vector of each account in the first block and the predecessor state vector of the first block; wherein, if the first block is the first block of the at least one block, the predecessor state vector of the first block is the first state vector, and if the first block is not the first block of the at least one block, the predecessor state vector of the first block is the state vector of the previous block of the first block; obtain a state matrix according to the first state vector and the state vector of the at least one block as the state snapshot of the at least one block.

[0036] Optionally, the processing module is specifically used to: merge the status snapshots of the at least one block into a status block; and send the status block to the node to be added.

[0037] Optionally, the synchronization request includes the block height of the block that the node to be added has synchronized and the number of blocks that the node to be added needs to synchronize this time.

[0038] In a fourth aspect, the present invention provides a node synchronization device for a blockchain, comprising:

[0039] A transmission module, configured to send a synchronization request to a joined node of the blockchain, wherein the synchronization request indicates at least one block to be synchronized; obtain a state snapshot of at least one block from the joined node, wherein the state snapshot of a first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0040] The processing module is used to synchronize the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block.

[0041] Optionally, the processing module is specifically used for:

[0042] For the first account of the first block in the at least one block, modify the account value of the first account in the node to be added according to the ledger result information of the first account when the first block is generated.

[0043] In a fifth aspect, the present invention provides a computer device, including a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect or second aspect and each optional method.

[0044] In a sixth aspect, the present invention provides a storage medium, including a program or an instruction, which, when executed, is used to execute the above-mentioned first aspect or second aspect and each optional method.

[0045] The beneficial effects of the above-mentioned second to sixth aspects and each optional implementation method can refer to the beneficial effects of the above-mentioned first aspect and each optional method of the first aspect, and will not be repeated here.

[0046] These and other aspects of the present invention will become more apparent from the following description of the embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0048] Figure 1 A flowchart corresponding to a node synchronization method of a blockchain provided by an embodiment of the present invention;

[0049] Figure 2 A schematic diagram of the structure of a node synchronization device for a blockchain provided by an embodiment of the present invention;

[0050] Figure 3 A schematic diagram of the structure of a node synchronization device for a blockchain provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0052] When a financial institution (bank, insurance or securities institution) is operating a business (such as a bank's loan business, deposit business, etc.), a new node may join the blockchain network, and the new node can only join successfully after being synchronized with the blockchain network. In the prior art, when a new node needs to join the blockchain network, it will synchronize all the existing block data in the blockchain network until the block data of the new node is consistent with all the existing block data in the blockchain network before it can join the consensus of the blockchain network. However, this situation does not meet the needs of financial institutions such as banks and cannot guarantee the efficient operation of various businesses of financial institutions.

[0053] For this reason, Figure 1 As shown, the present invention provides a node synchronization method for a blockchain.

[0054] Step 101: The joined node of the blockchain obtains a synchronization request from the node to be joined.

[0055] Step 102: The joined node generates a status snapshot of the at least one block.

[0056] Step 103: The joined node sends the state snapshot of the at least one block to the node to be joined.

[0057] In step 101 to step 103, the synchronization request indicates at least one block to be synchronized. There are multiple specific indication methods. For example, the synchronization request includes the block height of the block that has been synchronized by the node to be added and the number of blocks that the node to be added needs to synchronize this time, so as to indicate which block to start from and how many blocks to synchronize. At least one block to be synchronized can also be indicated by the block header of the block.

[0058] It should be noted that the at least one block to be synchronized here refers to at least one block of the ledger result information to be synchronized. For the node to be added, as long as it is consistent with the ledger result information of the current blockchain, it can join the blockchain network. In the prior art, the ledger result information is obtained by calculating the block data in the blockchain, while the present invention can skip the block data and directly obtain the ledger result information through the state snapshot. In addition, at least one block can be all the blocks of the blockchain that are not synchronized, such as the node to be added needs to synchronize the ledger result information of 1-100 blocks in total, 1-80 blocks have been synchronized, and at least one block is 81-100 blocks; at least one block can also be a part of the blocks of the blockchain that are not synchronized, such as the node to be added needs to synchronize the ledger result information of 1-100 blocks in total, 1-10 blocks have been synchronized, and at least one block is 11-20 blocks.

[0059] The state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block. The first block is any block in the at least one block, the first account is any account in the first block, and the state snapshot of the at least one block is used by the node to be joined to synchronize the ledger result information of each account when the at least one block is generated.

[0060] It should be noted that the ledger result information of each account when the first block is generated refers to the ledger information of each account when the first block is generated after each account has experienced all transactions in the first block. For example, if the first block has 1000 transactions, then the final ledger information of each account after the changes in these 1000 transactions is the ledger result information of each account. Among them, the state snapshot of the first block can directly be the ledger result information of each account when the first block is generated; the state snapshot of the first block can also be the state information that can indirectly obtain the ledger result information of each account. For example, if the first block has 1000 transactions, the ledger information of each account when there are 0-500 transactions can be obtained, and the ledger information of each account when there are 501-1000 transactions can be obtained.

[0061] Step 102 may be specifically performed in the following manner:

[0062] The joined node obtains a first status snapshot, where the first status snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; the joined node obtains the status snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first status snapshot.

[0063] There may be various specific ways to obtain the state snapshot of the at least one block, and there may also be various forms of the first state snapshot and the state snapshot of the at least one block, such as a string.

[0064] In a possible implementation, the data format of the first state snapshot is a first state vector, and a specific method of obtaining the state snapshot of the at least one block may be as follows:

[0065] For the first block in the at least one block, the joined node obtains the transaction modification vector of each account in the first block according to the ledger result information of each account in the first block and the predecessor state vector of the first block; obtains the state vector of the first block according to the transaction modification vector of each account in the first block and the predecessor state vector of the first block; the joined node obtains a state matrix according to the first state vector and the state vector of the at least one block as a state snapshot of the at least one block.

[0066] If the first block is the first block of the at least one block, the predecessor state vector of the first block is the first state vector; if the first block is not the first block of the at least one block, the predecessor state vector of the first block is the state vector of the previous block of the first block.

[0067] Step 103 may be specifically performed in the following manner:

[0068] The joined node merges the state snapshot of the at least one block into a state block; the joined node sends the state block to the node to be joined.

[0069] Therefore, the state snapshot of the at least one block is included in only one state block and sent to the node to be added, thereby reducing the number of blocks and further improving the synchronization efficiency.

[0070] The node to be added may synchronize the ledger result information of each account when the at least one block is generated in the following manner:

[0071] For the first account of the first block in the at least one block, the node to be joined modifies the account value of the first account in the node to be joined according to the ledger result information of the first account when the first block is generated.

[0072] A node synchronization method for a blockchain provided by the present invention is described in detail below with reference to more specific examples.

[0073] Step 001: The node A002 to be added in the blockchain network initiates a synchronization block request to the already added node A001. The synchronization request may include the identifier of the node to be added (nodeId), the current block height currentblockNumber of the node to be added, and the number of blocks count that the node to be added needs to synchronize. For example, the node A002 to be added initiates a synchronization request to the already added node A001, and the request body content of the synchronization request is {nodeId:A002,currentblockNumber:0,count:10}, which means that the current block height of the A002 node is 0, and it requests the already added node to synchronize the ten block data from 1 to 10.

[0074] Step 002: The joined node queries and obtains the block list blockList to be returned from its own block data according to the currentblockNumber current block height and count block number in the request body sent by the node to be joined. For example, in the request body of step 001, the joined node A001 obtains blocks 1-10 according to its own account database and proceeds to the next step.

[0075] Step 003, the joined node obtains the currentblockNumber, i.e., the state data corresponding to the block height of the node to be joined, from its own state database. The state data is the account value (or state value) of each account in the node to be joined when the currentblockNumber block height is 0. For example, the joined node A001 queries the state data when the block height is 0 from the state database (the state data contains the account values ​​of all on-chain accounts), recorded as vector0 (the first state vector). Vector0 is the initial state of the state modification set, which contains the account state values ​​involved in the block height of 0.

[0076] Vector description is as follows: [Account 1 field 1, Account 2 field 2, Account 3 field 1…];

[0077] Specifically, it can be: [0x1001-value:0,0x1002-value:0,0x1003-value:0,…].

[0078] Step 004: After the joined node obtains the status data, it scans the block list blockList to obtain the account (or account address) involved in at least one block. The joined node A001 obtains the account addresses involved in all transactions in the block from the block list. For example, if a transaction is initiated in block block1 to change the value of contract 0x1001 from 0 to 1, the contract account address 0x1001 is put into the cache. In this way, all transactions of all blocks in blockList are looped to obtain the accounts involved in each block and store them in vector0. The example is as follows:

[0079] [0x1001-value:0,0x1002-value:0,0x1003-value:0,…] (including all accounts in blockList, the initial values ​​are all account values ​​when the block height is currentNumber. Here, block0 is taken as an example. If the block height is 0, the initial values ​​of all accounts are 0).

[0080] Step 005: The joined node A001 traverses the transactions in the blockList block. For example, when traversing the first block block1, that is, the block with a block height of 1, the input value, transaction output, account address (such as an external account or contract account), contract method methodId and other input and output values ​​of all transactions in block1 are combined based on vector0, and the existing values ​​required for the transaction in the existing vector0 state are added to calculate the modified value of the transaction, that is, the modification set of the transaction to the vector0 state, which can be called the transaction vector or transaction modification vector t1 (transaction state modification set). If the value of the 0x1001 account is modified from 0 to 1 in t1, the form of t1 is [0x1001-value:1], and then the initial state vector0 vector is added to the first transaction t1 vector. By analogy, after adding multiple transactions in a block, the final modification set of block 1 is obtained as vector1, that is:

[0081] vector1=vector0+t1+t2+t3+…;

[0082] It should be noted that the initial vector0 created before the addition is the union of the rows of all transaction vectors, that is, the variables of all transactions involving accounts. For example, t1 involves the value variable of 0x1001, and t2 involves the value variable of 0x1002, then vector0 needs to contain these corresponding variables in all transactions.

[0083] For example, node A001 has joined according to the initial value of vector0. Assuming that the transactions contained in block 1 involve two users, 0x1001 and 0x1002, one of whom modified the value of 0x1001 from 0 to 1, and the other modified the name value of 0x1002 from an empty string to aaa, then vector0 obtains the state vector of vector1 based on the two vectors of transactions t1 and t2 in block 1:

[0084] [0x1001-value:”1”,0x1002-name:”aaa”,0x1003-value:0,0x1004-value:0];

[0085] Step 006: Since the block data is executed and confirmed data, parallel acquisition of transaction vectors can be enabled without affecting the existing account book information. The node A001 has been added and multiple threads are enabled. Multiple transaction vectors in a block are obtained in parallel in a single thread. For example, block block1 contains 3 transactions. After obtaining transaction vectors such as t1, t2, and t3, they are added to vector0 to obtain vector1 of the final block block1 as the second row.

[0086] [0x1001-value:0,0x1002-name:0,0x1003-value:0,0x1004-value:0];

[0087] [0x1001-value:1,0x1002-name:aaa,0x1003-value:0,0x1004-value:0].

[0088] Step 007: When processing the second block block2 in blockList, create a vector2 that is the same as vector1, such as [0x1001-value:1,0x1002-name:aaa,0x1003-value:0,0x1004-value:0]. Assuming that the block2 transaction modifies the value of account 0x1003 and account 0x1004, the value of vector2 is as follows in the third line:

[0089] [0x1001-value:0,0x1002-name:0,0x1003-value:0,0x1004-value:0];

[0090] [0x1001-value:1,0x1002-name:aaa,0x1003-value:0,0x1004-value:0];

[0091] [0x1001-value:1,0x1002-name:aaa,0x1003-value:99,0x1004-value:100].

[0092] The subsequent operations are similar to the previous steps. Vectors t1, t2, t3, etc. of all transactions in block2 are obtained in parallel and added to vector2.

[0093] Step 008: After traversing the entire list of blocks to be synchronized blockList, the final state modification matrix vectorN is obtained.

[0094] Examples of vectorN matrix values ​​are as follows:

[0095] [0x1001-value:0,0x1002-name:0,0x1003-value:0,0x1004-value:0];

[0096] [0x1001-value:1,0x1002-name:aaa,0x1003-value:0,0x1004-value:0];

[0097] [0x1001-value:1,0x1002-name:aaa,0x1003-value:99,0x1004-value:100];

[0098] [0x1001-value:1,0x1002-name:aaa,0x1003-value:99,0x1004-value:100,0x1005-name:bbb,0x1006-name:ccc,0x1007-value:99].

[0099] Step 009, before starting to transmit block data to the node A002 to be added, the node A001 that has been added adds the state vectors of multiple blocks by matrix addition, and merges the state vectors of multiple blocks into one state block. The merged new block is returned to the node to be added, so as to compress the block data and speed up the synchronization.

[0100] Step 010: After the node A002 receives the block return value from A001, it can determine whether the blockList to be synchronized is merged into a single block according to the status flag isZip. Therefore, A002 modifies the block data of its current currentBlockNumber according to the status matrix vectorN from the block with a block height of currentBlockNumber+count, and quickly replays the ledger information through vectorN, and finally obtains the ledger information with the same block height of currentBlockNumber+count.

[0101] For example, A001 returns vectorN, which is the state vector matrix obtained from block0 with a block height of 0 to block10 with a block height of 10. After receiving it, node A002 directly modifies the corresponding account value in its ledger according to the state vectors from block0, block1... to block10 in vectorN, achieving the effect of fast replay of ledger information, so that A002's ledger is synchronized to the state of block10 with a block height of 10.

[0102] Step 011: After A002 receives the compressed block and replays it, A002 repeats the process from step 001 to step 010 until the node A002 to be added is synchronized to the latest block of the node A001 that has been added. For example, if the latest block of A001 is 100, after A1002 synchronizes blocks 0-10, it will continue to synchronize blocks 11-100, and according to the machine performance and network bandwidth, only synchronize a certain number of count blocks each time.

[0103] like Figure 2 The present invention provides a node synchronization device for a blockchain, comprising:

[0104] An acquisition module 201 is used to acquire a synchronization request from a node to be added, wherein the synchronization request indicates at least one block to be synchronized;

[0105] The processing module 202 is used to generate a state snapshot of the at least one block, wherein the state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0106] And used to send the state snapshot of the at least one block to the node to be added, and the state snapshot of the at least one block is used by the node to be added to synchronize the ledger result information of each account when the at least one block is generated.

[0107] Optionally, the processing module 202 is specifically used to: obtain a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; and obtain the state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot.

[0108] Optionally, the data format of the first state snapshot is a first state vector, and the processing module 202 is specifically used to: for the first block in the at least one block, obtain the transaction modification vector of each account in the first block according to the ledger result information of each account in the first block and the predecessor state vector of the first block; obtain the state vector of the first block according to the transaction modification vector of each account in the first block and the predecessor state vector of the first block; wherein, if the first block is the first block of the at least one block, the predecessor state vector of the first block is the first state vector, and if the first block is not the first block of the at least one block, the predecessor state vector of the first block is the state vector of the previous block of the first block; obtain a state matrix according to the first state vector and the state vector of the at least one block as the state snapshot of the at least one block.

[0109] Optionally, the processing module 202 is specifically used to: merge the status snapshots of the at least one block into a status block; and send the status block to the node to be added.

[0110] Optionally, the synchronization request includes the block height of the block that the node to be added has synchronized and the number of blocks that the node to be added needs to synchronize this time.

[0111] like Figure 3 The present invention provides a node synchronization device for a blockchain, comprising:

[0112] The transmission module 301 is used to send a synchronization request to a joined node of the blockchain, wherein the synchronization request indicates at least one block to be synchronized; obtain a state snapshot of at least one block from the joined node, wherein the state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is less than the data volume of the block data of the first block, the first block is any block in the at least one block, and the first account is any account in the first block;

[0113] The processing module 302 is used to synchronize the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block.

[0114] Optionally, the processing module 302 is specifically used for:

[0115] For the first account of the first block in the at least one block, modify the account value of the first account in the node to be added according to the ledger result information of the first account when the first block is generated.

[0116] Based on the same inventive concept, an embodiment of the present invention also provides a computer device, including a program or instructions. When the program or instructions are executed, the node synchronization method of the blockchain provided in the embodiment of the present invention and any optional method are executed.

[0117] Based on the same inventive concept, an embodiment of the present invention also provides a computer-readable storage medium, including a program or instructions. When the program or instructions are executed, the node synchronization method of the blockchain provided in the embodiment of the present invention and any optional method are executed.

[0118] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0119] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0120] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0121] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0122] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.

[0123] Obviously, those skilled in the art can make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these 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 these modifications and variations.

Claims

1. A node synchronization method for a blockchain, characterized in that: include: The joined node of the blockchain obtains a synchronization request from the to-be-joined node, wherein the synchronization request indicates at least one block to be synchronized; The joined node obtains a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; The joined node obtains a status snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first status snapshot; The state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block. The first block is any block in the at least one block, and the first account is any account in the first block. The joined node sends the state snapshot of the at least one block to the node to be joined, and the state snapshot of the at least one block is used by the node to be joined to synchronize the ledger result information of each account when the at least one block is generated.

2. The method according to claim 1, characterized in that The data form of the first state snapshot is a first state vector, and the joined node obtains the state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot, including: For the first block in the at least one block, the joined node obtains the transaction modification vector of each account in the first block according to the ledger result information of each account in the first block and the predecessor state vector of the first block; obtains the state vector of the first block according to the transaction modification vector of each account in the first block and the predecessor state vector of the first block; wherein, if the first block is the first block of the at least one block, the predecessor state vector of the first block is the first state vector, and if the first block is not the first block of the at least one block, the predecessor state vector of the first block is the state vector of the previous block of the first block; The joined node obtains a state matrix according to the first state vector and the state vector of the at least one block as a state snapshot of the at least one block.

3. The method according to claim 1, characterized in that The joined node sends the state snapshot of the at least one block to the node to be joined, including: The joined node merges the state snapshot of the at least one block into a state block; The joined node sends the status block to the node to be joined.

4. The method according to any one of claims 1 to 3, characterized in that The synchronization request includes the block height of the block that the node to be added has synchronized and the number of blocks that the node to be added needs to synchronize this time.

5. A method for synchronizing block data of a blockchain, characterized in that: include: The node to be joined sends a synchronization request to the joined node of the blockchain, wherein the synchronization request indicates at least one block to be synchronized; The node to be joined obtains a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; The node to be joined obtains a status snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first status snapshot; The state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block. The first block is any block in the at least one block, and the first account is any account in the first block. The node to be joined synchronizes the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block.

6. The method according to claim 5, characterized in that The node to be joined synchronizes the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block, including: For the first account of the first block in the at least one block, the node to be joined modifies the account value of the first account in the node to be joined according to the ledger result information of the first account when the first block is generated.

7. A node synchronization device for a blockchain, characterized in that: include: An acquisition module, configured to acquire a synchronization request from a node to be added, wherein the synchronization request indicates at least one block to be synchronized; A processing module, configured to obtain a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; Obtaining a state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot; The state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block. The first block is any block in the at least one block, and the first account is any account in the first block. And used to send the state snapshot of the at least one block to the node to be added, and the state snapshot of the at least one block is used by the node to be added to synchronize the ledger result information of each account when the at least one block is generated.

8. A block data synchronization device for a blockchain, characterized in that: include: A transmission module, configured to send a synchronization request to a joined node of the blockchain, wherein the synchronization request indicates at least one block to be synchronized; Obtaining a first state snapshot, where the first state snapshot is the ledger result information of each account when the last block synchronized between the joined node and the node to be joined is generated; obtaining a state snapshot of the at least one block according to the ledger result information of each account on the at least one block and the first state snapshot; The state snapshot of the first block is used to obtain the ledger result information of each account when the first block is generated, and the data volume of the state snapshot of the first block is smaller than the data volume of the block data of the first block. The first block is any block in the at least one block, and the first account is any account in the first block. The processing module is used to synchronize the ledger result information of each account when the at least one block is generated according to the state snapshot of the at least one block.

9. A computer device, characterized in that: The method comprises a program or an instruction. When the program or the instruction is executed by a processor, the method according to any one of claims 1 to 4 or 5 to 6 is performed.

Citation Information

Patent Citations

  • Data synchronization method and device of alliance chain, readable medium and electronic equipment

    CN112100282A