State Merkle Tree in Blockchain Network
Technical Field:
It relates to the field of blockchain technology, and in particular to a method and device for updating a state Merkle Tree for recording account status in a blockchain.
Technical Problem:
There are many accounts and frequent transactions in a blockchain network, which results in frequent updates of the state Merkle Tree, and the traditional layer-by-layer update method is inefficient.
Technical Solution:
Method Overview: By means of parallel processing, the part to be updated in the state Merkle Tree is divided into a root subtree and multiple dirty subtrees, and then the dirty subtrees are updated in parallel, and finally the root subtree is updated based on the updated dirty subtree, thereby obtaining an updated state Merkle Tree.
Step Details:
Determine the node to be updated (dirty node) caused by the change in account status.
Extract the root subtree and multiple dirty subtrees according to the node to be updated, the root subtree contains the root node of the state Merkle Tree, the root node of the dirty subtree is the node to be updated and is the child node of the bottom-level node of the root subtree.
Assign multiple dirty subtrees to multiple worker threads for parallel processing to obtain updated dirty subtrees.
Based on the hash value of the updated dirty subtree root node, the root subtree is updated to obtain the updated state Merkle tree.
Application scenario:
It is mainly used for nodes in the blockchain network, including updating the state Merkle tree when packaging new blocks and verifying new blocks.
Implementation method:
Extraction of root subtree and dirty subtree: The root subtree and dirty subtree are determined by setting a preset number of layers or a threshold of the number of dirty nodes.
Parallel processing: The dirty subtree is assigned to the worker thread, and tasks are assigned by numbering and modulo to achieve parallel processing.
Update and verification: The updated state Merkle tree is used to package new blocks or verify blocks to be verified.
Request item:
Includes technical details of multiple specific implementation methods, such as the extraction method of the root subtree and dirty subtree under different strategies, the specific implementation method of parallel processing, etc.
Illustration description:
Multiple diagrams are provided, including block structure diagrams, state Merkle tree examples, update flow charts, etc., to intuitively illustrate the technical solution.
Technical effect:
Compared with the traditional layer-by-layer update method, the method of processing multiple dirty subtrees in parallel significantly improves the update efficiency of the state Merkle tree, thereby improving the overall performance of the blockchain network.
What is the technical field involved in this application?
This application relates to the field of blockchain technology, especially to the update method and device for the state Merkle tree used to record the account status in the blockchain.
What are the problems with the traditional method of updating the state Merkle tree?
There are many accounts and frequent transactions in the blockchain network, which leads to the need for frequent updates of the state Merkle tree. The traditional layer-by-layer upward update method is inefficient and cannot meet the high performance requirements.
What is the technical solution proposed in this application?
Through parallel processing, the part to be updated in the state Merkle tree is divided into a root subtree and multiple dirty subtrees, the dirty subtrees are updated in parallel, and finally the root subtree is updated based on the updated dirty subtree, so as to obtain the updated state Merkle tree.
How to determine the node to be updated (dirty node)?
Trace back from the leaf node corresponding to the account whose status has changed to the root node, and determine all nodes passed on the backtracking path as nodes to be updated (dirty nodes).
How to extract the root subtree and dirty subtree?
The root subtree can be determined by setting a preset number of layers or a threshold for the number of dirty nodes. The dirty subtree is extracted based on the nodes to be updated in the lowest node of the root subtree, ensuring that the root node of the dirty subtree is the child node of the lowest node of the root subtree.
How is parallel processing achieved?
Multiple dirty subtrees are assigned to multiple worker threads, and the dirty subtrees are assigned to the worker threads by numbering and modulo to achieve parallel processing. After the worker threads independently update the dirty subtrees, the update results are summarized to update the root subtree.
What are the application scenarios of the updated state Merkle tree?
It is mainly used for nodes in the blockchain network, including updating the state Merkle tree when packaging new blocks and verifying new blocks. The hash value of the root node of the updated state Merkle tree will be recorded in the block.
What are the advantages of this technical solution over the traditional method?
Compared with the traditional layer-by-layer update method, the method of processing multiple dirty subtrees in parallel significantly improves the update efficiency of the state Merkle tree, thereby improving the overall performance of the blockchain network.
Are there any diagrams in the application?
Yes, the application provides multiple diagrams, including block structure diagrams, state Merkle tree examples, update flow charts, etc., to intuitively illustrate the technical solution.