IP Library Granted Patent US 10,956,444
Granted Patent B2
US 10,956,444 · App. 16/775,195 · Granted Mar 23, 2021

Block chain state data synchronization method, apparatus, and electronic device

Inventors: Haizhen Zhuo (Hangzhou, CN); Zhonghao Lu (Hangzhou, CN); Benquan Yu (Hangzhou, CN)
Assignee: Advanced New Technologies Co., Ltd.
G06F16/27G06F16/2246
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 10,956,444
App. No.
16/775,195
Granted
Mar 23, 2021
Kind
B2
Abstract

A method of synchronizing blockchain state data, where account state data in the blockchain is organized into a Merkle state tree and stored in a database; the Merkle state tree includes a current Merkle state tree formed by a latest account state of each blockchain account; and a history Merkle state tree formed by a history account state of each blockchain account; and the method includes: receiving a data synchronization instruction for the Merkle state tree; in response to the data synchronization instruction, obtaining in real time the current Merkle state tree of the latest block stored in the database of other node device in the blockchain; and storing the obtained current Merkle state tree of the latest block to the local database to complete real-time data synchronization for the Merkle state tree.

Claims (68)

1. A computer-implemented method of synchronizing blockchain state data, comprising:

receiving, at a blockchain node device in a blockchain, a data synchronization instruction, wherein the blockchain node device is in recovery from a crash or is a new node in the blockchain;

in response to receiving the data synchronization instruction, obtaining in real time, at the blockchain node device, a current Merkle state tree of a latest block stored in a database of another blockchain node device in the blockchain,

wherein the database of the other blockchain node device stores the current Merkle state tree of the latest block and a history Merkle state tree, wherein the current Merkle state tree and the history Merkle state tree are distinct Merkle state trees that store respective non-identical sets of data, wherein at least some data stored in the history Merkle state tree is blockchain account data not stored in the current Merkle state tree, and wherein a storage size of the current Merkle state tree is less than a storage size of the history Merkle state tree, and

wherein the current Merkle state tree of the latest block stored in the database of the other blockchain node device is formed by a latest account state of blockchain accounts of the blockchain, and wherein the history Merkle state tree stored in the database of the other blockchain node device is formed by historical account states of the blockchain accounts of the blockchain;

storing the obtained current Merkle state tree of the latest block to a local database of the blockchain node device to complete real-time data synchronization;

at a later time, subsequent to storing the obtained current Merkle state tree of the latest block, obtaining, at the blockchain node device, the history Merkle state tree stored in the database of the other blockchain node device; and

storing the obtained history Merkle state tree in the local database of the blockchain node device.

2. The computer-implemented method of claim 1 , further comprising:

determining, by the blockchain node device, that a first block number of the latest block stored in the database of the other blockchain node device is smaller than a second block number of a current latest block of the blockchain; and

in response to determining that the first block number of the latest block stored in the database of the other blockchain node device is smaller than the second block number of the current latest block of the blockchain, re-executing, by the blockchain node device, transactions in all blocks from the first block number to the second block number, to update data nodes on the stored obtained current Merkle state tree and the stored obtained history Merkle state tree that have been synchronized to the local database of the blockchain node device.

3. The computer-implemented method of claim 2 , further comprising:

after execution of a transaction in a target block is completed, based on a latest account state of a target account related to the transaction after execution of the transaction, modifying and updating, by the blockchain node device, data nodes that correspond to the target account on a current Merkle state tree of a previous block adjacent to the target block, to obtain a current Merkle state tree of the target block;

based on a history account state of the target account before execution of the transaction, generating, by the blockchain node device, history data nodes corresponding to a history Merkle state tree of the target block; and

based on (i) the generated history data nodes and (ii) data nodes other than data nodes corresponding to the target account on a history Merkle state tree of the previous block adjacent to the target block, creating, by the blockchain node device, the history Merkle state tree of the target block.

4. The computer-implemented method of claim 1 , wherein data nodes on the stored obtained current Merkle state tree are organized into a data structure of a balance+tree; and

wherein data nodes on the stored obtained history Merkle state tree are organized into a data structure of a Log-Structured Merge Tree.

5. The computer-implemented method of claim 1 , wherein the local database is a Key-Value database;

wherein data nodes on the stored obtained current Merkle state tree and data nodes on the stored obtained history Merkle state tree are stored in the form of Key-Value pairs;

wherein a key of each data node on the stored obtained current Merkle state tree is a node ID of the data node; and

wherein a key of each data node on the stored obtained history Merkle state tree is a hash value of data content contained in the data node.

6. The computer-implemented method of claim 1 , wherein the local database is a LevelDB database or a database based on a LevelDB architecture.

7. The computer-implemented method of claim 1 , wherein obtaining the current Merkle state tree comprises immediately creating, by the blockchain node device, a thread and, using the thread, obtaining the current Merkle state tree through a connection between the blockchain node device and the other blockchain node device.

8. A non-transitory, computer-readable medium storing one or more instructions that, when executed by a computer system, cause the computer system to perform operations for synchronizing blockchain state data, the operations comprising:

receiving, at a blockchain node device in a blockchain, a data synchronization instruction, wherein the blockchain node device is in recovery from a crash or is a new node in the blockchain;

in response to receiving the data synchronization instruction, obtaining in real time, at the blockchain node device, a current Merkle state tree of a latest block stored in a database of another blockchain node device in the blockchain,

wherein the database of the other blockchain node device stores the current Merkle state tree of the latest block and a history Merkle state tree, wherein the current Merkle state tree and the history Merkle state tree are distinct Merkle state trees that store respective non-identical sets of data, wherein at least some data stored in the history Merkle state tree is blockchain account data not stored in the current Merkle state tree, and wherein a storage size of the current Merkle state tree is less than a storage size of the history Merkle state tree, and

wherein the current Merkle state tree of the latest block stored in the database of the other blockchain node device is formed by a latest account state of blockchain accounts of the blockchain, and wherein the history Merkle state tree stored in the database of the other blockchain node device is formed by historical account states of the blockchain accounts of the blockchain;

storing the obtained current Merkle state tree of the latest block to a local database of the blockchain node device to complete real-time data synchronization;

at a later time, subsequent to storing the obtained current Merkle state tree of the latest block, obtaining, at the blockchain node device, the history Merkle state tree stored in the database of the other blockchain node device; and

storing the obtained history Merkle state tree in the local database of the blockchain node device.

9. The non-transitory, computer-readable medium of claim 8 , wherein the operations further comprise:

determining, by the blockchain node device, that a first block number of the latest block stored in the database of the other blockchain node device is smaller than a second block number of a current latest block of the blockchain; and

in response to determining that the first block number of the latest block stored in the database of the other blockchain node device is smaller than the second block number of the current latest block of the blockchain, re-executing, by the blockchain node device, transactions in all blocks from the first block number to the second block number, to update data nodes on the stored obtained current Merkle state tree and the stored obtained history Merkle state tree that have been synchronized to the local database of the blockchain node device.

10. The non-transitory, computer-readable medium of claim 9 , wherein the operations further comprise:

after execution of a transaction in a target block is completed, based on a latest account state of a target account related to the transaction after execution of the transaction, modifying and updating, by the blockchain node device, data nodes that correspond to the target account on a current Merkle state tree of a previous block adjacent to the target block, to obtain a current Merkle state tree of the target block;

based on a history account state of the target account before execution of the transaction, generating, by the blockchain node device, history data nodes corresponding to a history Merkle state tree of the target block; and

based on (i) the generated history data nodes and (ii) data nodes other than data nodes corresponding to the target account on a history Merkle state tree of the previous block adjacent to the target block, creating, by the blockchain node device, the history Merkle state tree of the target block.

11. The non-transitory, computer-readable medium of claim 8 , wherein data nodes on the stored obtained current Merkle state tree are organized into a data structure of a balance+tree; and

wherein data nodes on the stored obtained history Merkle state tree are organized into a data structure of a Log-Structured Merge Tree.

12. The non-transitory, computer-readable medium of claim 8 , wherein the local database is a Key-Value database;

wherein data nodes on the stored obtained current Merkle state tree and data nodes on the stored obtained history Merkle state tree are stored in the form of Key-Value pairs;

wherein a key of each data node on the stored obtained current Merkle state tree is a node ID of the data node; and

wherein a key of each data node on the stored obtained history Merkle state tree is a hash value of data content contained in the data node.

13. The non-transitory, computer-readable medium of claim 8 , wherein the local database is a LevelDB database or a database based on a LevelDB architecture.

14. A computer-implemented system, comprising:

one or more computers; and

one or more computer memory devices interoperably coupled with the one or more computers and having tangible, non-transitory, machine-readable media storing one or more instructions that, when executed by the one or more computers, cause the one or more computers to perform one or more operations for synchronizing blockchain state data, the operations comprising:

receiving, at a blockchain node device in a blockchain, a data synchronization instruction, wherein the blockchain node device is in recovery from a crash or is a new node in the blockchain;

in response to receiving the data synchronization instruction, obtaining in real time, at the blockchain node device, a current Merkle state tree of a latest block stored in a database of another blockchain node device in the blockchain,

wherein the database of the other blockchain node device stores the current Merkle state tree of the latest block and a history Merkle state tree, wherein the current Merkle state tree and the history Merkle state tree are distinct Merkle state trees that store respective non-identical sets of data, wherein at least some data stored in the history Merkle state tree is blockchain account data not stored in the current Merkle state tree, and wherein a storage size of the current Merkle state tree is less than a storage size of the history Merkle state tree, and

wherein the current Merkle state tree of the latest block stored in the database of the other blockchain node device is formed by a latest account state of blockchain accounts of the blockchain, and wherein the history Merkle state tree stored in the database of the other blockchain node device is formed by historical account states of the blockchain accounts of the blockchain;

storing the obtained current Merkle state tree of the latest block to a local database of the blockchain node device to complete real-time data synchronization;

at a later time, subsequent to storing the obtained current Merkle state tree of the latest block, obtaining, at the blockchain node device, the history Merkle state tree stored in the database of the other blockchain node device; and

storing the obtained history Merkle state tree in the local database of the blockchain node device.

15. The computer-implemented system of claim 14 , wherein the operations further comprise:

determining, by the blockchain node device, that a first block number of the latest block stored in the database of the other blockchain node device is smaller than a second block number of a current latest block of the blockchain; and

in response to determining that the first block number of the latest block stored in the database of the other blockchain node device is smaller than the second block number of the current latest block of the blockchain, re-executing, by the blockchain node device, transactions in all blocks from the first block number to the second block number, to update data nodes on the stored obtained current Merkle state tree and the stored obtained history Merkle state tree that have been synchronized to the local database of the blockchain node device.

16. The computer-implemented system of claim 15 , wherein the operations further comprise:

after execution of a transaction in a target block is completed, based on a latest account state of a target account related to the transaction after execution of the transaction, modifying and updating, by the blockchain node device, data nodes that correspond to the target account on a current Merkle state tree of a previous block adjacent to the target block, to obtain a current Merkle state tree of the target block;

based on a history account state of the target account before execution of the transaction, generating, by the blockchain node device, history data nodes corresponding to a history Merkle state tree of the target block; and

based on (i) the generated history data nodes and (ii) data nodes other than data nodes corresponding to the target account on a history Merkle state tree of the previous block adjacent to the target block, creating, by the blockchain node device, the history Merkle state tree of the target block.

17. The computer-implemented system of claim 14 , wherein data nodes on the stored obtained current Merkle state tree are organized into a data structure of a balance+tree; and

wherein data nodes on the stored obtained history Merkle state tree are organized into a data structure of a Log-Structured Merge Tree.

18. The computer-implemented system of claim 14 , wherein the local database is a Key-Value database;

wherein data nodes on the stored obtained current Merkle state tree and data nodes on the stored obtained history Merkle state tree are stored in the form of Key-Value pairs;

wherein a key of each data node on the stored obtained current Merkle state tree is a node ID of the data node; and

wherein a key of each data node on the stored obtained history Merkle state tree is a hash value of data content contained in the data node.

Assignments (3)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Jan 28, 2021
From: ZHUO, HAIZHEN; LU, ZHONGHAO; YU, BENQUAN
To: ALIBABA GROUP HOLDING LIMITED
Reel/Frame 055068/0437 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Sep 10, 2020
From: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
To: ADVANCED NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053754/0625 →
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Aug 31, 2020
From: ALIBABA GROUP HOLDING LIMITED
To: ADVANTAGEOUS NEW TECHNOLOGIES CO., LTD.
Reel/Frame 053743/0464 →
Priority Claims (1)
CN 201910703834.1 · Jul 31, 2019 · national
Continuity (2)
Continuation PCTCN2020072123 · Jan 15, 2020
Related Publication 20200167367A1 · May 28, 2020