A method, device and equipment for expanding the capacity of a blockchain layer 2 network

By using contracts to generate and replace Merkel trees on the side chain and main chain of the blockchain layer 2 network, the problem of frequent repeated hash calculations when calculating Merkel roots is solved, and the effect of reducing transaction fees and improving efficiency is achieved.

CN115987799BActive Publication Date: 2025-04-25CHINA MOBILE (SUZHOU) SOFTWARE TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111199523.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-14
Publication Date
2025-04-25
Estimated Expiration
2041-10-14

AI Technical Summary

Technical Problem

The existing blockchain layer 2 network expansion solution has the problem of frequent repeated hash calculations when calculating Merkel roots, resulting in high transaction fees.

Method used

Generate a Merkel tree by obtaining transaction information on the side chain of the blockchain, and obtaining empty child node data through the contract on the main chain, selecting the target empty child node to replace the Merkel tree, thereby reducing the number of hash calculations.

Benefits of technology

Without reducing security, the number of hash calculations is greatly reduced and transaction fees are reduced.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115987799B_ABST
    Figure CN115987799B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, device and equipment for expanding the capacity of a second-layer blockchain network, the method comprising: obtaining at least one transaction information initiated by a participant of the side chain through a first contract on the side chain of the blockchain; generating a first Merkle tree on the first contract according to the at least one transaction information; obtaining data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through a second contract on the side chain of the blockchain; selecting a target empty child node according to the data of the first Merkle tree and the at least one empty child node; replacing the position of the target empty child node with the first Merkle tree. In the above manner, the present invention realizes a significant reduction in the number of hash calculations and transaction costs without reducing security.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a method, device and equipment for expanding the capacity of a blockchain layer 2 network. Background Art

[0002] In the existing technology, there are three main solutions for expanding the capacity of the blockchain layer 2 network:

[0003] One is the state channel, but participants in the state channel may have to wait for a long time, usually 24 hours, before they can exit, and they need to frequently monitor the main chain to ensure that their counterparties have not used a past state to exit. At the same time, the state channel can generally only be opened between two participants;

[0004] The second is the “unregulated” sidechain technology Plasma, but it must provide the complete history of the token when transferring the token, and the exit mechanism is very complicated;

[0005] The third is the sidechain Rollup technology. However, in the process of calculating the Merkle tree, when a deposit transaction is received and the Merkle root is recalculated, the hash number needs to be calculated. When another deposit transaction is added, the hash number still needs to be calculated when calculating the Merkle root. However, the calculation cost of hash functions that are friendly to zk-SNARK is relatively high. Summary of the invention

[0006] In view of the above problems, embodiments of the present invention are proposed to provide a method, device and equipment for expanding the capacity of a blockchain layer 2 network that overcomes the above problems or at least partially solves the above problems.

[0007] According to one aspect of an embodiment of the present invention, a method for expanding the capacity of a blockchain layer 2 network is provided, the method comprising:

[0008] Obtaining, through a first contract on a side chain of the blockchain, at least one transaction information initiated by a participant of the side chain;

[0009] Generate a first Merkle tree on the first contract according to the at least one transaction information;

[0010] Obtain data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through the second contract on the side chain of the blockchain;

[0011] Selecting a target empty child node according to the first Merkle tree and the data of the at least one empty child node;

[0012] The position of the target empty child node is replaced by the first Merkle tree.

[0013] According to another aspect of an embodiment of the present invention, a device for expanding a blockchain layer 2 network is provided, the device comprising:

[0014] A processing module, configured to obtain at least one transaction information initiated by a participant of the side chain through a first contract on the side chain of the blockchain; and generate a first Merkle tree on the first contract according to the at least one transaction information;

[0015] An acquisition module, used to acquire data of at least one empty child node of a second Merkle tree on a main chain of the blockchain through a second contract on a side chain of the blockchain;

[0016] The processing module is further used to select a target empty child node according to the data of the first Merkle tree and the at least one empty child node; and replace the position of the target empty child node with the first Merkle tree.

[0017] According to another aspect of an embodiment of the present invention, there is provided a computing device, comprising: a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus;

[0018] The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform operations corresponding to the above-mentioned blockchain layer 2 network expansion method.

[0019] According to another aspect of an embodiment of the present invention, a computer storage medium is provided, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to perform operations corresponding to the above-mentioned blockchain layer 2 network expansion method.

[0020] According to the solution provided by the above-mentioned embodiment of the present invention, the expansion method of the second-layer network of the blockchain can obtain at least one transaction information initiated by the participants of the side chain through the first contract on the side chain of the blockchain; generate a first Merkle tree on the first contract according to the at least one transaction information; obtain data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through the second contract on the side chain of the blockchain; select a target empty child node according to the data of the first Merkle tree and the at least one empty child node; replace the position of the target empty child node with the first Merkle tree, thereby solving the problem of repeated hash calculation in the process of calculating the Merkle root in the prior art when multiple deposit transactions are included, and achieving the beneficial effect of greatly reducing the number of hash calculations and reducing transaction costs without reducing security.

[0021] The above description is only an overview of the technical solution of the embodiment of the present invention. In order to more clearly understand the technical means of the embodiment of the present invention, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the embodiment of the present invention more obvious and easy to understand, the specific implementation method of the embodiment of the present invention is specifically listed below. BRIEF DESCRIPTION OF THE DRAWINGS

[0022] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the embodiments of the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:

[0023] Figure 1 A flowchart of a method for expanding the capacity of a blockchain layer 2 network provided by an embodiment of the present invention is shown;

[0024] Figure 2 A schematic diagram of the structure of a first Merkle tree in a specific embodiment provided by the present invention is shown;

[0025] Figure 3 A schematic diagram of a Merkle root of a second Merkle tree when no transaction is initiated in a specific embodiment provided by the present invention is shown;

[0026] Figure 4 A schematic diagram showing the Merkle root of the second Merkle tree when initiating an A11 transaction in a specific embodiment provided by the present invention is shown;

[0027] Figure 5 A schematic diagram of the Merkle root of the second Merkle tree when initiating an A12 transaction in a specific embodiment provided by the present invention is shown;

[0028] Figure 6 A schematic diagram showing the Merkle root of the second Merkle tree when initiating the A13 transaction in a specific embodiment provided by the present invention is shown;

[0029] Figure 7 A schematic diagram showing a method of inserting a first Merkle tree into an empty child node of a second Merkle tree in a specific embodiment provided by the present invention is shown;

[0030] Figure 8 A schematic diagram showing the insertion of A13 into an empty child node of the second Merkle tree in a specific embodiment provided by the present invention is shown;

[0031] Fig. 9 A schematic diagram of the process of performing four transactions in a specific embodiment provided by the present invention is shown;

[0032] Fig.10A schematic diagram of the structure of a blockchain layer 2 network expansion device provided by an embodiment of the present invention is shown;

[0033] Fig.11 The schematic diagram of the structure of the main chain and the side chain in a specific embodiment provided by the present invention is shown;

[0034] Fig.12 A schematic diagram of the structure of a computing device provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0035] The exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although the exemplary embodiments of the present invention are shown in the accompanying drawings, it should be understood that the present invention can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present invention and to enable the scope of the present invention to be fully communicated to those skilled in the art.

[0036] Figure 1 A flow chart of a method for expanding the capacity of a blockchain layer 2 network provided by an embodiment of the present invention is shown.

[0037] like Figure 1 As shown, the method comprises the following steps:

[0038] Step 11, obtaining at least one transaction information initiated by a participant of the side chain through the first contract on the side chain of the blockchain;

[0039] Step 12: generating a first Merkle tree on the first contract according to the at least one transaction information;

[0040] Step 13, obtaining data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through the second contract on the side chain of the blockchain;

[0041] Step 14, selecting a target empty child node according to the data of the first Merkle tree and the at least one empty child node;

[0042] Step 15: Replace the position of the target empty child node with the first Merkle tree.

[0043] The data of the empty subnode includes the level of the empty subnode and the hash value of the empty subnode.

[0044] In this embodiment, a first contract and a second contract are established on the side chain, at least one transaction information initiated by a participant of the side chain is obtained through the first contract, a first Merkle tree including at least one transaction information is generated on the first contract, the second contract obtains data of at least one empty subnode of the second Merkle tree on the main chain, and a target empty subnode is selected from at least one empty subnode according to the first Merkle tree, and the target empty subnode is replaced with the first Merkle tree; the number of times hash calculations are greatly reduced without reducing transaction security, thereby reducing transaction costs;

[0045] Among them, the side chain of the blockchain is a blockchain that is completely independent of the main chain of the blockchain. There are side chain participants and side chain operators on the side chain. The side chain can transfer assets with the main chain of the blockchain. At the same time, the side chain can also selectively send snapshots of the block header to the main chain to prevent the occurrence of forks. The snapshot of the block header effectively prevents the occurrence of forks and improves security. Here, the block header stores the metadata of the block, which is used to identify, verify and explain the block content.

[0046] The main chain of the blockchain is an important guarantee for the security of the blockchain's second-layer network expansion method; it acts as an arbitrator in the blockchain's second-layer network expansion method to ensure the security of transactions with the side chain.

[0047] It should be noted that the first contract is preferably a Merkle tree in progress. The first contract can be used to generate a first Merkle tree when a participant initiates at least one transaction information. The first contract can also be used to merge the first Merkle tree in the first contract with the second Merkle tree on the main chain.

[0048] The second contract can be used to obtain data of at least one empty child node of the second Merkle tree on the main chain of the blockchain.

[0049] In an optional embodiment of the present invention, step 12 includes:

[0050] Step 121: if a balanced binary tree is constructed according to the at least one transaction information, a first Merkle tree is generated on the first contract;

[0051] Step 122: If the tree constructed based on the at least one transaction information is not a balanced binary tree, the first contract saves the at least one transaction information and waits for the next transaction information, and generates a first Merkle tree based on the at least one transaction information and the next transaction information.

[0052] In this embodiment, a transaction is initiated by a side chain participant, and the first contract receives at least one transaction information initiated by the side chain participant. When the first contract can generate a balanced binary tree according to the at least one transaction information, a first Merkle tree is generated, and the first Merkle tree here is a balanced binary tree; and when the first contract cannot generate a balanced binary tree according to the at least one transaction information, the at least one transaction information is saved and waits for the next transaction information, and the first Merkle tree is generated according to the at least one transaction information and the next transaction information;

[0053] It should be noted that, since each transaction information is at the same level on the first Merkle tree when the first Merkle tree is generated, when at least one transaction information cannot construct a balanced binary tree, a balanced binary tree can be constructed based on at least one transaction information and the next transaction information, thereby generating the first Merkle tree;

[0054] Among them, the balanced binary tree can be an empty tree or not. When the balanced binary tree is not an empty tree, the balanced binary tree satisfies: the left subtree and the right subtree of any node are balanced binary trees, and the absolute value of the difference in height does not exceed 1.

[0055] Figure 2 FIG. 2 shows a schematic diagram of the structure of the first Merkle tree in a specific embodiment provided by the present invention. Figure 2 As shown, in a specific embodiment 1, when a side chain participant initiates 3 transactions (the first transaction information is A1, the second transaction information is A2, and the third transaction information is A3), A1 and A2 are first constructed into a first Merkle tree (archive_tree). During the construction of archive_tree, the number of hashes is 1 and the depth is 1, wherein A3 does not participate in the construction of this Merkle tree.

[0056] In a specific embodiment 2, the Merkle tree (archive_tree) is initialized and initialized to an empty tree. When a deposit transaction A enters, transaction A is first saved and waited. When the second deposit transaction B enters, the hash values ​​H(A, B) of A and B are calculated to construct the first Merkle tree. The saved hash value H(A, B) indicates that the first Merkle tree contains 2 deposit transactions and the depth of archive_tree is 1. When the third deposit transaction C enters, it is saved and waited until the fourth deposit transaction D enters. At this time, the hash values ​​H(C, D) of the third and fourth deposit transactions are calculated, and the hash values ​​of H(A, B) and H(C, D) are calculated to obtain H(H(A, B), H(C, D)). The hash value H(H(A, B), H(C, D)) indicates that the first Merkle tree contains 4 deposit transactions and the depth of the first Merkle tree is 2.

[0057] In an optional embodiment of the present invention, step 13 includes:

[0058] Traverse the second Merkle tree on the main chain of the blockchain, obtain the data of all empty child nodes on the second Merkle tree and save them in the second contract.

[0059] The data of the empty subnode includes the level of the empty subnode and the hash value of the empty subnode.

[0060] In this embodiment, the data of the empty child nodes on the second Merkle tree is preferably a key-value pair (map). The second Merkle tree on the main chain is traversed. If all child nodes of a node on the second Merkle tree are empty, the node is treated as an empty child node, and the data of the empty child node is saved in the second contract; the second contract implements the statistics of the empty child nodes of the second Merkle tree on the main chain, and the second contract saves the data of all empty child nodes on the second Merkle tree;

[0061] An empty child node of the second Merkle tree refers to an empty child node whose upper-level nodes are not empty and whose lower-level nodes are all empty; the data of the empty child node includes the level of the empty child node and the hash value of the empty child node.

[0062] In a specific embodiment 3, the data of the empty subnode includes the level of the empty subnode and the hash value of the empty subnode, as shown in the following table:

[0063] Tiers Hash Layer 1 hash(0,0) Layer 2 hash(hash(0,0),hash(0,0)) ... … Layer tree_depth hash(hash(hash(…hash(0,0),))…)

[0064] Table 1

[0065] As shown in Table 1, the hash value of the empty child node of the first layer of the second Merkle tree is hash(0,0), the hash value of the empty child node of the second layer of the second Merkle tree is hash(hash(0,0), hash(0,0)), and the hash value of the empty child node of the tree_depth layer of the second Merkle tree is hash(hash(hash(…hash(0,0),))…).

[0066] In an optional embodiment of the present invention, step 14 includes:

[0067] Step 141, obtaining the depth of the first Merkle tree;

[0068] Step 142: According to the depth of the first Merkle tree and the data of the at least one empty child node, select an empty child node whose level is the same as the depth of the first Merkle tree as a target empty child node.

[0069] In this embodiment, a first Merkle tree is generated based on at least one transaction information, the depth of the first Merkle tree is at least 1, all empty subnodes of the second Merkle tree in the second contract and the data of all empty subnodes are read, and the empty subnodes whose number of layers of empty subnodes is the same as the depth of the first Merkle tree are selected as the target empty subnodes.

[0070] In an optional embodiment of the present invention, step 15 includes:

[0071] Step 151, replacing the level corresponding to the target empty child node with the head node of the first Merkle tree;

[0072] Step 152: Replace the nodes of the next level corresponding to the target empty child node with the nodes of the next level of the head node of the first Merkle tree, until all nodes under the target empty child node are replaced with all nodes in the first Merkle tree.

[0073] In this embodiment, since the level of the target empty subnode selected in step 14 is the same as the depth of the first Merkle tree, the target empty subnode is replaced with the head node of the first Merkle tree, and the nodes of the next level corresponding to the target empty subnode are replaced with the nodes of the next level of the head node of the first Merkle tree. The replacement is performed according to the level, and the nodes of all levels under the target empty subnode can be replaced with all nodes of the first Merkle tree.

[0074] It should be noted that the relative positions of all nodes below the target empty subnode of the replaced second Merkle tree and all nodes below the head node of the first Merkle tree remain unchanged, that is, when the node on the left subtree in the next layer of the head node of the first Merkle tree (balanced binary tree) is L1, and the node on the right subtree is R1, therefore, when replacing the target empty subnode of the second Merkle tree, the node on the left subtree of the next layer of the target empty subnode is L1, and the node on the right subtree is R1.

[0075] In a specific embodiment 4, the first Merkle tree is archive_tree, and its Merkle root leaf1 with a depth of archive_tree_depth is read. The key-value pair map value in the second contract is read, and the second Merkle tree (balance_tree) of the main chain is queried for an empty child node leaf2 with a level of archive_tree_depth and all child nodes are empty. The empty child node leaf2 in the second Merkle tree replaces leaf1 in archive_tree.

[0076] In an optional embodiment of the present invention, the method for expanding the capacity of the blockchain layer 2 network further includes:

[0077] Step 16, update the data corresponding to the empty subnode replaced by the first Merkle tree in the second contract.

[0078] In this embodiment, each time a target empty subnode is replaced with the first Merkle tree, it is preferably necessary to update the data corresponding to the empty subnode replaced by the first Merkle tree in the second contract to avoid replacing the first Merkle tree of the previous transaction in the second Merkle number of the main chain when the target empty subnode is replaced with the first Merkle tree for the second time.

[0079] In a specific embodiment 5, when the side chain initiates three transactions, namely A11, A12 and A13, as shown in Figure 3 As shown, Figure 3 It is the Merkle root of the second Merkle tree when three transactions are not initiated. When the number of accounts is not 2 n When calculating the nodes whose child nodes in the Merkle root are all empty, such as H(9,10), H(9,10,9,10); the empty child nodes of the second Merkle tree are saved in the second contract, such as

[0080] As shown in Table 2:

[0081] Tiers Hash Layer 1 H(9,10) Layer 2 H(9,10,9,10)

[0082] Table 2

[0083] like Figures 4 to 6 As shown, when the first Merkle tree and the target empty child node replacement method are not used, when A11 is added, as shown in Figure 4 As shown in the shaded area, the hash is calculated 4 times. When A12 is increased, as shown in Figure 5 As shown in the shaded area, the hash is calculated 4 times. When A12 is increased, as shown in Figure 6 As shown in the shaded area, 4 hashes are also calculated. Therefore, when 3 deposit transactions are added, a total of 4*3=12 hashes are performed. When the number of deposit transactions n=4, the number of hashes is n*tree_depth=3*4=12 times.

[0084] like Figure 7 and Figure 8 As shown, when the first Merkle tree and the target empty child node are replaced, A11 and A12 are generated into the first Merkle tree. When the first Merkle trees of A11 and A12 are added, as shown in Figure 7 As shown in the shaded area, the hash is calculated three times. When A13 is increased, as shown in Figure 8 As shown in the shaded area, 4 hash calculations are performed, so the total number of calculations is n+tree_depth=3+4=7 times.

[0085] It can be seen from the above specific embodiment 5 that when a deposit transaction is added, the number of hashes corresponding to the height tree needs to be recalculated and recorded as tree_depth hashes. When the second deposit transaction comes in, the number of hashes still needs to be recalculated tree_depth. Therefore, the number of hashes for at least one new transaction is O(n*tree_depth). On this basis, the method of merging transactions is adopted to make the number of hashes O(n+tree_depth), thereby optimizing the number of calculations of repeated hash calculations for multiple transactions.

[0086] like Fig. 9 As shown, in a specific embodiment 6, the first transaction is A, and a balanced binary tree cannot be generated. The second transaction B is waiting, and the first Merkle tree H(A, B) is formed with the second transaction B. Then the third transaction C is initiated, and the fourth transaction D is waiting. The third transaction C and the fourth transaction D are combined with H(A, B) to form the first Merkle tree of four transactions. The first Merkle tree of the four transactions is replaced with the target empty child node of the second Merkle tree on the main chain, which can greatly reduce the number of hash calculations and reduce transaction costs without reducing security.

[0087] The embodiment of the present invention obtains at least one transaction information initiated by a participant of the side chain of the blockchain through a first contract on the side chain of the blockchain; generates a first Merkle tree on the first contract according to the at least one transaction information; obtains data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through a second contract on the side chain of the blockchain; selects a target empty child node according to the data of the first Merkle tree and the at least one empty child node; replaces the position of the target empty child node with the first Merkle tree; and achieves a significant reduction in the number of hash calculations and transaction costs without reducing security.

[0088] Fig.10 The schematic diagram of the structure of the expansion device of the blockchain layer 2 network provided by the embodiment of the present invention is shown. Fig.10 As shown, the device 100 includes:

[0089] The processing module 101 is used to obtain at least one transaction information initiated by a participant of the side chain through a first contract on the side chain of the blockchain; and generate a first Merkle tree on the first contract according to the at least one transaction information;

[0090] An acquisition module 102 is used to acquire data of at least one empty child node of a second Merkle tree on a main chain of the blockchain through a second contract on a side chain of the blockchain;

[0091] The processing module 101 is further configured to select a target empty child node according to the first Merkle tree and the data of the at least one empty child node; and replace the position of the target empty child node with the first Merkle tree.

[0092] Optionally, in the processing module 101, generating a first Merkle tree on the first contract according to the at least one transaction information includes:

[0093] If a balanced binary tree is constructed according to the at least one transaction information, a first Merkle tree is generated on the first contract;

[0094] If the tree constructed based on the at least one transaction information is not a balanced binary tree, the first contract saves the at least one transaction information and waits for the next transaction information, and generates a first Merkle tree based on the at least one transaction information and the next transaction information.

[0095] Optionally, the acquisition module 102 is specifically used to traverse the second Merkle tree on the main chain of the blockchain, obtain the data of all empty child nodes on the second Merkle tree and save them in the second contract.

[0096] Optionally, the data of the empty child node includes the level of the empty child node and the hash value of the empty child node.

[0097] Optionally, in the processing module 101, selecting a target empty child node according to the first Merkle tree and the data of the at least one empty child node includes:

[0098] Get the depth of the first Merkle tree;

[0099] According to the depth of the first Merkle tree and the data of the at least one empty child node, an empty child node whose level is the same as the depth of the first Merkle tree is selected as a target empty child node.

[0100] Optionally, in the processing module 101, replacing the position of the target empty child node with the first Merkle tree includes:

[0101] Replace the level corresponding to the target empty child node with the head node of the first Merkle tree;

[0102] The nodes of the next level corresponding to the target empty child node are replaced with the nodes of the next level of the head node of the first Merkle tree, until all nodes under the target empty child node are replaced with all nodes in the first Merkle tree.

[0103] Optionally, the processing device 101 is further used to update the data corresponding to the empty sub-node replaced by the first Merkle tree in the second contract.

[0104] Fig.11Schematic diagram of the structure of the main chain and side chain in a specific embodiment provided by the present invention is shown. Fig.11 As shown, in a specific embodiment 7, the side chain includes a side chain participant module, a side chain operator module and a side chain module;

[0105] Specifically, in order to save transaction fees, the sidechain participant module initiates transactions on the sidechain, and the transaction-related interactions are carried out between the sidechain and the main chain, so that sidechain traders can save transaction fees when trading, and at the same time, the security of the transaction can be guaranteed at the same level;

[0106] The sidechain operator will take a snapshot of the blocks on the sidechain and provide a SNARK (Simplified Non-Interactive Proof) when generating the snapshot to prove that the sidechain has performed a valid state transition using a related set of transactions and sent the relevant data to the mainchain;

[0107] The side chain module includes smart contract 1, smart contract 2 and at least one side chain block. At least one side chain block constitutes a side chain. The side chain blocks include side chain block A (S-BlockA), side chain block B (S-BlockB) and side chain block C (S-BlockC), etc., wherein side chain block A is S1 before the state update and is S2 after the update, while side chain block B is S2 before the state update and is S3 after the update, and side chain block C is S3 before the state update and is S4 after the update;

[0108] Smart Contract 1 is used when a side chain participant initiates a transaction and a transaction is entered. Smart Contract 1 starts to build the first Merkle tree. If the newly initiated transaction cannot be constructed into a balanced binary tree, it will wait. If a balanced binary tree can be constructed, the corresponding node will be hashed and the corresponding hash value and the depth of the first Merkle tree will be recorded. When the second Merkle tree of the main chain is constructed, the first Merkle tree that meets the conditions will be merged into the second Merkle tree.

[0109] Smart contract 2 is used to create the second Merkle tree. If the child nodes of a node are all empty, the node is placed in the key-value pair map, where key is the corresponding level and value is the corresponding hash value.

[0110] The main chain includes a main chain module and a main chain verifier module, wherein the main chain verifier module is specifically used to verify the zero-knowledge proof SNARK to prove that the state transfer on the side chain is valid, and stores the Merkle root of the new state and the complete state data of the block on the side chain, and can also be used to verify the correctness of the block transaction so that the blockchain can normally generate blocks; and the main chain module includes a side chain smart contract and at least one main chain block, at least one main chain block constitutes the main chain, the main chain block includes the main chain block x (Blockx), the main chain block y (Blocky) and the main chain block z (Blockz), etc., wherein the main chain block x also includes the hash value of S2, the main chain block y also includes the hash value of S3, and the main chain block z also includes the hash value of S4; the side chain smart contract is used to verify the transactions in the side chain, the side chain operator packages at least one transaction in the side chain into a standard transaction, and verifies the transaction by calling the side chain smart contract. In order to reduce transaction fees, two Merkle trees are used as records in the side chain smart contract.

[0111] It should be noted that the device is a device corresponding to the above-mentioned blockchain layer 2 network expansion method. All implementation methods in the above-mentioned method embodiments are applicable to the embodiments of the device and can achieve the same technical effects.

[0112] An embodiment of the present invention provides a non-volatile computer storage medium, wherein the computer storage medium stores at least one executable instruction, and the computer executable instruction can execute the method for expanding the second-layer blockchain network in any of the above method embodiments.

[0113] Fig.12 A schematic diagram of the structure of a computing device provided by an embodiment of the present invention is shown, and the specific embodiment of the present invention does not limit the specific implementation of the computing device.

[0114] like Fig.12 As shown, the computing device may include: a processor, a communications interface, a memory, and a communication bus.

[0115] Wherein: the processor, the communication interface, and the memory communicate with each other through the communication bus. The communication interface is used to communicate with network elements of other devices such as clients or other servers. The processor is used to execute the program, and specifically can execute the relevant steps in the above-mentioned embodiment of the method for expanding the second layer network of the blockchain for computing devices.

[0116] Specifically, the program may include program codes including computer operation instructions.

[0117] The processor may be a central processing unit (CPU), or an application specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention. The one or more processors included in the computing device may be processors of the same type, such as one or more CPUs; or processors of different types, such as one or more CPUs and one or more ASICs.

[0118] The memory is used to store programs. The memory may include a high-speed RAM memory, and may also include a non-volatile memory, such as at least one disk memory.

[0119] The program can be specifically used to enable the processor to execute the expansion method of the second-layer blockchain network in any of the above-mentioned method embodiments. The specific implementation of each step in the program can refer to the corresponding descriptions in the corresponding steps and units in the above-mentioned embodiments of the second-layer blockchain network expansion method, which will not be repeated here. Those skilled in the art can clearly understand that for the convenience and simplicity of description, the specific working process of the above-described devices and modules can refer to the corresponding process description in the above-mentioned method embodiments, which will not be repeated here.

[0120] The algorithm or display provided herein is not inherently related to any particular computer, virtual system or other device. Various general purpose systems can also be used together with the teachings based on this. According to the above description, it is obvious that the structure required for constructing this type of system. In addition, the embodiment of the present invention is not directed to any specific programming language either. It should be understood that various programming languages ​​can be utilized to realize the content of the embodiment of the present invention described herein, and the description of the above specific language is to disclose the best mode of the embodiment of the present invention.

[0121] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0122] Similarly, it should be understood that in order to streamline the embodiments of the present invention and to aid in understanding one or more of the various inventive aspects, in the above description of the exemplary embodiments of the present invention, the various features of the embodiments of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, the disclosed method should not be interpreted as reflecting the following intention: that the claimed embodiments of the present invention require more features than the features explicitly recited in each claim. More specifically, as reflected in the claims below, the inventive aspects lie in less than all the features of the single embodiment disclosed above. Therefore, the claims that follow the specific embodiment are hereby expressly incorporated into the specific embodiment, wherein each claim itself serves as a separate embodiment of the present invention.

[0123] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or components in the embodiments may be combined into one module or unit or component, and in addition they may be divided into a plurality of submodules or subunits or subcomponents. Except that at least some of such features and / or processes or units are mutually exclusive, all features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device disclosed in this manner may be combined in any combination. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.

[0124] In addition, those skilled in the art will appreciate that, although some embodiments herein include certain features included in other embodiments but not other features, the combination of features of different embodiments is meant to be within the scope of the present invention and form different embodiments. For example, in the claims below, any one of the claimed embodiments may be used in any combination.

[0125] The various component embodiments of the present invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or digital signal processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components according to the embodiments of the present invention. The embodiments of the present invention may also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing an embodiment of the present invention may be stored on a computer-readable medium, or may have the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0126] It should be noted that the above embodiments illustrate rather than limit the present invention, and that those skilled in the art may devise alternative embodiments without departing from the scope of the appended claims. In the claims, any reference symbol between brackets shall not be construed as a limitation on the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "one" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention may be implemented by means of hardware comprising a number of different elements and by means of a suitably programmed computer. In a unit claim listing a number of devices, several of these devices may be embodied by the same hardware item. The use of the words first, second, and third, etc. does not indicate any order. These words may be interpreted as names. The steps in the above embodiments, unless otherwise specified, should not be understood as limitations on the order of execution.

Claims

1. A method for expanding the capacity of a blockchain layer 2 network, characterized in that: The method comprises: Obtaining, through a first contract on a side chain of the blockchain, at least one transaction information initiated by a participant of the side chain; Generate a first Merkle tree on the first contract according to the at least one transaction information; Obtain data of at least one empty child node of the second Merkle tree on the main chain of the blockchain through the second contract on the side chain of the blockchain; Selecting a target empty child node according to the first Merkle tree and the data of the at least one empty child node; The position of the target empty child node is replaced by the first Merkle tree.

2. The method for expanding the second layer network of blockchain according to claim 1, characterized in that: Generating a first Merkle tree on the first contract according to the at least one transaction information includes: If a balanced binary tree is constructed according to the at least one transaction information, a first Merkle tree is generated on the first contract; If a balanced binary tree is not constructed based on the at least one transaction information, the first contract saves the at least one transaction and waits for the next transaction, and generates a first Merkle tree based on the at least one transaction and the next transaction.

3. The method for expanding the second layer network of blockchain according to claim 1, characterized in that: The data of at least one empty child node of the second Merkle tree on the main chain of the blockchain is obtained through the second contract on the side chain of the blockchain, including: Traverse the second Merkle tree on the main chain of the blockchain, obtain the data of all empty child nodes on the second Merkle tree and save them in the second contract.

4. The method for expanding the second layer network of blockchain according to claim 3 is characterized in that: The data of the empty child node includes the level of the empty child node and the hash value of the empty child node.

5. The method for expanding the second layer network of blockchain according to claim 4 is characterized in that: Selecting a target empty child node according to the first Merkle tree and the data of the at least one empty child node includes: Get the depth of the first Merkle tree; According to the depth of the first Merkle tree and the data of the at least one empty child node, an empty child node whose level is the same as the depth of the first Merkle tree is selected as a target empty child node.

6. The method for expanding the second layer network of blockchain according to claim 5, characterized in that: Replacing the position of the target empty child node with the first Merkle tree includes: Replace the level corresponding to the target empty child node with the head node of the first Merkle tree; The nodes of the next level corresponding to the target empty child node are replaced with the nodes of the next level of the head node of the first Merkle tree, until all nodes under the target empty child node are replaced with all nodes in the first Merkle tree.

7. The method for expanding the second layer network of blockchain according to claim 1, characterized in that: Also includes: Update the data corresponding to the empty subnode replaced by the first Merkle tree in the second contract.

8. A capacity expansion device for a blockchain layer 2 network, characterized in that: The device comprises: A processing module, configured to obtain at least one transaction information initiated by a participant of the side chain through a first contract on the side chain of the blockchain; and generate a first Merkle tree on the first contract according to the at least one transaction information; An acquisition module, used to acquire data of at least one empty child node of a second Merkle tree on a main chain of the blockchain through a second contract on a side chain of the blockchain; The processing module is further used to select a target empty child node according to the data of the first Merkle tree and the at least one empty child node; and replace the position of the target empty child node with the first Merkle tree.

9. A computing device comprising: A processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface communicate with each other via the communication bus; The memory is used to store at least one executable instruction, and the executable instruction enables the processor to perform an operation corresponding to the method for expanding the second-layer blockchain network as described in any one of claims 1-7.

10. A computer storage medium, wherein at least one executable instruction is stored in the storage medium, and the executable instruction enables a processor to perform operations corresponding to the method for expanding the capacity of a blockchain layer 2 network as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Main chain storage method and system based on blockchain intelligent contract and storage medium

    CN110033243A

  • Distributed electric quantity transaction block chain storage method and device based on Merkel tree

    CN112600875A