Alliance chain account book optimization method and device, equipment, medium and product
By inserting target fields and replacing full node blocks in the alliance chain, the problem of ledger data storage pressure in the alliance chain is solved and the long-term operating efficiency of the alliance chain is ensured.
Patent Information
- Application Number
- CN202410249068.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2024-10-18
- Estimated Expiration
- 2044-03-05
AI Technical Summary
The full backup mechanism of ledger data in the alliance chain results in a shortage of node storage resources, making it difficult to support more and more ledger data. When new nodes join, the block ledger synchronization time becomes longer and longer, affecting the long-term operating efficiency of the alliance chain network.
When it is detected that the number of blocks in the full node chain of the computing network alliance chain meets the segmentation conditions, a target field is inserted into the current configuration block to indicate the segmentation position of the block and the hash address of the previous configuration block, and when the When the node replacement condition is used, the block area to be replaced is searched based on this field, and the full node block is replaced with a light node block to reduce the storage burden.
By inserting target fields into the blockchain and replacing full node blocks, the burden of full block ledger storage is reduced, effectively solving the ledger storage pressure on nodes and promoting the sustainable development of the computing power network alliance chain.
Smart Images

Figure CN118802481A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the technical field of blockchain, and in particular to a ledger optimization method, device, equipment, medium and product for a consortium chain. Background Art
[0002] The computing power network connects multi-level computing power resources such as network, cloud, data, intelligence, security, edge, end, and chain to provide a new type of information infrastructure with integrated services; however, due to the ubiquitous distribution, complex situation, and large number of computing power nodes in the computing power network, it brings problems such as trust and collaboration to the computing power network.
[0003] Blockchain has the characteristics of decentralization, immutability, and traceability. Therefore, blockchain can solve the trust problem very well. Alliance chain is a type of blockchain owned by members within the alliance. It is highly controllable and easy to reach consensus. Building a computing network based on alliance chain can effectively solve the problems of insufficient trust, opaque information, and poor collaboration among partners in the computing network. However, due to the full backup mechanism of the ledger data of the alliance chain, the node storage resources in the blockchain will be tight and it will be difficult to support more and more ledger data. In addition, the addition of new nodes will make the synchronization time of the block ledger longer and longer, making it difficult to ensure the long-term operation efficiency of the alliance chain network. Therefore, solving the problem of in-chain ledger storage is the primary issue to ensure the normal operation of the computing network alliance chain. Summary of the invention
[0004] The embodiments of the present disclosure at least provide a method, device, equipment, medium and product for optimizing the ledger of a consortium chain.
[0005] In a first aspect, the present disclosure provides a ledger optimization method for a consortium chain, including:
[0006] When it is detected that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition, a target field is inserted into the current configuration block of the computing network alliance chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block;
[0007] When it is detected that the full node chain meets the node replacement condition, searching for the block area to be replaced based on the target field in the configuration block;
[0008] Search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
[0009] In an optional implementation, inserting a target field into the current configuration block of the computing network alliance chain includes:
[0010] Inserting a first field and a second field into the metadata structure of the current configuration block; wherein the first field is used to indicate an identification bit of a segment position, and the second field is used to indicate a hash address of a previous configuration block before the current configuration block.
[0011] In an optional implementation manner, the detecting that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition includes:
[0012] When it is detected that the number of configuration blocks between the current configuration block and the first configuration block in the full-node chain meets the first number requirement, it is determined that the number of blocks in the full-node chain meets the segmentation condition; wherein the first configuration block is the configuration block with the previous insertion identification bit of the current configuration block in the full-node chain.
[0013] In an optional implementation, when it is detected that the full node chain satisfies the node replacement condition, searching for the block area to be replaced based on the target field in the configuration block includes:
[0014] In order from back to front, search the full node chain for the first configuration block with the identification bit inserted, to obtain the second configuration block;
[0015] A specified number of configuration blocks located between the second configuration block and the third configuration block in the full node chain are determined as the block area to be replaced; wherein the third configuration block is a configuration block with an identification bit inserted after the second configuration block.
[0016] In an optional implementation, the computing network alliance chain includes multiple organizations, each of which includes an anchor node and an endorsement node; wherein the endorsement node is used to receive the full node block sent by the master node in the organization, and the anchor node is used to receive the light node block sent by the master node in the organization.
[0017] In an optional implementation, after replacing the full node block with the corresponding light node block, the method further includes:
[0018] Determine in the computing network alliance chain the block that has been replaced with the corresponding light node block to obtain a backup block;
[0019] Backing up the backup block in a backup node of the first organization, and creating a virtual chain based on the backup block;
[0020] The routing table set in the anchor node of the first organization writes the block routing information of the backup block.
[0021] In an optional implementation manner, the method further includes:
[0022] In response to a data query request, determining a backup organization of the historical data to be queried based on the routing table, and determining a backup node for backing up the historical data in the backup organization;
[0023] The historical data is searched based on the virtual chain running in the backup node.
[0024] In an optional implementation manner, the backup node includes a primary backup node and a secondary backup node, and the method further includes:
[0025] Calculating a first Merkle root hash value based on a block header of a backup block in the primary backup node, and calculating a second Merkle root hash value based on a block header of a backup block in the secondary backup node;
[0026] Based on the first Merkle tree root hash value and the second Merkle tree root hash value, the consistency of the backup blocks in the primary backup node and the secondary backup node is verified.
[0027] In an optional implementation, after replacing the full node block with the corresponding light node block, the method further includes:
[0028] Calculate the root value of the Bucket tree of the full-node on-chain state database in each organization of the computing network alliance chain to obtain multiple roots;
[0029] The consistency and integrity of the world state within the computing network alliance chain are verified based on the multiple roots.
[0030] In a second aspect, the embodiment of the present disclosure provides a ledger optimization device for a consortium chain, including:
[0031] An insertion unit, configured to insert a target field into a current configuration block of the computing network alliance chain when detecting that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block;
[0032] A search unit, configured to search for a block area to be replaced based on a target field in the configuration block when it is detected that the full node chain satisfies a node replacement condition;
[0033] The block replacement unit is used to search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
[0034] In a third aspect, an embodiment of the present disclosure further provides an electronic device, comprising: a processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor, and when the electronic device is running, the processor and the memory communicate via the bus, and when the machine-readable instructions are executed by the processor, the steps of the above-mentioned first aspect, or any possible implementation of the first aspect are performed.
[0035] In a fourth aspect, an embodiment of the present disclosure further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above-mentioned first aspect or any possible implementation of the first aspect are executed.
[0036] In a fifth aspect, an embodiment of the present disclosure further provides a computer program product, characterized in that the computer program product is stored in a storage medium, and the program product is executed by at least one processor to perform the steps in the above-mentioned first aspect, or any possible implementation of the first aspect.
[0037] In an embodiment of the present disclosure, when it is detected that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition, a target field can be inserted in the current configuration block of the computing network alliance chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block; and when it is detected that the full-node chain meets the node replacement condition, the block area to be replaced is searched based on the target field in the configuration block; then, the light node block corresponding to each full-node block in the block area to be replaced is searched in the light node chain, and the full-node block is replaced with the corresponding light node block.
[0038] In the above implementation, by inserting the target field in the configuration block and searching for the block area to be replaced based on the target field, each full-node block in the block area to be replaced is replaced with a light-node block. This ensures that the storage burden of the full-block ledger is reduced under the tamper-proof nature of the blockchain itself, effectively solves the node's ledger storage pressure, and promotes the sustainable development of the computing power network alliance chain.
[0039] In order to make the above-mentioned objectives, features and advantages of the present disclosure more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the following is a brief introduction to the drawings required for use in the embodiments. The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used together with the specification to illustrate the technical solutions of the present disclosure. It should be understood that the following drawings only illustrate certain embodiments of the present disclosure and should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can also be obtained based on these drawings without creative work.
[0041] Figure 1 A flowchart of a ledger optimization method for a consortium chain provided in an embodiment of the present disclosure is shown;
[0042] Figure 2 A schematic diagram of the division of labor of nodes in a computing power network alliance chain provided by an embodiment of the present disclosure is shown;
[0043] Figure 3 A schematic diagram showing a replacement of a full node block of a computing power network alliance chain with a light node block provided by an embodiment of the present disclosure is shown;
[0044] Figure 4 A schematic diagram of a ledger optimization device for a consortium chain provided by an embodiment of the present disclosure is shown;
[0045] Figure 5 A schematic diagram of an electronic device provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical scheme and advantages of the embodiments of the present disclosure clearer, the technical scheme in the embodiments of the present disclosure will be clearly and completely described below in conjunction with the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only part of the embodiments of the present disclosure, rather than all of the embodiments. The components of the embodiments of the present disclosure generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present disclosure provided in the drawings is not intended to limit the scope of the present disclosure for protection, but merely represents the selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those skilled in the art without making creative work belong to the scope of protection of the present disclosure.
[0047] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0048] The term "and / or" herein only describes an association relationship, indicating that three relationships may exist. For example, A and / or B may represent the following three situations: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C may represent including any one or more elements selected from the set consisting of A, B, and C.
[0049] Research has found that the computing power network has connected multi-level computing power resources such as network, cloud, data, intelligence, security, edge, end, and chain to provide a new type of information infrastructure that provides integrated services; however, due to the ubiquitous distribution, complex situation, and large number of computing power nodes in the computing power network, it has brought problems such as trust and collaboration to the computing power network.
[0050] Blockchain has the characteristics of decentralization, immutability, and traceability. Therefore, blockchain can solve the trust problem very well. Alliance chain is a type of blockchain owned by members within the alliance. It is highly controllable and easy to reach consensus. Building a computing network based on alliance chain can effectively solve the problems of insufficient trust, opaque information, and poor collaboration among partners in the computing network. However, due to the full backup mechanism of the ledger data of the alliance chain, the node storage resources in the blockchain will be tight and it will be difficult to support more and more ledger data. In addition, the addition of new nodes will make the synchronization time of the block ledger longer and longer, making it difficult to ensure the long-term operation efficiency of the alliance chain network. Therefore, solving the problem of in-chain ledger storage is the primary issue to ensure the normal operation of the computing network alliance chain.
[0051] Based on the above research, the present disclosure provides a ledger optimization method, device, equipment, medium and product for a consortium chain. In an embodiment of the present disclosure, when it is detected that the number of blocks in the full node chain of the computing network consortium chain meets the segmentation condition, a target field can be inserted into the current configuration block of the computing network consortium chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network consortium chain, and a hash address of the previous configuration block; and when it is detected that the full node chain meets the node replacement condition, the block area to be replaced is searched based on the target field in the configuration block; then, the light node block corresponding to each full node block in the block area to be replaced is searched in the light node chain, and the full node block is replaced with the corresponding light node block.
[0052] In the above implementation, by inserting the target field in the configuration block and searching for the block area to be replaced based on the target field, each full-node block in the block area to be replaced is replaced with a light-node block. This ensures that the storage burden of the full-block ledger is reduced under the tamper-proof nature of the blockchain itself, effectively solves the node's ledger storage pressure, and promotes the sustainable development of the computing power network alliance chain.
[0053] To facilitate understanding of this embodiment, a consortium chain ledger optimization method disclosed in the embodiment of the present disclosure is first introduced in detail. The execution subject of the consortium chain ledger optimization method provided in the embodiment of the present disclosure is generally an electronic device with certain computing capabilities. In some possible implementations, the consortium chain ledger optimization method can be implemented by a processor calling a computer-readable instruction stored in a memory.
[0054] See also Figure 1 As shown, it is a flowchart of a ledger optimization method of a consortium chain provided by an embodiment of the present disclosure, and the method includes steps S101 to S103, wherein:
[0055] S101: When it is detected that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation conditions, a target field is inserted into the current configuration block of the computing network alliance chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block.
[0056] In the disclosed embodiment, the full-node chain includes a full-node block, which stores all the ledger transaction data in the block and is responsible for operations such as transaction search, transaction verification, and transaction tracing. The light-node block adopts the consistent hashing principle and only stores the block header data and is responsible for transaction verification.
[0057] Here, the full node chain can run in the endorsement node (Endorser) of the Suanwang Alliance Chain, and the light node chain where the light node block is located can run in the anchor node (Anchor) of the Suanwang Alliance Chain.
[0058] Here, the target field can be inserted into the metadata structure of the current configuration block, and the identification bit can be used to indicate the segment position of the block in the Suanwang alliance chain.
[0059] S102: When it is detected that the full node chain meets the node replacement condition, the block area to be replaced is searched based on the target field in the configuration block.
[0060] Here, it is possible to detect whether the number of blocks of the full node block in the full node chain meets the node replacement condition. For example, it is possible to detect that the number of blocks of the full node block in the full node chain reaches the first threshold Block_num1, and then determine that the node replacement condition is met, wherein the specific value of the first threshold Block_num1 can be set according to actual needs, for example, Block_num1=100000, at this time, when it is detected that the number of blocks of the full node block reaches 100000, it can be determined that the full node chain meets the node replacement condition. At this time, the block area to be replaced can be searched in the full node chain based on the target field inserted in the configuration block.
[0061] S103: Searching the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replacing the full node block with the corresponding light node block.
[0062] Full node blocks and light node blocks in the blockchain are relative concepts. The light node chain contains light node blocks, which use the consistent hashing principle and only store block header data to verify transactions.
[0063] In the above implementation, by inserting the target field in the configuration block and searching for the block area to be replaced based on the target field, each full-node block in the block area to be replaced is replaced with a light-node block. This ensures that the storage burden of the full-block ledger is reduced under the tamper-proof nature of the blockchain itself, effectively solves the node's ledger storage pressure, and promotes the sustainable development of the computing power network alliance chain.
[0064] The above steps will be described in detail below in conjunction with specific implementation methods.
[0065] Here, it should be noted that blockchain has the following basic properties: chain integrity, sequential addition of ledgers, and state data integrity.
[0066] Chain integrity means that the structure of the blockchain is a one-way graph, and the header of each subsequent block contains the hash address of the header of the previous block, namely the prehash. This approach makes it more difficult and more costly to tamper with the chain information, thus ensuring the "immutability" of the blockchain.
[0067] The sequential addition of ledgers means that since the status data of the ledgers in the full-node blocks in the blockchain are updated according to the order of transaction details in the block number, the ledgers of the entire blockchain need to be appended sequentially according to the block number.
[0068] State data integrity means that the world state is obtained through state data, which supports the transaction verification work of the endorsement node. Since the state of the blockchain is the cumulative result of the execution of each transaction in each block starting from the genesis block, the correctness of the world state needs to be guaranteed based on complete ledger data.
[0069] In the disclosed embodiment, based on the basic properties of the blockchain described above, a computing power network alliance chain with a mixed working mechanism of full node blocks and light node blocks is proposed.
[0070] Here, the Suanwang alliance chain includes multiple organizations. Based on this, different blockchains can be stored according to the role division of nodes within each organization.
[0071] like Figure 2As shown in the figure, the nodes of each organization in the blockchain are divided into four roles, and each role has different division of labor. The specific role descriptions are as follows:
[0072] The leader node supports the client to obtain the block release submitted to the chain and publish it to other nodes in the organization for block ledger synchronization.
[0073] Endorser, a node that undertakes endorsement tasks, supports the operation of contracts and endorses transaction proposals, and requires complete state data to view the accurate world state.
[0074] Anchor nodes support message broadcasting between organizations.
[0075] The accounting node (Comitter) supports the accounting function, while the other three types of nodes perform their respective duties and also serve as accounting nodes.
[0076] Although the division of labor of each node is different, each node will synchronize the same ledger data. However, in the long run, this will lead to a significant reduction in the physical space of the node, and a large number of backup ledgers in the organization will only lead to data redundancy. Based on this, the technical solution disclosed in this disclosure maintains different types of blockchains according to the division of labor for the four roles in each organization of the Suanwang Alliance Chain, for example, including: full node chain, light node chain, hybrid node chain, and virtual chain.
[0077] like Figure 2 As shown, the improvement of the Suanwang Alliance Chain by the disclosed technical solution is described as follows:
[0078] After receiving the block sent by the Order node, the master node distributes the block. At this time, the full node block corresponding to the block can be sent to the endorsement node (Endorser), and a hybrid node chain of full nodes and light nodes will be established later. Then, the light block node corresponding to the block is sent to the anchor node (Anchor) to establish a light node chain. Among them, the main work of the anchor node is the communication work between organizations. The ledger is the lightest to avoid node failure.
[0079] Here, the ledger node (Committer) in each organization can also be set to receive the backup block to be stored and establish a virtual chain based on the backup block.
[0080] After improving the Suanwang alliance chain in the manner described above, the process described in steps S101 to S103 above can be performed.
[0081] First, we can detect whether the number of blocks in the full-node chain of the Suanwang Alliance Chain meets the segmentation conditions.
[0082] In an optional implementation, it is detected that the number of blocks in the full-node chain of the Suanwang Alliance Chain meets the segmentation condition, which specifically includes the following steps:
[0083] Step S11, when it is detected that the number of configuration blocks between the current configuration block and the first configuration block in the full-node chain meets the first number requirement, it is determined that the number of blocks in the full-node chain meets the segmentation condition; wherein the first configuration block is the configuration block with the previous insertion identification bit of the current configuration block in the full-node chain.
[0084] In specific implementation, it is possible to start from the genesis block and detect whether the number of blocks in the full node chain reaches the preset second threshold Block_num2, for example, Block_num2 = 10000 blocks. If it is detected that the number of blocks in the full node chain reaches the second threshold, it is determined that the first number requirement is met, that is, the segmentation condition is met. At this time, an identification bit can be inserted into the metadata structure of the 10000th block (i.e., the current configuration block). Afterwards, starting from the next block after the current configuration block, continue to count whether the number of blocks reaches the second threshold Block_num2. If it is judged that it has reached it, an identification bit is inserted into the metadata structure of the 20000th block, and so on, inserting an identification bit in the configuration block of the full node chain. At this time, the 20000th block is the current configuration block, and the 10000th block is the first configuration block.
[0085] Afterwards, it can be detected whether the full node chain meets the node replacement conditions, and if it is detected that the node replacement conditions are met, the block area to be replaced is found based on the target field in the configuration block.
[0086] In an optional implementation, the above step S101 inserts the target field into the current configuration block of the computing network alliance chain, specifically including the following steps:
[0087] Step S21, inserting a first field and a second field into the metadata structure of the current configuration block; wherein the first field is used to indicate an identification bit of a segment position, and the second field is used to indicate a hash address of a previous configuration block before the current configuration block.
[0088] In the disclosed embodiment, two fields can be added to the metadata structure of the configuration block, namely the first field light_label and the second field prehash; wherein the first field light_label is used to indicate the light node identification bit. In specific implementation, when it is detected that the number of blocks in the full node chain meets the segmentation condition, the first field light_label = 1 can be inserted into the metadata structure; since the structure of the blockchain is a one-way structure, it is necessary to obtain the previous block address based on the prehash address; therefore, the second field prehash can also be inserted into the metadata structure to indicate the hash address of the previous configuration block through the second field.
[0089] Next, it can be detected that the full node chain meets the node replacement condition, and when it is detected that the node replacement condition is met, the block area to be replaced is found based on the configuration block inserted into the target field.
[0090] From the above description, it can be known that it is possible to detect whether the number of blocks of full-node blocks in the full-node chain meets the node replacement condition. For example, it can be detected that the number of blocks of full-node blocks in the full-node chain reaches the first threshold Block_num1, then it is determined that the node replacement condition is met.
[0091] In an optional implementation, in the above step S102, when it is detected that the full node chain meets the node replacement condition, searching for the block area to be replaced based on the identification bit in the configuration block specifically includes the following steps:
[0092] Step S31, searching the full node chain for the first configuration block with the identification bit inserted in order from back to front to obtain a second configuration block;
[0093] Step S32: determine a specified number of configuration blocks between the second configuration block and the third configuration block in the full node chain as the block area to be replaced; wherein the third configuration block is a configuration block with an identification bit inserted after the second configuration block.
[0094] In the embodiment of the present disclosure, when it is detected that the full node chain meets the node replacement condition, the previous configuration block can be quickly located in a backward order starting from the block at the last end of the blockchain at the current moment.
[0095] Here, since the hash address of the previous configuration block is recorded in the configuration block, the previous configuration block can be quickly located based on the hash address. After determining the previous configuration block, you can check whether an identification bit is inserted in the configuration block; if it is determined that an identification bit is inserted in the configuration block, and the first field light_label in the identification bit is 0, it means that the configuration block is an ordinary configuration block. After that, you can continue to locate the configuration block forward based on the hash address, and then determine whether the located configuration block is the second configuration block in the manner described above; and so on, until the first configuration block with the identification bit inserted is obtained, thereby obtaining the second configuration block.
[0096] After the second configuration block is determined, the configuration block with the next insertion identification bit of the second configuration block, ie, the third configuration block, can be used, and then a specified number of configuration blocks between the second configuration block and the third configuration block in the node chain are determined as the block area to be replaced.
[0097] In specific implementation, the block number N of the second configuration block can be determined, and then the second threshold described above is obtained, and the block number and the second threshold are summed to obtain the block number M of the third configuration block. At this time, the block area to be replaced can be determined by a specified number of block areas in the block number interval (N, M). For example, the first 1000 blocks in the block number interval (N, M) can be used as the block area to be replaced.
[0098] After determining the block area to be replaced, Figure 3 As shown, the light node block corresponding to each full node block in the block area to be replaced can be searched in the light node chain, and then the full node block can be replaced with the corresponding light node block.
[0099] In specific implementation, starting from the second configuration block N, in order from front to back, based on the block number, a specified number of full-node blocks in the endorsement node interval (N, M) are searched and replaced with light-node blocks, thereby ensuring the order of the ledger.
[0100] In the above implementation, by storing the ledger data in the nodes of each organization in the Suanwang alliance chain according to the role and demand, the redundancy caused by storing the full amount of ledger data in all nodes can be avoided, and the organizations in the Suanwang alliance chain can cooperate to ensure the integrity and decentralization of the ledger; by adding an identification bit to the metadata of the configuration block, it will not affect the block header and block body, nor will it affect the consistency check of the blockchain. The position of the segmented replacement block can be quickly located through this identification bit, so as to minimize the changes to the current alliance chain and maximize the effect.
[0101] In an optional embodiment, after replacing the full node block with the corresponding light node block, the method further includes the following steps:
[0102] Step S41, determining the block that has been replaced with the corresponding light node block in the computing network alliance chain, and obtaining a backup block;
[0103] Step S42, backing up the backup block in the backup node of the first organization, and creating a virtual chain based on the backup block;
[0104] Step S43, writing the block routing information of the backup block into the routing table set in the anchor node of the first organization.
[0105] In the disclosed embodiment, the full node block that has been replaced by the corresponding light node block can be determined in the computing network alliance chain as a backup block. For example, the full node block located in the block area to be replaced can be used as a backup block. Then, the historical ledger backup is performed on the blocks of the full ledger data in the endorsement node in an organized manner and backed up in the accounting node.
[0106] Here, the first organization for backing up the backup block can be determined from among the multiple organizations of the Suanwang Alliance Chain, and then the backup block is backed up in the backup node of the first organization. To prevent the ledger data of the backup block from being tampered with offline, the master-slave backup method of "one master and two backups" can be used to avoid single point failures and verify data consistency.
[0107] In the disclosed embodiment, a routing table is set in the anchor node of each organization. The information recorded in the routing table is shown in 1 below. The routing table can record the backup status of all backup blocks in the Suanwang Alliance Chain in each organization (i.e., block routing information). Here, the block routing information in the routing table can also be quickly synchronized to the routing tables of other organizations in the Suanwang Alliance Chain through the anchor node.
[0108] Table 1
[0109]
[0110] Next, a virtual chain can be created based on the backup block. The virtual chain supports the query of backup historical block data. Its essence is also an independent blockchain, so the ledger data starting from the genesis block must be saved.
[0111] Here, the virtual chain is a complete blockchain, but the virtual chain created for each organization contains the block header, block body and metadata of the backup blocks backed up by the organization.
[0112] In an optional embodiment, the method further comprises the following steps:
[0113] Step S51, in response to a data query request, determining a backup organization of historical data to be queried based on the routing table; and determining a backup node for backing up historical data in the backup organization;
[0114] Step S52: searching for the historical data based on the virtual chain running in the backup node.
[0115] In the disclosed embodiment, after detecting a data query request for the account book data in the Suanwang alliance chain, the chain id and the configuration block number carried in the data query request can be determined; wherein the chain id is used to indicate the virtual chain where the historical data is located, and the configuration block number is used to indicate the block number of the block where the historical data to be queried is located. At this time, the chain id and the configuration block number can be used as keys to query the routing table, and the organization used to back up the historical data can be determined by querying the routing table, thereby obtaining the second organization.
[0116] Then, based on the organization ID and node peer in the routing table, the backup node of the historical data is determined to obtain the backup location of the historical data. After the backup node is determined, the transaction status in the historical block can be searched through the virtual chain running in the backup node to obtain the historical data.
[0117] In an optional implementation, when the backup node includes a primary backup node and a secondary backup node, the method further includes:
[0118] First, a first Merkle root hash value is calculated based on the block header of the backup block in the primary backup node, and a second Merkle root hash value is calculated based on the block header of the backup block in the secondary backup node;
[0119] Secondly, based on the first Merkle tree root hash value and the second Merkle tree root hash value, the consistency of the backup blocks in the primary backup node and the secondary backup node is verified.
[0120] From the above description, it can be seen that in order to prevent the ledger data of the backup block from being tampered with offline, the master-slave backup method of "one master and two backups" can be adopted to avoid single point failures and verify data consistency.
[0121] Based on this, the Merkle Tree Root value can be calculated regularly through the block header calculation of the three backup data, thereby obtaining the first Merkle Tree Root Hash value and the second Merkle Tree Root Hash value. Afterwards, the consistency of the first Merkle Tree Root Hash value and the second Merkle Tree Root Hash value can be verified, and the consistency of the backup blocks in the primary backup node and the secondary backup node can be verified through the consistency check result, while also preventing attacks and damages from providing backups.
[0122] In an optional embodiment, after replacing the full node block with the corresponding light node block, the method further includes the following steps:
[0123] First, calculate the root value of the Bucket tree of the full-node on-chain state database in each organization of the computing network alliance chain, and obtain multiple roots;
[0124] Secondly, the consistency and integrity of the world state within the computing network alliance chain is verified based on multiple root verifications.
[0125] The state data of the full amount of blockchain ledger data ensures the accuracy of the world state, and the world state supports the endorsement of transactions submitted on the endorsement node, which can be regenerated according to the changes or restarts of the node peer. In the disclosed embodiment, the replacement of the full node block in the computing network alliance chain will cause data loss in the state database, so the change of the full node chain will first persist the state data. Based on this, the root value of the Bucket tree of the state database on the hybrid chain (the full node chain after replacement) can be calculated regularly to obtain multiple roots.
[0126] After obtaining multiple rootings, the consistency and integrity of the world state within the computing network alliance chain can be verified based on the rootings.
[0127] In the above implementation, by periodically calculating the root value of the Bucket tree of the hybrid chain state database, efficient verification of the consistency and integrity of the world state within the chain can be guaranteed.
[0128] The survey found that most of the current methods to solve storage pressure in the blockchain use light nodes. Among them, peer nodes with weak functions or limited storage in the chain can be set up to save light node ledgers, but peer nodes are still required to maintain a set of full node ledgers, which is bound to face a full ledger storage bottleneck.
[0129] The transaction volume of the computing power network alliance chain is huge, and the long-standing historical block data will have little impact on subsequent functions as it decays over time. Therefore, the disclosed technical solution, while ensuring the basic properties of blockchain "unalterable", "trusted transactions" and "traceable", for the first time proposes the use of a joint working mechanism of full-node blocks and light-node blocks on the full-node chain. Among them, a configuration block with an identification bit is added to help with positioning and transfer, and the transferred full-node block is replaced by the corresponding light-node block; and the historical block data of the full-node chain is transferred to the virtual chain for backup on an organizational basis, and the virtual chain subsequently supports the traceability of historical data. The hybrid chain of full-node blocks and light-node blocks has achieved minimal modification to the blockchain, effectively solving the problem of blockchain storage pressure and ensuring the long-term operating efficiency of the computing power network alliance chain.
[0130] Those skilled in the art will appreciate that, in the above method of specific implementation, the order in which the steps are written does not imply a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of the steps should be determined by their functions and possible internal logic.
[0131] Based on the same inventive concept, the embodiment of the present disclosure also provides a consortium chain ledger optimization device corresponding to the consortium chain ledger optimization method. Since the principle of solving the problem by the device in the embodiment of the present disclosure is similar to the above-mentioned consortium chain ledger optimization method in the embodiment of the present disclosure, the implementation of the device can refer to the implementation of the method, and the repeated parts will not be repeated.
[0132] Reference Figure 4 As shown, it is a schematic diagram of a ledger optimization device of a consortium chain provided by an embodiment of the present disclosure, and the device includes: an insertion unit 10, a search unit 20, and a block replacement unit 30; wherein,
[0133] An insertion unit, configured to insert a target field into a current configuration block of the computing network alliance chain when detecting that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block;
[0134] A search unit, configured to search for a block area to be replaced based on a target field in the configuration block when it is detected that the full node chain satisfies a node replacement condition;
[0135] The block replacement unit is used to search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
[0136] In the above implementation, by inserting the target field in the configuration block and searching the block area to be replaced based on the identification bit, each full node block in the block area to be replaced is replaced with a light node block. This can ensure that the full block ledger storage burden is reduced under the tamper-proof nature of the blockchain itself, effectively solve the node ledger storage pressure, and promote the sustainable development of the computing power network alliance chain. In one possible implementation, the insertion unit is also used to:
[0137] Inserting a first field and a second field into the metadata structure of the current configuration block; wherein the first field is used to indicate an identification bit of a segment position, and the second field is used to indicate a hash address of a previous configuration block before the current configuration block.
[0138] In a possible implementation manner, the insertion unit is further used for:
[0139] When it is detected that the number of configuration blocks between the current configuration block and the first configuration block in the full-node chain meets the first number requirement, it is determined that the number of blocks in the full-node chain meets the segmentation condition; wherein the first configuration block is the configuration block with the previous insertion identification bit of the current configuration block in the full-node chain.
[0140] In a possible implementation manner, the searching unit is further configured to:
[0141] In order from back to front, search the full node chain for the first configuration block with the identification bit inserted, to obtain the second configuration block;
[0142] A specified number of configuration blocks located between the second configuration block and the third configuration block in the full node chain are determined as the block area to be replaced; wherein the third configuration block is a configuration block with an identification bit inserted after the second configuration block.
[0143] In one possible implementation, the computing network alliance chain includes multiple organizations, each of which includes an anchor node and an endorsement node; wherein the endorsement node is used to receive the full node block sent by the master node in the organization, and the anchor node is used to receive the light node block sent by the master node in the organization.
[0144] In a possible implementation manner, the device is further used for:
[0145] After replacing the full node block with the corresponding light node block, determining the block that has been replaced with the corresponding light node block in the computing network alliance chain to obtain a backup block;
[0146] Backing up the backup block in a backup node of the first organization, and creating a virtual chain based on the backup block;
[0147] The routing table set in the anchor node of the first organization writes the block routing information of the backup block.
[0148] In a possible implementation manner, the device is further used for:
[0149] In response to a data query request, determining a backup organization of the historical data to be queried based on the routing table, and determining a backup node that backs up the historical data in the backup organization;
[0150] The historical data is searched based on the virtual chain running in the backup node.
[0151] In a possible implementation manner, when the backup node includes a primary backup node and a secondary backup node, the device is further used to:
[0152] Calculating a first Merkle root hash value based on a block header of a backup block in the primary backup node, and calculating a second Merkle root hash value based on a block header of a backup block in the secondary backup node;
[0153] Based on the first Merkle tree root hash value and the second Merkle tree root hash value, the consistency of the backup blocks in the primary backup node and the secondary backup node is verified.
[0154] In a possible implementation manner, the device is further used for:
[0155] After replacing the full node block with the corresponding light node block, the root value of the Bucket tree of the full node chain state database in each organization of the computing network alliance chain is calculated to obtain multiple roots;
[0156] The consistency and integrity of the world state within the computing network alliance chain are verified based on the multiple roots.
[0157] For descriptions of the processing flow of each module in the device and the interaction flow between each module, reference may be made to the relevant descriptions in the above method embodiment, which will not be described in detail here.
[0158] Corresponds to Figure 1 The ledger optimization method of the alliance chain in the present disclosure also provides an electronic device 500, such as Figure 5 FIG. 5 is a schematic diagram of the structure of an electronic device 500 provided in an embodiment of the present disclosure, including:
[0159] Processor 51, memory 52, and bus 53; memory 52 is used to store execution instructions, including memory 521 and external memory 522; memory 521 here is also called internal memory, which is used to temporarily store operation data in processor 51 and data exchanged with external memory 522 such as hard disk. Processor 51 exchanges data with external memory 522 through memory 521. When the electronic device 500 is running, the processor 51 communicates with the memory 52 through bus 53, so that the processor 51 executes the following instructions:
[0160] When it is detected that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition, a target field is inserted into the current configuration block of the computing network alliance chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block;
[0161] When it is detected that the full node chain meets the node replacement condition, searching for the block area to be replaced based on the target field in the configuration block;
[0162] Search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
[0163] The present disclosure also provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the alliance chain ledger optimization method described in the above method embodiment are executed. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0164] The present disclosure also provides a computer program product that carries a program code. The program code includes instructions that can be used to execute the steps of the alliance chain ledger optimization method described in the above method embodiment. For details, please refer to the above method embodiment, which will not be repeated here.
[0165] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is implemented as a computer storage medium. In another optional embodiment, the computer program product is implemented as a software product, such as a software development kit (SDK).
[0166] Those skilled in the art can clearly understand that, for the convenience and simplicity of description, the specific working process of the system and device described above can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here. In the several embodiments provided in the present disclosure, it should be understood that the disclosed system, device and method can be implemented in other ways. The device embodiments described above are merely schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some communication interfaces, and the indirect coupling or communication connection of the device or unit can be electrical, mechanical or other forms.
[0167] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0168] In addition, each functional unit in each embodiment of the present disclosure may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0169] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a non-volatile computer-readable storage medium that is executable by a processor. Based on this understanding, the technical solution of the present disclosure, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present disclosure. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0170] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present disclosure, which are used to illustrate the technical solutions of the present disclosure, rather than to limit them. The protection scope of the present disclosure is not limited thereto. Although the present disclosure is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still modify the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present disclosure, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these modifications, changes or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be included in the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be based on the protection scope of the claims.
Claims
1. A ledger optimization method for a consortium chain, characterized in that: include: When it is detected that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition, a target field is inserted into the current configuration block of the computing network alliance chain; wherein the target field includes an identification bit for indicating the segmentation position of the block in the computing network alliance chain, and a hash address of the previous configuration block; When it is detected that the full node chain meets the node replacement condition, searching for the block area to be replaced based on the target field in the configuration block; Search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
2. The method according to claim 1, characterized in that The inserting a target field into the current configuration block of the computing network alliance chain includes: Inserting a first field and a second field into the metadata structure of the current configuration block; wherein the first field is used to indicate an identification bit of a segment position, and the second field is used to indicate a hash address of a previous configuration block before the current configuration block.
3. The method according to claim 1, characterized in that The detection that the number of blocks in the full-node chain of the Suanwang Alliance Chain meets the segmentation conditions includes: When it is detected that the number of configuration blocks between the current configuration block and the first configuration block in the full-node chain meets the first number requirement, it is determined that the number of blocks in the full-node chain meets the segmentation condition; wherein the first configuration block is the configuration block with the previous insertion identification bit of the current configuration block in the full-node chain.
4. The method according to claim 1, characterized in that: When it is detected that the full node chain satisfies the node replacement condition, searching for the block area to be replaced based on the target field in the configuration block includes: In order from back to front, search the full node chain for the first configuration block with the identification bit inserted, to obtain the second configuration block; A specified number of configuration blocks located between the second configuration block and the third configuration block in the full node chain are determined as the block area to be replaced; wherein the third configuration block is a configuration block with an identification bit inserted after the second configuration block.
5. The method according to claim 1, characterized in that The Suanwang alliance chain includes multiple organizations, each of which contains anchor nodes and endorsement nodes; wherein the endorsement nodes are used to receive full node blocks sent by the master node in the organization, and the anchor nodes are used to receive light node blocks sent by the master node in the organization.
6. The method according to claim 1 or 5, characterized in that: After replacing the full node block with the corresponding light node block, the method further includes: Determine in the computing network alliance chain the block that has been replaced with the corresponding light node block to obtain a backup block; Backing up the backup block in a backup node of the first organization, and creating a virtual chain based on the backup block; The routing table set in the anchor node of the first organization writes the block routing information of the backup block.
7. The method according to claim 6, characterized in that The method further comprises: In response to a data query request, determining a backup organization of the historical data to be queried based on the routing table, and determining a backup node for backing up the historical data in the backup organization; The historical data is searched based on the virtual chain running in the backup node.
8. The method according to claim 6, characterized in that The backup nodes include a primary backup node and a secondary backup node, and the method further includes: Calculating a first Merkle root hash value based on a block header of a backup block in the primary backup node, and calculating a second Merkle root hash value based on a block header of a backup block in the secondary backup node; Based on the first Merkle tree root hash value and the second Merkle tree root hash value, the consistency of the backup blocks in the primary backup node and the secondary backup node is verified.
9. The method according to claim 1, characterized in that: After replacing the full node block with the corresponding light node block, the method further includes: Calculate the root value of the Bucket tree of the full-node on-chain state database in each organization of the computing network alliance chain to obtain multiple roots; The consistency and integrity of the world state within the computing network alliance chain are verified based on the multiple roots.
10. A ledger optimization device for a consortium chain, characterized in that: include: An insertion unit, configured to insert a target field into the current configuration block of the computing network alliance chain when detecting that the number of blocks in the full-node chain of the computing network alliance chain meets the segmentation condition; wherein the target field is used to indicate the segmentation position of the block in the computing network alliance chain and the hash address of the previous configuration block; A search unit, configured to search for a block area to be replaced based on a target field in the configuration block when it is detected that the full node chain satisfies a node replacement condition; The block replacement unit is used to search the light node chain for a light node block corresponding to each full node block in the block area to be replaced, and replace the full node block with the corresponding light node block.
11. An electronic device, characterized in that: include: A processor, a memory and a bus, wherein the memory stores machine-readable instructions executable by the processor. When the electronic device is running, the processor and the memory communicate through the bus. When the machine-readable instructions are executed by the processor, the steps of optimizing the ledger of the alliance chain as described in any one of claims 1 to 9 are performed.
12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, which, when executed by a processor, executes the steps of optimizing the ledger of the alliance chain as described in any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product is stored in a storage medium, and the program product is executed by at least one processor to implement the steps of optimizing the ledger of the alliance chain as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Certificate processing method and device for blockchain network, electronic equipment and storage medium
CN110597911A
Block chain query optimization method based on on-chain and off-chain collaboration
CN114461673A
Data processing method, device and equipment based on alliance chain and readable storage medium
CN116049304A
Method and apparatus for storing blockchain state data and electronic device
US20200167345A1
