CN115987799A - Method, device and equipment for expanding two-layer network of block chain - Google Patents
Method, device and equipment for expanding two-layer network of block chain Download PDFInfo
- Publication number
- CN115987799A CN115987799A CN202111199523.XA CN202111199523A CN115987799A CN 115987799 A CN115987799 A CN 115987799A CN 202111199523 A CN202111199523 A CN 202111199523A CN 115987799 A CN115987799 A CN 115987799A
- Authority
- CN
- China
- Prior art keywords
- tree
- node
- block chain
- contract
- child node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Data Exchanges In Wide-Area Networks (AREA)
Abstract
The invention discloses a method, a device and equipment for expanding a block chain two-layer network, wherein the method comprises the following steps: acquiring at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of a block chain; generating a first Merck tree on the first contract according to the at least one transaction message; acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain; selecting a target null sub node according to the data of the first Merck tree and the at least one null sub node; replacing the location of the target null child node with a first Merck tree. Through the mode, the invention greatly reduces the hash calculation times and reduces the transaction cost under the condition of not reducing the security.
Description
Technical Field
The invention relates to the technical field of block chains, in particular to a method, a device and equipment for expanding a two-layer network of a block chain.
Background
In the prior art, there are three main expansion schemes for a two-layer network of a block chain:
one is a status channel, but the participants of the status channel may have to wait for a relatively long period of time, usually 24 hours, before exiting, and the main chain needs to be monitored frequently to ensure that their counterparty does not use a certain past status to exit, while the status channel is generally opened only between two participants;
second, the "unsupervised" side-chain technique Plasma, but it must provide the complete history of the token while it is being transferred, and the exit mechanism is very complex;
thirdly, side chain Rollup technology, but in the process of calculating the mercker tree, when a deposit transaction is received and the mercker root is recalculated, the hash times need to be calculated, when a deposit transaction is added and the mercker root is calculated, the hash times still need to be calculated, and the calculation cost is higher for zk-SNARK-friendly hash functions.
Disclosure of Invention
In view of the foregoing, embodiments of the present invention are provided to provide a method, an apparatus, and a device for expanding a blockchain two-layer network, which overcome the foregoing problems or at least partially solve the foregoing problems.
According to an aspect of the embodiments of the present invention, a method for expanding a two-layer network of a block chain is provided, where the method includes:
acquiring at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of a block chain;
generating a first Merck tree on the first contract according to the at least one transaction message;
acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain;
selecting a target null child node according to the first merkel tree and the data of the at least one null child node;
replacing the location of the target null child node with a first Merck tree.
According to another aspect of the embodiments of the present invention, there is provided a capacity expansion apparatus for a block chain two-layer network, where the apparatus includes:
the processing module is used for acquiring at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of the block chain; generating a first Merck tree on the first contract according to the at least one transaction message;
the acquisition module is used for acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain;
the processing module is further used for selecting a target null sub node according to the data of the first Mercker tree and the at least one null sub node; replacing the location of the target null child node with a first Merck tree.
According to still another aspect of an embodiment of the present invention, there is provided a computing device including: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction enables the processor to execute the operation corresponding to the capacity expansion method of the block chain two-layer network.
According to another aspect of the embodiments of the present invention, a computer storage medium is provided, where at least one executable instruction is stored in the storage medium, and the executable instruction causes a processor to perform an operation corresponding to the above method for expanding a volume of a blockchain two-layer network.
According to the scheme provided by the embodiment of the invention, the capacity expansion method of the block chain two-layer network can acquire at least one transaction message initiated by the participant of the side chain through the first contract on the side chain of the block chain; generating a first Merck tree on the first contract according to the at least one transaction message; acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain; selecting a target null sub node according to the data of the first Merck tree and the at least one null sub node; the position of the target void node is replaced by the first Mercker tree, so that the problem that Hash is repeatedly calculated for many times when a plurality of deposit transactions are involved in the Mercker root calculation process in the prior art is solved, and the advantages that the Hash calculation times are greatly reduced and the transaction cost is reduced under the condition that the safety is not reduced are achieved.
The foregoing description is only an overview of the technical solutions of the embodiments of the present invention, and the embodiments of the present invention can be implemented according to the content of the description in order to make the technical means of the embodiments of the present invention more clearly understood, and the detailed description of the embodiments of the present invention is provided below in order to make the foregoing and other objects, features, and advantages of the embodiments of the present invention more clearly understandable.
Drawings
Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the embodiments of the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
fig. 1 is a flowchart illustrating a method for expanding a block chain two-layer network according to an embodiment of the present invention;
FIG. 2 shows a schematic structural diagram of a first Merck tree in a specific embodiment provided by the present invention;
FIG. 3 shows a schematic representation of the Merck root of a second Merck tree without a transaction initiated in a specific embodiment provided by the invention;
FIG. 4 shows a schematic diagram of the Mercker root of the second Mercker tree when initiating an A11 transaction in a specific embodiment provided by the present invention;
FIG. 5 is a diagram illustrating a Merck root of a second Merck tree in initiating an A12 transaction in a specific embodiment provided by the present invention;
FIG. 6 shows a schematic illustration of the Merck root of the second Merck tree when initiating an A13 transaction in the specific embodiment provided by the invention;
FIG. 7 is a diagram illustrating the insertion of a first Merck tree into a null child node of a second Merck tree in a specific embodiment provided by the present invention;
FIG. 8 is a diagram illustrating the insertion of A13 into a null child node of a second Mercker tree in a specific embodiment provided by the present invention;
FIG. 9 is a schematic flow chart illustrating the performance of four transactions in a particular embodiment of the present invention;
fig. 10 is a schematic structural diagram of a capacity expansion device of a block chain two-layer network according to an embodiment of the present invention;
FIG. 11 shows a schematic structural view of the main chain and the side chain in a specific embodiment provided by the present invention;
fig. 12 is a schematic structural diagram of a computing device provided by an embodiment of the present invention.
Detailed Description
Exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the invention are shown in the drawings, it should be understood that the invention can be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the invention to those skilled in the art.
Fig. 1 is a flowchart illustrating a method for expanding a block chain two-layer network according to an embodiment of the present invention.
As shown in fig. 1, the method comprises the steps of:
and step 15, replacing the position of the target empty child node with a first Merck tree.
Wherein the data of the empty child node comprises a hierarchy of the empty child node and a hash value of the empty child node.
In the embodiment, a first contract and a second contract are established on a side chain, at least one piece of transaction information initiated by a participant of the side chain is obtained through the first contract, a first Mercker tree comprising the at least one piece of transaction information is generated on the first contract, the second contract obtains data of at least one vacancy node of a second Mercker tree on a main chain, a target vacancy node is selected from the at least one vacancy node according to the first Mercker tree, and the target vacancy node is replaced with the first Mercker tree; the method can greatly reduce the times of hash calculation and reduce transaction cost under the condition of not reducing transaction security;
the side chain can mutually transfer assets with the main chain of the block chain, and meanwhile, the side chain can selectively send a snapshot of the block head to the main chain, so that the generation of bifurcation is prevented. The generation of bifurcation is effectively prevented and the safety is improved through the snapshot of the block head; here, the block header stores meta-information of the block, which is used to perform some identification, verification and description on the contents of the block;
the main chain of the block chain is an important guarantee of the block chain two-layer network capacity expansion method on the safety; the method is used as an arbitrator in a block chain two-layer network capacity expansion method and is used for guaranteeing the safety when a transaction is carried out with a side chain.
It should be noted that the first contract is preferably a tacle tree in a process, the first contract may be used to generate a first tacle tree when there is a participant initiating at least one transaction message, and the first contract may also be used to merge the first tacle tree in the first contract with a second tacle tree on the main chain;
the second contract may be used to obtain data for at least one null child node of a second merkel tree on the backbone of the block chain.
In an alternative embodiment of the present invention, step 12 includes:
step 121, if a balanced binary tree is constructed according to the at least one piece of transaction information, generating a first Mercker tree on the first contract;
and step 122, if the binary tree is not a balanced binary tree constructed according to the at least one piece of transaction information, storing the at least one piece of transaction information by the first contract, waiting for next piece of transaction information, and generating a first Mercker tree according to the at least one piece of transaction information and the next piece of transaction information.
In this embodiment, a side chain participant initiates a transaction, a first contract receives at least one piece of transaction information initiated by the side chain participant, and when the first contract can generate a balanced binary tree according to the at least one piece of transaction information, a first mercker tree is generated, where the first mercker tree is the balanced binary tree; when the first contract can not generate a balanced binary tree according to at least one transaction message, storing the at least one transaction message and waiting for the next transaction message, and generating a first Mercker tree according to the at least one transaction message and the next transaction message;
it should be noted that, because each transaction information is at the same level on the first mercker tree when generating the first mercker tree, when at least one transaction information cannot construct a balanced binary tree, a balanced binary tree can be constructed according to at least one transaction information and the next transaction information, so as to generate the first mercker tree;
when the balanced binary tree is not an empty tree, the balanced binary tree satisfies the following conditions: the left and right subtrees of any one node are balanced binary trees, and the absolute value of the difference between the heights does not exceed 1.
FIG. 2 shows a schematic structural diagram of a first Mercker tree in a specific embodiment provided by the present invention. As shown in fig. 2, in a specific embodiment 1, when a side-chain participant initiates 3 transactions (a first transaction information is A1, a second transaction information is A2, and a third transaction information is A3), a first merck tree (archive _ tree) is first constructed by A1 and A2, and in the process of constructing the archive _ tree, the hash number is 1 and the depth is 1, wherein A3 does not participate in constructing the merck tree.
In a specific embodiment 2, initializing the Mercker tree (archive _ tree), initializing the Mercker tree to an empty tree, when a deposit transaction A enters, saving and waiting transaction A, when a second deposit transaction B enters, calculating the hash values H (A, B) of A and B, constructing a first Mercker tree, saving the saved hash values H (A, B), which means that the first Mercker tree contains 2 deposit transactions and the depth of archive _ tree is 1, when a third deposit transaction C enters, saving and waiting until a fourth deposit transaction D enters, calculating the hash values H (C, D) of the third and fourth deposit transactions, and calculating the hash values of H (A, B) and H (C, D), to obtain H (H (A, B), H (C, D)), the hash values H (H (A, B), H (C, D)), and the first deposit number of 4 Mercker transactions, and the depth of the first deposit tree 2 of 4 Mercker transactions.
In an alternative embodiment of the present invention, step 13 includes:
and traversing the second Mercker tree on the main chain of the block chain, acquiring data of all the empty child nodes on the second Mercker tree, and storing the data in a second contract.
Wherein the data of the null child node includes a hierarchy of the null child node and a hash value of the null child node.
In this embodiment, the data of the empty child node on the second merkel tree is preferably a key value pair (map), the second merkel tree on the main chain is traversed, if all child nodes of the node on the second merkel tree are empty, the node is taken as an empty child node, and the data of the empty child node is stored in a second contract; the second contract realizes the statistics of the empty child nodes of the second Mercker tree on the main chain, and simultaneously the second contract stores the data of all the empty child nodes on the second Mercker tree;
the empty child node of the second merkel tree means that the node of the previous level of the empty child node is not empty, and the nodes of the next level are all empty child nodes; the data of the null child node includes a hierarchy of the null child node and a hash value of the null child node.
In a specific embodiment 3, the data of the null child node includes a hierarchy of the null child node and a hash value of the null child node, as shown in the following table:
hierarchy | Hashing |
Layer | |
1 | hash(0,0) |
|
hash(hash(0,0),hash(0,0)) |
... | … |
Layer tree_depth | hash(hash(hash(…hash(0,0),))…) |
TABLE 1
As shown in table 1, the hash value of the null sub-node of the first layer of the second merkel tree is hash (0,0), the hash value of the null sub-node of the second layer of the second merkel tree is hash (hash (0,0), hash (0,0)), and the hash value of the null sub-node of the third tree _ depth layer of the second merkel tree is hash (hash (… hash (0,0),)) …).
In an alternative embodiment of the present invention, step 14 includes:
step 141, obtaining the depth of the first merkel tree;
and 142, selecting the null sub node with the same level of the null sub node as the depth of the first merkel tree as a target null sub node according to the depth of the first merkel tree and the data of the at least one null sub node.
In this embodiment, a first merkel tree is generated according to at least one piece of transaction information, the depth of the first merkel tree is at least 1, all null sub nodes and data of all null sub nodes of a second merkel tree in a second contract are read, and a null sub node having the same number of layers as the depth of the first merkel tree in all null sub nodes is selected as a target null sub node.
In an alternative embodiment of the present invention, step 15 includes:
step 151, replacing the hierarchy corresponding to the target null sub node with a head node of a first merkel tree;
and 152, replacing the next level node corresponding to the target empty child node with the next level node of the head node of the first merkel tree until all the nodes under the target empty child node and all the nodes in the first merkel tree are replaced.
In this embodiment, since the level of the target empty sub node selected in step 14 is the same as the depth of the first merkel tree, the target empty sub node is replaced with the head node of the first merkel tree, the node of the next level corresponding to the target empty sub node is replaced with the node of the next level of the head node of the first merkel tree, and the replacement is performed according to the level, so that the nodes of all levels below the target empty sub node can be replaced with all the nodes of the first merkel tree;
it should be noted that, after being replaced, all nodes below the target null sub node of the second merkel tree have unchanged relative positions with all nodes below the head node of the first merkel tree, that is, when the node below the head node of the first merkel tree (balanced binary tree) is L1, the node above the left sub tree of the next layer of the target null sub node is L1, and the node above the right sub tree is R1, therefore, when being replaced onto the target null sub node of the second merkel tree, the node above the left sub tree of the next layer of the target null sub node is L1, and the node below the right sub tree is R1.
In a specific embodiment 4, the first merkel tree is an arch _ tree, the depth of the first merkel tree is the merkel root leaf1 of the arch _ tree _ depth, the key value pair map value in the second contract is read, the second merkel tree (balance _ tree) of the main chain is queried, the empty child node leaf2 with the level of the arch _ tree _ depth and all the child nodes empty is the empty child node leaf2, and the leaf1 in the arch _ tree is replaced by the empty child node leaf2 in the second merkel tree.
In an optional embodiment of the present invention, the method for expanding a block chain two-layer network further includes:
and step 16, updating data corresponding to the empty child node replaced by the first Mercker tree in the second contract.
In this embodiment, each time the target dummy node and the first merkel tree are replaced once, it is preferable that data corresponding to the dummy node replaced by the first merkel tree in the second contract needs to be updated to avoid replacing the target dummy node and the first merkel tree for the second time, and the first merkel tree of the last transaction in the second merkel number of the main chain is replaced.
In a specific example 5, when three transactions are initiated by the side chain, respectively A11, A12 and A13, as shown in FIG. 3, FIG. 3 is the Merck root of the second Merck tree when three transactions are not initiated, and when the number of accounts is not 2 n Calculating nodes with all empty nodes in the merkel root, such as H (9,10) and H (9,10,9,10); saving the empty child nodes of the second Mercker tree in a second contract, e.g. by
Shown in Table 2:
hierarchy level | Hashing |
Layer 1 | H(9,10) |
Layer 2 | H(9,10,9,10) |
TABLE 2
As shown in fig. 4 to 6, when the first merkel tree and the target empty child node replacement are not used, when a11 is added, 4 hashes are calculated as shown in the shaded portion in fig. 4, when a12 is added, 4 hashes are calculated as shown in the shaded portion in fig. 5, when a12 is added, 4 hashes are also calculated as shown in the shaded portion in fig. 6, and therefore, when 3 deposit transactions are added, 4 × 3=12 hashes are performed in total, and when the number of deposit transactions n =4, the number of hashes is n = tree _ depth =3 × 4= 12;
as shown in fig. 7 and 8, when a11 and a12 are generated into a first merkel tree using the first merkel tree and the target null node replacement, when the first merkel tree of a11 and a12 is added, hash is calculated 3 times as shown by the shaded portion of fig. 7, and when a13 is added, hash is calculated 4 times as shown by the shaded portion of fig. 8, so that the total number of calculations is n + tree _ depth =3+4=7 times.
As can be seen from the foregoing specific embodiment 5, when a new deposit transaction is added, the hash number corresponding to the height tree needs to be recalculated and recorded as the tree _ depth hash, and when a second deposit transaction comes, the tree _ depth hash still needs to be recalculated, so that the hash number of the at least one new deposit transaction is O (n _ tree _ depth), and on this basis, a merge transaction mode is adopted, so that the hash number is O (n + tree _ depth), thereby implementing the optimization of the calculation number of the hash for repeated calculation of multiple transactions.
As shown in fig. 9, in a specific embodiment 6, the first transaction is a, a balanced binary tree cannot be generated, a second transaction B is waited, the first mercker tree H (a, B) is formed with the second transaction B, a third transaction C is initiated again, a fourth transaction D is waited to enter, the third transaction C and the fourth transaction D are combined with H (a, B) to form a first mercker tree of the four transactions, and the first mercker tree of the four transactions is replaced with a target null node of the second mercker tree on the main chain, so that the number of times of hash calculation can be greatly reduced without reducing security, and transaction cost can be reduced.
The embodiment of the invention obtains at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of a block chain; generating a first Merck tree on the first contract according to the at least one transaction message; acquiring data of at least one null sub node of a second Merckel tree on a main chain of the block chain through a second contract on a side chain of the block chain; selecting a target null sub node according to the data of the first Merck tree and the at least one null sub node; replacing the position of the target null-child node with a first Merck tree; under the condition of not reducing the security, the hash calculation times are greatly reduced, and the transaction cost is reduced.
Fig. 10 illustrates a schematic structural diagram of a capacity expansion device of a block chain two-layer network according to an embodiment of the present invention. As shown in fig. 10, the apparatus 100 includes:
the processing module 101 is configured to obtain at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of the block chain; generating a first Merck tree on the first contract according to the at least one transaction message;
an obtaining module 102, configured to obtain, through a second contract on a side chain of a block chain, data of at least one null child node of a second merkel tree on a main chain of the block chain;
the processing module 101 is further configured to select a target null sub node according to the first merkel tree and the data of the at least one null sub node; replacing the location of the target null-child node with a first merkel tree.
Optionally, in the processing module 101, generating a first merck tree on the first contract according to the at least one piece of transaction information includes:
if a balanced binary tree is constructed according to the at least one piece of transaction information, generating a first Mercker tree on the first contract;
if the binary tree is not a balanced binary tree constructed according to the at least one piece of transaction information, the first contract stores the at least one piece of transaction information and waits for next piece of transaction information, and a first Mercker tree is generated according to the at least one piece of transaction information and the next piece of transaction information.
Optionally, the obtaining module 102 is specifically configured to traverse a second merkel tree on the main chain of the block chain, obtain data of all null child nodes on the second merkel tree, and store the data in a second contract.
Optionally, the data of the null child node includes a hierarchy of the null child node and a hash value of the null child node.
Optionally, in the processing module 101, selecting a target null-child node according to the first merkel tree and the data of the at least one null-child node, includes:
obtaining the depth of the first Mercker tree;
and selecting a null child node with the same level of the null child node as the depth of the first Mercker tree as a target null child node according to the depth of the first Mercker tree and the data of the at least one null child node.
Optionally, in the processing module 101, replacing the position of the target null child node with a first merkel tree includes:
replacing the hierarchy corresponding to the target null child node with a head node of a first Mercker tree;
and replacing the next-level node corresponding to the target null sub node with the next-level node of the head node of the first Mercker tree until all the nodes under the target null sub node and all the nodes in the first Mercker tree are replaced.
Optionally, the processing device 101 is further configured to update data corresponding to the empty child node replaced by the first merkel tree in the second contract.
FIG. 11 shows a schematic representation of the structure of the main and side chains in a particular embodiment provided by the present invention. As shown in fig. 11, in a specific embodiment 7, the sidechain includes a sidechain participant module, a sidechain operator module, and a sidechain module;
specifically, in order to save transaction cost, the side chain participant module initiates a transaction on the side chain, and the side chain and the main chain perform interaction related to the transaction, so that a side chain trader can save transaction cost during the transaction, and meanwhile, the security of the transaction can obtain the same level of security guarantee;
the side chain operator will take a snapshot of the blocks on the side chain and, when generating the snapshot, provide a SNARK (simplified non-interactive proof) to prove that the side chain has performed a valid state transition using the relevant set of transactions and send the relevant data to the main chain;
the side chain module comprises an intelligent contract 1, an intelligent contract 2 and at least one side chain block, wherein the at least one side chain block forms a side chain, the side chain block comprises a side chain block A (S-Block A), a side chain block B (S-Block B), a side chain block C (S-Block C) and the like, the side chain block A is S1 before state updating and is S2 after state updating, the side chain block B is S2 before state updating and is S3 after state updating, the side chain block C is S3 before state updating and is S4 after state updating;
the intelligent contract 1 is used for starting to construct a first Mercker tree when a side chain participant initiates a transaction and the transaction enters, waiting if a newly initiated transaction cannot construct a balanced binary tree, hashing a corresponding node if the balanced binary tree can be constructed, recording a corresponding hash value and the depth of the first Mercker tree, and merging the first Mercker tree meeting the conditions into a second Mercker tree when constructing a second Mercker tree of a main chain;
the intelligent contract 2 is used for placing a node into the key value pair map if child nodes of the node are all empty when a second Mercker tree is created, wherein key is a corresponding hierarchy and value is a corresponding hash value;
the main chain comprises a main chain module and a main chain verifier module, wherein the main chain verifier module is specifically used for verifying a zero-knowledge proof SNARK to prove that state transfer on the side chain is effective, and storing a Mercker root in a new state and complete state data of blocks on the side chain, and also can be used for verifying the correctness of block transaction to enable the block chain to normally generate blocks; the main chain module comprises a side chain intelligent contract and at least one main chain block, wherein the main chain block forms a main chain, the main chain block comprises a main chain block x (Blockx), a main chain block y (Blocky), a main chain block z (Blockz) and the like, the main chain block x further comprises a hash value of S2, the main chain block y further comprises a hash value of S3, and the main chain block z further comprises a hash value of S4; the side chain intelligent contract is used for verifying the transaction in the side chain, the side chain operator packs at least one transaction in the side chain into a standard transaction, the intelligent contract verifies the transaction by calling the side chain intelligent contract, and in order to reduce transaction fee, two Mercker trees are used as records in the side chain intelligent contract.
It should be noted that the apparatus is an apparatus corresponding to the above method for expanding a volume of a two-layer network of a block chain, and all implementation manners in the above method embodiment are applicable to the embodiment of the apparatus, and the same technical effect can be achieved.
The embodiment of the invention provides a nonvolatile computer storage medium, wherein at least one executable instruction is stored in the computer storage medium, and the computer executable instruction can execute the capacity expansion method of the two-layer network of the block chain in any method embodiment.
Fig. 12 is a schematic structural diagram of a computing device according to an embodiment of the present invention, where the specific embodiment of the present invention does not limit a specific implementation of the computing device.
As shown in fig. 12, the computing device may include: a processor (processor), a Communications Interface (Communications Interface), a memory (memory), and a Communications bus.
Wherein: the processor, the communication interface, and the memory communicate with each other via a communication bus. A communication interface for communicating with network elements of other devices, such as clients or other servers. The processor is configured to execute a program, and may specifically execute the relevant steps in the above capacity expansion method embodiment for a blockchain two-layer network of a computing device.
In particular, the program may include program code comprising computer operating instructions.
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 an embodiment of the invention. The computing device includes one or more processors, which may be the same type of processor, such as one or more CPUs; or may be different types of processors such as one or more CPUs and one or more ASICs.
And the memory is used for storing programs. The memory may comprise high-speed RAM memory, and may also include non-volatile memory (non-volatile memory), such as at least one disk memory.
The program may be specifically configured to enable the processor to execute the capacity expansion method of the block chain two-layer network in any of the method embodiments. For specific implementation of each step in the program, reference may be made to corresponding steps and corresponding descriptions in units in the above embodiment of the method for expanding a block chain two-layer network, which are not described herein again. It can be clearly understood by those skilled in the art that, for convenience and simplicity of description, the specific working processes of the above-described devices and modules may refer to the corresponding process descriptions in the foregoing method embodiments, and are not described herein again.
The algorithms or displays presented herein are not inherently related to any particular computer, virtual system, or other apparatus. Various general purpose systems may also be used with the teachings herein. The required structure for constructing such a system will be apparent from the description above. In addition, embodiments of the present invention are not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of embodiments of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of use of an embodiment of the present invention.
In the description provided herein, numerous specific details are set forth. However, it is understood that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the embodiments of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be interpreted as reflecting an intention that: that is, the claimed embodiments of the invention require more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
Various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. Those skilled in the art will appreciate that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functionality of some or all of the components according to embodiments of the present invention. Embodiments of the invention may also be implemented as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing embodiments of the present invention may be stored on computer-readable media or may be in 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.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. Embodiments of the invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names. The steps in the above embodiments should not be construed as limiting the order of execution unless specified otherwise.
Claims (10)
1. A method for expanding a two-layer network of a block chain is characterized in that the method comprises the following steps:
acquiring at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of a block chain;
generating a first Merck tree on the first contract based on the at least one transaction message;
acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain;
selecting a target null child node according to the first merkel tree and the data of the at least one null child node;
replacing the location of the target null child node with a first Merck tree.
2. A method for expanding a block chain two-layer network according to claim 1, wherein generating a first merkel tree on the first contract according to the at least one transaction message comprises:
if a balanced binary tree is constructed according to the at least one piece of transaction information, generating a first Mercker tree on the first contract;
if the balanced binary tree is not constructed according to the at least one piece of transaction information, the first contract stores the at least one piece of transaction and waits for the next piece of transaction, and a first Mercker tree is generated according to the at least one piece of transaction and the next piece of transaction.
3. A method for expanding a block chain two-layer network according to claim 1, wherein acquiring data of at least one empty child node of a second merkel tree in a main chain of the block chain by a second contract on a side chain of the block chain includes:
and traversing the second Mercker tree on the main chain of the block chain, acquiring data of all the empty child nodes on the second Mercker tree, and storing the data in a second contract.
4. A method for expanding a block chain two-layer network according to claim 3, wherein the data of the null child node includes a level of the null child node and a hash value of the null child node.
5. A method of expanding a block chain two-layer network according to claim 4, wherein selecting a target null sub-node according to the data of the first merkel tree and the at least one null sub-node comprises:
obtaining the depth of the first Mercker tree;
and selecting a null child node with the same level of the null child node as the depth of the first Mercker tree as a target null child node according to the depth of the first Mercker tree and the data of the at least one null child node.
6. A method for expanding a block chain two-layer network according to claim 5, wherein replacing the position of the target null child node with a first merkel tree comprises:
replacing the hierarchy corresponding to the target null child node with a head node of a first Mercker tree;
and replacing the next-level node corresponding to the target null sub node with the next-level node of the head node of the first Mercker tree until all the nodes under the target null sub node and all the nodes in the first Mercker tree are replaced.
7. A method for expanding a block chain two-layer network according to claim 1, further comprising:
and updating data corresponding to the empty child node replaced by the first Mercker tree in the second contract.
8. An expansion device for a block chain two-layer network, the device comprising:
the processing module is used for acquiring at least one piece of transaction information initiated by a participant of a side chain through a first contract on the side chain of the block chain; generating a first Merck tree on the first contract according to the at least one transaction message;
the acquisition module is used for acquiring data of at least one empty child node of a second Mercker tree on a main chain of the block chain through a second contract on a side chain of the block chain;
the processing module is further used for selecting a target null sub node according to the data of the first Mercker tree and the at least one null sub node; replacing the location of the target null-child node with a first merkel tree.
9. A computing device, comprising: the system comprises a processor, a memory, a communication interface and a communication bus, wherein the processor, the memory and the communication interface complete mutual communication through the communication bus;
the memory is used for storing at least one executable instruction, and the executable instruction causes the processor to execute the operation corresponding to the capacity expansion method of the block chain two-layer network according to any one of claims 1-7.
10. A computer storage medium having stored therein at least one executable instruction for causing a processor to perform operations corresponding to the method of expanding a volume of a blockchain two-tier network according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111199523.XA CN115987799A (en) | 2021-10-14 | 2021-10-14 | Method, device and equipment for expanding two-layer network of block chain |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111199523.XA CN115987799A (en) | 2021-10-14 | 2021-10-14 | Method, device and equipment for expanding two-layer network of block chain |
Publications (1)
Publication Number | Publication Date |
---|---|
CN115987799A true CN115987799A (en) | 2023-04-18 |
Family
ID=85964813
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111199523.XA Pending CN115987799A (en) | 2021-10-14 | 2021-10-14 | Method, device and equipment for expanding two-layer network of block chain |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN115987799A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116628083A (en) * | 2023-04-27 | 2023-08-22 | 中国人民解放军战略支援部队信息工程大学 | Block chain transaction data capacity expansion storage method and system |
-
2021
- 2021-10-14 CN CN202111199523.XA patent/CN115987799A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN116628083A (en) * | 2023-04-27 | 2023-08-22 | 中国人民解放军战略支援部队信息工程大学 | Block chain transaction data capacity expansion storage method and system |
CN116628083B (en) * | 2023-04-27 | 2024-05-24 | 中国人民解放军战略支援部队信息工程大学 | Block chain transaction data capacity expansion storage method and system |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN108846659B (en) | Block chain-based transfer method and device and storage medium | |
CN108595157B (en) | Block chain data processing method, device, equipment and storage medium | |
EP3321819B1 (en) | Device, method and program for securely reducing an amount of records in a database | |
CN108681565B (en) | Block chain data parallel processing method, device, equipment and storage medium | |
EP3779760B1 (en) | Blockchain-based data processing method and apparatus, and electronic device | |
CN113329031A (en) | Method and device for generating state tree of block | |
CN110503558A (en) | A kind of processing method and processing device based on block catenary system | |
CN111444196B (en) | Method, device and equipment for generating Hash of global state in block chain type account book | |
CN108769264B (en) | Block chain domain division method | |
CN112651724A (en) | Cross-chain interaction method, device and system | |
WO2016118429A1 (en) | System for efficient processing of transaction requests related to an account in a database | |
CN112074818A (en) | Method and node for enabling access to past transactions in a blockchain network | |
CN111161078A (en) | One-to-many block chain transfer realization method | |
CN105051708A (en) | Apparatus and methods for a distributed memory system including memory nodes | |
CN110659905A (en) | Transaction verification method, device, terminal equipment and storage medium | |
CN113163011A (en) | Method, system, device and storage medium for modifying data in block chain | |
CN115987799A (en) | Method, device and equipment for expanding two-layer network of block chain | |
CN108958973A (en) | Distributed file system correcting and eleting codes data reconstruction memory node selection method and device | |
CN106775481A (en) | Method for reading data and equipment | |
CN110706108B (en) | Method and apparatus for concurrently executing transactions in a blockchain | |
CN107392745B (en) | Reconciliation data fragmentation processing method | |
CN107295059A (en) | The statistical system and method for service propelling amount | |
CN114723534B (en) | Block chain-based e-commerce transaction rationality judging method and related equipment | |
CN111260364A (en) | Extensible quick payment method and system based on block chain | |
CN115358825A (en) | Matching transaction method and system based on block chain prediction machine |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |