Blockchain ledger optimization method, apparatus, device, medium and product of consortium chain
By inserting target fields into the consortium blockchain and replacing full node blocks with light node blocks, the problem of scarce storage resources in the consortium blockchain is solved, efficient ledger data management is achieved, and the long-term operational efficiency and sustainability of the consortium blockchain are guaranteed.
Patent Information
- Application Number
- CN202410249068.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2026-01-16
- Estimated Expiration
- 2044-03-05
AI Technical Summary
In consortium blockchains, the full backup mechanism leads to issues such as limited node storage resources and excessively long synchronization times for new nodes, which affect the long-term operational efficiency of the consortium blockchain network.
Insert a target field into the full node chain of the consortium blockchain to indicate the segment position and the hash address of the previous configuration block. When the conditions are met, find the block area to be replaced, replace the full node block with the light node block, and create a virtual chain to back up historical data, thereby reducing the storage burden.
While maintaining the immutability of blockchain, it reduces the storage pressure of the entire block ledger and improves the operational efficiency and sustainability of the consortium blockchain.
Smart Images

Figure CN118802481B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present disclosure relates to the technical field of blockchain, in particular, to a ledger optimization method and device of a consortium chain, equipment, medium and product. BACKGROUND
[0002] The computing power network connects multi-level computing power resources such as network, cloud, data, intelligence, security, edge, end and chain, and provides a new type of information infrastructure for integrated services. However, due to the characteristics of ubiquitous distribution, complex situation and large quantity of computing power nodes in the computing power network, the computing power network has problems such as trust and cooperation.
[0003] The blockchain has the characteristics of decentralization, non-tamperability and traceability, so the blockchain can well solve the trust problem. The consortium chain belongs to a kind of blockchain owned by members within the alliance, has strong controllability and is easy to reach consensus. Building a computing power network based on the consortium chain can effectively solve the problems of insufficient trust, opaque information and unsmooth cooperation among various partners in the computing power network. However, due to the full backup mechanism of the ledger data of the consortium chain, the storage resources of the nodes in the blockchain are nervous and difficult to support more and more ledger data. Moreover, for the addition of new nodes, the synchronization time of the block ledger is getting longer and longer, which is difficult to guarantee the long-term operation efficiency of the consortium chain network. Therefore, solving the problem of in-chain ledger storage is the primary problem to ensure the normal operation of the computing power network consortium chain. SUMMARY
[0004] The present disclosure provides at least a ledger optimization method, device, equipment, medium and product of a consortium chain.
[0005] In a first aspect, the present disclosure provides a ledger optimization method of a consortium chain, comprising:
[0006] In a case where it is detected that the number of blocks in a full node chain of a computing power network consortium chain meets a segmentation condition, a target field is inserted in a current configuration block of the computing power network consortium chain; wherein the target field contains an identification bit for indicating the segmentation position of a block in the computing power network consortium chain, and a hash address of a previous configuration block;
[0007] In a case where it is detected that the full node chain meets a node replacement condition, a target field in a configuration block is searched to find a block area to be replaced;
[0008] In a light node chain, a light node block corresponding to each full node block in the block area to be replaced is searched, and the full node block is replaced by the corresponding light node block.
[0009] In an optional implementation, the target field is inserted in the current configuration block of the computing power network consortium chain, comprising:
[0010] inserting a first field and a second field in a metadata structure of the current configuration block; wherein the first field is used to indicate identification bits of a segment position, and the second field is used to indicate a hash address of a last configuration block before the current configuration block.
[0011] In an optional implementation, the detecting that the number of blocks in the full node chain of the network calculation alliance chain satisfies the segment condition comprises:
[0012] In a case where it is detected that the number of configuration blocks between the current configuration block and a first configuration block in the full node chain satisfies a first quantity requirement, it is determined that the number of blocks in the full node chain satisfies the segment condition; wherein the first configuration block is a last configuration block in the full node chain in which identification bits are inserted.
[0013] In an optional implementation, in a case where it is detected that the full node chain satisfies a node replacement condition, a target field in the configuration block is used to find a block area to be replaced.
[0014] In a case where it is detected that the full node chain satisfies a node replacement condition, a target field in the configuration block is used to find a block area to be replaced.
[0015] In an optional implementation, in a case where it is detected that the full node chain satisfies a node replacement condition, a target field in the configuration block is used to find a block area to be replaced.
[0016] In an optional implementation, the network calculation alliance chain comprises a plurality of organizations, and each of the organizations comprises an anchor node and an endorsement node; wherein the endorsement node is used to receive a full node block sent by a master node in the organization, and the anchor node is used to receive a light node block sent by the master node in the organization.
[0017] In an optional implementation, after the full node block is replaced by the corresponding light node block, the method further comprises:
[0018] In an optional implementation, after the full node block is replaced by the corresponding light node block, the method further comprises:
[0019] In an optional implementation, after the full node block is replaced by the corresponding light node block, the method further comprises:
[0020] In an optional implementation, after the full node block is replaced by the corresponding light node block, the method further comprises:
[0021] In an optional implementation, the method further comprises:
[0022] In response to the data query request, determining a backup organization of the historical data to be queried based on the routing table, and determining a backup node backing up the historical data in the backup organization;
[0023] Searching for the historical data based on a virtual chain running in the backup node.
[0024] In an optional implementation, the backup node includes a master backup node and a slave backup node, and the method further includes:
[0025] calculating a first Merkle tree root hash value based on block headers of backup blocks in the master backup node, and calculating a second Merkle tree root hash value based on block headers of backup blocks in the slave backup node;
[0026] verifying consistency of the backup blocks in the master backup node and the slave backup node based on the first Merkle tree root hash value and the second Merkle tree root hash value.
[0027] In an optional implementation, after replacing the full node blocks with corresponding light node blocks, the method further includes:
[0028] calculating root values of Bucket trees of state databases on full node chains in each organization of the computing network alliance chain, to obtain a plurality of root plants;
[0029] verifying consistency and integrity of the world state in the computing network alliance chain according to the plurality of root plants.
[0030] In a second aspect, the embodiments of the present disclosure provide a ledger optimization device of an alliance chain, including:
[0031] an insertion unit configured to insert a target field in a current configuration block of the computing network alliance chain when it is detected that the number of blocks in a full node chain of the computing network alliance chain meets a segmentation condition, wherein the target field includes identification bits indicating a segmentation position of a block in the computing network alliance chain, and a hash address of a previous configuration block;
[0032] a searching unit configured to search for a block area to be replaced based on the target field in the configuration block when it is detected that the full node chain meets a node replacement condition;
[0033] a block replacement unit configured to search for a light node block corresponding to each full node block in the block area to be replaced in a light node chain, and replace the full node block with the corresponding light node block.
[0034] In a third aspect, the embodiments of the present disclosure further provide an electronic device, comprising a processor, a memory and a bus, the memory stores machine readable instructions executable by the processor, when the electronic device is running, the processor communicates with the memory through the bus, and the machine readable instructions are executed by the processor to perform the steps of the first aspect or any possible implementation manner of the first aspect.
[0035] In a fourth aspect, the embodiments of the present disclosure further provide a computer readable storage medium, the computer readable storage medium stores a computer program, and the computer program is executed by a processor to perform the steps of the first aspect or any possible implementation manner of the first aspect.
[0036] In a fifth aspect, the embodiments of the present disclosure further provide 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 of the first aspect or any possible implementation manner of the first aspect.
[0037] In the embodiments of the present disclosure, in a case where it is detected that the number of blocks in the full node chain of the computing power alliance chain satisfies the segmentation condition, a target field can be inserted in the current configuration block of the computing power alliance chain; the target field contains identification bits for indicating the segmentation position of the block in the computing power alliance chain, and the hash address of the previous configuration block; and in a case where it is detected that the full node chain satisfies the node replacement condition, the target field in the configuration block is searched to find a block area to be replaced; 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 by the corresponding light node block.
[0038] In the above embodiments, by inserting the target field in the configuration block and searching the block area to be replaced based on the target field, each full node block in the block area to be replaced is replaced by a light node block, which can ensure that the storage burden of the full block ledger is reduced under the characteristics that the blockchain itself is not tamperable, effectively solve the ledger storage pressure of the node, and promote the continuous development of the computing power network alliance chain.
[0039] In order to make the above objectives, characteristics and advantages of the present disclosure more apparent and easy to understand, the following preferred embodiments are specifically described below, and the accompanying drawings are referred to. BRIEF DESCRIPTION OF DRAWINGS
[0040] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure, the drawings needed to be used in the embodiments will be briefly introduced as follows. The drawings incorporated in the description and forming a part of the description are consistent with the embodiments of the present disclosure, and are used to explain the technical solutions of the present disclosure together with the description. It should be understood that the following drawings only show some of the embodiments of the present disclosure, and therefore should not be considered as a limitation on the scope, and other related drawings can also be obtained by those of ordinary skill in the art without creative labor.
[0041] Figure 1 A flow chart of a ledger optimization method of an alliance chain provided by an embodiment of the present disclosure is shown;
[0042] Figure 2 A schematic diagram of organization node division in a computing power network alliance chain provided by an embodiment of the present disclosure is shown;
[0043] Figure 3 A replacement schematic diagram of replacing full node blocks with light node blocks in a computing power network alliance chain provided by an embodiment of the present disclosure is shown;
[0044] Figure 4 A schematic diagram of a ledger optimization device of an alliance 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 objects, technical solutions and advantages of the embodiments of the present disclosure clearer, the technical solutions in the embodiments of the present disclosure will be described clearly and completely below with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only some of the embodiments of the present disclosure, but not all the embodiments. The components of the embodiments of the present disclosure described and shown in the drawings 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 claimed present disclosure, but only represents selected embodiments of the present disclosure. Based on the embodiments of the present disclosure, all other embodiments obtained by those of ordinary skill in the art without creative labor are within the scope of the present disclosure.
[0047] It should be noted that: similar reference numerals and letters represent similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.
[0048] The term "and / or", merely describes an associated relationship, which means that there can be three relationships, for example, A and / or B, which can represent: A exists alone, A and B exist together, and B exists alone. In addition, the term "at least one" herein means any one of the plurality or any combination of at least two of the plurality, for example, at least one of A, B, and C includes any one or more elements selected from the set consisting of A, B, and C.
[0049] It is found through research that the computing power network connects multi-level computing power resources such as network, cloud, data, intelligence, security, edge, end, and chain, and provides a new type of information infrastructure for integrated services. However, due to the characteristics of ubiquitous distribution, complex situation, and large quantity of computing power nodes in the computing power network, the computing power network brings problems such as trust and cooperation.
[0050] The blockchain has the characteristics of decentralization, non-tamperability, and traceability, so the blockchain can well solve the trust problem. The consortium chain belongs to a blockchain owned by members within the consortium, has strong controllability and is easy to reach consensus. Building a computing power network based on a consortium chain can effectively solve the problems of insufficient trust, opaque information, and unsmooth cooperation between various cooperation parties in the computing network. However, due to the full backup mechanism of the account book data of the consortium chain, it will cause the storage resources of the nodes in the blockchain to be insufficient to support more and more account book data, and the synchronization time of the block account book will become longer for the addition of new nodes, which makes it difficult to guarantee the long-term operation efficiency of the consortium chain network. Therefore, solving the account book storage problem in the chain is the primary problem to ensure the normal operation of the computing power network consortium chain.
[0051] Based on the above research, the present disclosure provides a consortium chain account book optimization method, device, equipment, medium and product. In the embodiment of the present disclosure, if it is detected that the number of blocks in the full node chain of the computing power network consortium chain meets the segmentation condition, a target field can be inserted in the current configuration block of the computing power network consortium chain; wherein the target field contains an identification bit for indicating the segmentation position of the block in the computing power network consortium chain, and the hash address of the last configuration block; and if it is detected that the full node chain meets the node replacement condition, the target field in the configuration block is searched to find the replacement block area; then, the light node block corresponding to each full node block in the replacement block area is searched in the light node chain, and the full node block is replaced by the corresponding light node block.
[0052] In the above embodiment, by inserting a target field in the configuration block and searching for a replacement block area based on the target field, each full node block in the replacement block area is replaced by a light node block, which can ensure that under the non-tamperable characteristics of the blockchain itself, the storage burden of the full block account book is reduced, the account book storage pressure of the nodes is effectively solved, and the sustainable development of the computing power network consortium chain is promoted.
[0053] To facilitate the understanding of the present embodiment, first, a kind of alliance chain's account book optimization method disclosed in the present embodiment is introduced in detail, the execution subject of the alliance chain's account book optimization method provided by the present embodiment is generally electronic equipment with certain computing power.In some possible implementation ways, the alliance chain's account book optimization method can be realized by the way that processor calls computer readable instructions stored in memory.
[0054] Referring to Figure 1 As shown in the figure, the flow chart of the alliance chain's account book optimization method provided by the present embodiment, the method comprises steps S101-S103, wherein:
[0055] S101: in the case where the number of blocks in the full node chain of the algorithm network alliance chain meets the segmentation condition, a target field is inserted in the current configuration block of the algorithm network alliance chain;Wherein, the target field contains identification bits for indicating the segmentation position of the block in the algorithm network alliance chain, and the hash address of the last configuration block.
[0056] In the present embodiment, the full node chain contains full node blocks, which save all the account transaction data in the block, and are responsible for transaction search, transaction verification, transaction traceability and other operations;Light node block uses consistent hashing principle, only stores block header data responsible for transaction verification.
[0057] Here, the full node chain can run in the endorsement node (Endorser) of the algorithm network alliance chain, and the light node chain where the light node block is located can run in the anchor node (Anchor) of the algorithm network alliance chain.
[0058] Here, the target field can be inserted in the metadata structure of the current configuration block, and the identification bits can indicate the segmentation position of the block in the algorithm network alliance chain.
[0059] S102: in the case where the full node chain meets the node replacement condition, find the block area to be replaced based on the target field in the configuration block.
[0060] Here, it can be detected whether the number of full node blocks in the full node chain meets the node replacement condition, for example, it can be detected that the number 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, 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 full node blocks reaches 100000, it can be determined that the full node chain meets the node replacement condition.At this time, the target field inserted in the configuration block can be used to find the block area to be replaced in the full node chain.
[0061] S103: Find the light node block corresponding to each full node block in the light node chain in the block area to be replaced, and replace the full node block with the corresponding light node block.
[0062] The full node block and the light node block in the blockchain are a pair of relative concepts. The light node chain contains light node blocks, and the light node block only stores block header data responsible for transaction verification based on the consistent hash principle.
[0063] In the above embodiment, by inserting a target field in the configuration block and finding 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, which can ensure that the storage burden of the full block ledger is reduced under the characteristics of the blockchain itself being tamper-proof, effectively solving the ledger storage pressure of the node, and promoting the continuous development of the computing power network alliance chain.
[0064] In the following, the above steps will be described in detail in conjunction with specific embodiments.
[0065] Here, it should be noted that the blockchain has the following basic properties: chain integrity, ledger sequential addition, and state data integrity.
[0066] Chain integrity refers to the structure of the blockchain, which is a one-way graph, and the hash address of the previous block header, i.e. prehash, is contained in the next block header. This makes it more difficult to tamper with chain information and increases the cost of tampering, thereby ensuring the "tamper-proof" nature of the blockchain.
[0067] Ledger sequential addition refers to the fact that the state data of the ledger in the full node block in the blockchain is updated according to the transaction details in the block number, so the entire blockchain ledger needs to be sequentially added according to the block number.
[0068] State data integrity refers to the fact that the world state is obtained through state data, which supports the transaction verification work of the endorsing node. Since the state of the blockchain is the result of the execution and accumulation of each transaction in each block starting from the genesis block, the correctness of the world state needs to be ensured based on complete ledger data.
[0069] In the embodiments of the present disclosure, based on the above-described basic properties of the blockchain, a computing power network alliance chain with a mixed working mechanism of full node blocks and light node blocks is proposed.
[0070] Here, the computing network alliance chain includes multiple organizations, and based on this, different blockchains can be stored according to the role division of the nodes in each organization.
[0071] For example, Figure 2As shown, the nodes of each organization in the blockchain are divided into four roles, and each role has different functions. The specific roles are described as follows:
[0072] The leader node supports the client to obtain the block published by the submitted chain, and publishes it to other nodes in the organization for block ledger synchronization.
[0073] The endorser node is a node that undertakes the endorsement task, supports the operation of the contract and the endorsement of the transaction proposal, and needs complete state data to view the accurate world state.
[0074] The anchor node supports the broadcast of messages between organizations.
[0075] The comitter node supports the accounting function, and the other three types of nodes also function as comitter nodes.
[0076] Although the functions of the nodes are different, each node synchronizes the same ledger data. However, over time, it will lead to a large 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 of the present disclosure maintains different types of blockchains for the four roles in each organization of the algorithm network alliance chain according to the division of labor, for example, including: full node chain, light node chain, hybrid node chain, and virtual chain.
[0077] As shown in Figure 2 , the improvements of the algorithm network alliance chain according to the technical solution of the present disclosure are described as follows:
[0078] After the leader node receives the block issued by the order node, it distributes the block. At this time, the full node block corresponding to the block can be sent to the endorser node, and a hybrid node chain of full nodes and light nodes is established subsequently. Then, the light block node corresponding to the block is sent to the anchor node, and a light node chain is established, wherein the main work of the anchor node is inter-organizational communication, and the ledger level is the lightest to avoid node failure.
[0079] Here, the ledger node (committer) in each organization can also be set to receive a backup block to be stored, and a virtual chain is established based on the backup block.
[0080] After improving the algorithm network alliance chain in the manner described above, the processes described in steps S101 to S103 can be performed.
[0081] First, it can be detected whether the number of blocks in the full node chain of the algorithm network alliance chain meets the segmentation condition.
[0082] In an optional implementation, it is detected that the number of blocks in the full node chain of the algorithm network alliance chain satisfies the segmentation condition, and the method specifically includes the following steps:
[0083] In step S11, it is determined that the number of blocks in the full node chain satisfies the segmentation condition 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 satisfies the first number requirement; the first configuration block is the configuration block before the current configuration block in the full node chain.
[0084] In a specific implementation, the number of blocks in the full node chain can be detected from the genesis block to determine whether the number of blocks reaches a 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 satisfied, that is, the segmentation condition is satisfied, and at this time, an identification bit can be inserted into the metadata structure of the 10000th block (that is, the current configuration block). Subsequently, the number of blocks is counted from the next block after the current configuration block to determine whether the second threshold Block_num2 is reached. If it is determined that the second threshold is reached, an identification bit is inserted into the metadata structure of the 20000th block, and so on. The identification bit is inserted into 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] Subsequently, it can be detected whether the full node chain satisfies the node replacement condition, and based on the target field in the configuration block, the block area to be replaced is searched when it is detected that the node replacement condition is satisfied.
[0086] In an optional implementation, the step S101 of inserting the target field into the current configuration block of the algorithm network alliance chain specifically includes the following steps:
[0087] In step S21, a first field and a second field are inserted into the metadata structure of the current configuration block; the first field is used to indicate an identification bit of a segmentation position, and the second field is used to indicate a hash address of the last configuration block before the current configuration block.
[0088] In the embodiments of the present disclosure, two fields can be added in the metadata structure of the configuration block, which are respectively a first field light_label and a second field prehash; wherein the first field light_label is used to indicate the light node identification bit. In specific implementation, in the case that the number of blocks in the full node chain meets the segmentation condition, the first field of light_label=1 can be inserted in the metadata structure; since the structure of the block chain is a one-way structure, the address of the previous block needs to be obtained according to the prehash address; therefore, the second field prehash can also be inserted in 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 in the case that it is detected that the node replacement condition is met, the configuration block based on the inserted target field is used to find the block area to be replaced.
[0090] As can be known from the above description, it can be detected whether the number of blocks of the full node block in the full node chain meets the node replacement condition, for example, it can be detected that the number of blocks of the full node block in the full node chain reaches the first threshold Block_num1, and then it is determined that the node replacement condition is met.
[0091] In an optional embodiment, the above step S102, in the case that it is detected that the full node chain meets the node replacement condition, finds the block area to be replaced based on the identification bit in the configuration block, and specifically includes the following steps:
[0092] Step S31, in the order from back to front, finds the first configuration block in which the identification bit is inserted in the full node chain, to obtain a second configuration block;
[0093] Step S32, determines the specified number of configuration blocks between the second configuration block and a third configuration block in the full node chain as the block area to be replaced; wherein the third configuration block is the configuration block in which the identification bit is inserted after the second configuration block.
[0094] In the embodiments of the present disclosure, in the case that it is detected that the full node chain meets the node replacement condition, the previous configuration block can be quickly located in the order from back to front, starting from the block located at the last end of the block chain at the current time.
[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 the previous configuration block is determined, it can be checked whether the identification bit is inserted in the configuration block; wherein if it is determined that the identification bit is inserted in the configuration block, and the first field light_label = 0 in the identification bit, it indicates that the configuration block is a normal configuration block. Then, the configuration block can be located forward based on the hash address, and it is further judged whether the located configuration block is the second configuration block in the manner described above; and so on, until the first configuration block in which the identification bit is inserted is obtained, so as to obtain the second configuration block.
[0096] After the second configuration block is determined, the next configuration block in which the identification bit is inserted after the second configuration block, i.e. the third configuration block, is determined, and then the specified number of configuration blocks between the second configuration block and the third configuration block in the node chain are determined as the to-be-replaced block region.
[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 specified number of block regions in the block number interval (N, M) can be determined as the to-be-replaced block region. For example, the first 1000 blocks in the block number interval (N, M) can be taken as the to-be-replaced block region.
[0098] After the to-be-replaced block region is determined, as shown in Figure 3 , the full node block corresponding to each light node block in the to-be-replaced block region can be searched in the light node chain, and then the full node block is replaced with the corresponding light node block.
[0099] In specific implementation, the specified number of full node blocks in the block number interval (N, M) can be searched and replaced with light node blocks in the order from front to back starting from the second configuration block N, which guarantees the order of the account book.
[0100] In the above implementation, by storing the account book data of the nodes in each organization in the algorithm network alliance chain according to the roles and needs, the redundancy caused by storing the full amount of account book data by all nodes can be avoided, and each organization in the algorithm network alliance chain can work together to guarantee the integrity and decentralization of the account book; by adding the identification bit in the metadata of the configuration block, the block header and the block body are not affected, and the consistency check of the block chain is not affected, and the position of the segmented replacement block can be quickly located through the identification bit, which achieves the maximum effect with the minimum change to the current alliance chain.
[0101] In an optional implementation, after the full node block is replaced with the corresponding light node block, the method further includes the following steps:
[0102] Step S41, determining the block replaced by the corresponding light node block in the algorithm network alliance chain to obtain 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 in the routing table set in the anchor node of the first organization.
[0105] In the embodiments of the present disclosure, the full node block replaced by the corresponding light node block in the algorithm network alliance chain can be determined as a backup block, for example, the full node block located in the block area to be replaced can be taken as a backup block. Then, the blocks of the full ledger data in the endorsement node are backed up in a historical ledger according to the organization, and are backed up in the accounting node.
[0106] Here, the first organization for backing up the backup block can be determined in the multiple organizations of the algorithm network alliance chain, and then the backup block is backed up in the backup node of the first organization. In order to prevent the ledger data of the backup block from being tampered offline, the master-slave backup in the manner of "one master and two backups" can be adopted, so as to avoid single point failure and verify data consistency.
[0107] In the embodiments of the present disclosure, a routing table is set in the anchor node of each organization, and the information recorded in the routing table is shown in Table 1. Through the routing table, the backup situation of all backup blocks in the algorithm network alliance chain in each organization (i.e. block routing information) can be recorded. Here, the anchor node can also quickly synchronize the block routing information in the routing table to the routing table of other organizations in the algorithm network alliance chain.
[0108] Table 1
[0109]
[0110] Next, a virtual chain can be created based on the backup block to create a virtual chain. The virtual chain supports backup historical block data query work, and its essence is also an independent blockchain, so the ledger data starting from the genesis block needs to be saved.
[0111] Here, the virtual chain is a complete blockchain, but the virtual chain created in each organization contains the block header, block body and metadata of the backup block backed up in the organization.
[0112] In an optional embodiment, the method further comprises the following steps:
[0113] Step S51, in response to the data query request, determining a backup organization of the historical data to be queried based on the routing table; and determining a backup node of the backup historical data in the backup organization;
[0114] Step S52, finding the historical data based on a virtual chain running in the backup node.
[0115] In the embodiments of the present disclosure, after detecting a data query request for ledger data in an algorithm network alliance chain, a chain id and a configuration block block number carried in the data query request can be determined; the chain id is used to indicate a virtual chain where the historical data is located, and the configuration block block number is used to indicate a block number of a block where the historical data to be queried is located. At this time, the chain id and the configuration block block number can be used as a key to query a routing table, and by querying the routing table, an organization for backing up the historical data can be determined, so as to obtain a second organization.
[0116] Then, based on the organization id and the node peer in the routing table, a backup node of the historical data is determined, so as to obtain a backup location of the historical data. After the backup node is determined, a transaction in a historical block can be found through a virtual chain running in the backup node, so as to obtain the historical data.
[0117] In an optional implementation, in the case where the backup node includes a master backup node and a slave backup node, the method further includes:
[0118] First, a first Merkle tree root hash value is calculated based on a block header of a backup block in the master backup node, and a second Merkle tree root hash value is calculated based on a block header of a backup block in the slave backup node.
[0119] Second, consistency of the backup blocks in the master backup node and the slave backup node is verified based on the first Merkle tree root hash value and the second Merkle tree root hash value.
[0120] As can be known from the above description, in order to prevent ledger data of the backup block from being tampered offline, a "one master and two backups" mode can be used for master-slave backup, so as to avoid single point failure and verify data consistency.
[0121] Based on this, a Merkle tree root hash value can be calculated at a regular time through block headers of three backup data, so as to obtain the first Merkle tree root hash value and the second Merkle tree root hash value. Then, consistency of the first Merkle tree root hash value and the second Merkle tree root hash value can be verified, and consistency of the backup blocks in the master backup node and the slave backup node is verified through the consistency verification result, and at the same time, backup is provided in case of attack and damage.
[0122] In an optional embodiment, after the full node block is replaced by the corresponding light node block, the method further comprises the following steps:
[0123] First, the root value of the Bucket tree of the state database on the full node chain of each organization of the algorithm network alliance chain is calculated to obtain a plurality of root plants.
[0124] Second, the consistency and integrity of the world state in the algorithm network alliance chain are verified according to the plurality of root plants.
[0125] The state data of the full volume ledger data of the blockchain guarantees the accuracy of the world state, and the world state supports the endorsement of the transaction submitted by the endorsement node, which can be regenerated according to the change or restart of the node peer. In the embodiment of the present disclosure, the replacement of the full node block in the algorithm network alliance chain will cause the data loss in the state database, so the change of the full node chain is first persisted to save the state data. Based on this, the root value of the Bucket tree of the state database on the mixed chain (the full node chain after replacement) can be calculated regularly to obtain a plurality of root plants.
[0126] After obtaining the plurality of root plants, the consistency and integrity of the world state in the algorithm network alliance chain can be verified according to the root plants.
[0127] In the above embodiment, by regularly calculating the root value of the Bucket tree of the state database on the mixed chain, the efficient verification of the consistency and integrity of the world state in the chain can be guaranteed.
[0128] Investigation shows that most of the current methods for solving the storage pressure in the blockchain use the light node method, in which the peer node with weak chain function or limited storage can set to save the light node ledger, but still needs a peer node to maintain a full node ledger, which will inevitably also face the storage bottleneck of the full volume ledger.
[0129] The transaction volume of the algorithm network alliance chain is huge, and the long-term historical block data has less impact on subsequent functions as time decays, so the technical solution of the present disclosure first proposes a joint working mechanism of full node blocks and light node blocks on the full node chain while guaranteeing the basic properties of the blockchain such as "non-tamperable", "trusted transaction" and "traceable". Among them, the configuration block with the identification bit helps 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 backup by organization, and the subsequent traceability work of the historical data is supported by the virtual chain. The mixed chain of the full node block and the light node block makes the minimum modification to the blockchain, effectively solves the problem of storage pressure of the blockchain, and guarantees the long-term running efficiency of the algorithm network alliance chain.
[0130] Those skilled in the art can understand that, in the above method of the specific embodiment, the writing order of each step does not mean a strict execution order and does not constitute any limitation on the implementation process. The specific execution order of each step should be determined by its function and possible internal logic.
[0131] Based on the same inventive concept, the disclosure embodiments also provide a ledger optimization device for a consortium chain corresponding to the ledger optimization method of the consortium chain. Since the principle of solving problems by the device in the disclosure embodiments is similar to the above-mentioned ledger optimization method of the consortium chain in the disclosure embodiments, the implementation of the device can be referred to the implementation of the method, and the repeated parts will not be described here.
[0132] Referring to Figure 4 Fig. 1 shows a schematic diagram of a ledger optimization device for a consortium chain provided by the disclosure embodiments. The device comprises an insertion unit 10, a searching unit 20, and a block replacement unit 30. Wherein,
[0133] The insertion unit is configured to insert a target field in a current configuration block of an algorithm network consortium chain when it is detected that the number of blocks in a full node chain of the algorithm network consortium chain meets a segmentation condition. The target field contains identification bits for indicating the segmentation position of the blocks in the algorithm network consortium chain, and the hash address of the previous configuration block.
[0134] The searching unit is configured to search for a block area to be replaced based on the target field in the configuration block when it is detected that the full node chain meets a node replacement condition.
[0135] The block replacement unit is configured to search for a light node block corresponding to each full node block in the block area to be replaced in a light node chain, and replace the full node block with the corresponding light node block.
[0136] In the above embodiments, by inserting a target field in a configuration block and searching for a block area to be replaced based on the identification bits, each full node block in the block area to be replaced is replaced with a light node block, which can ensure that the storage burden of the full block ledger is reduced under the characteristics of the blockchain itself being tamper-proof, effectively solve the ledger storage pressure of the node, and promote the sustainable development of the algorithm network consortium chain. In a possible implementation, the insertion unit is further configured to:
[0137] insert a first field and a second field in the metadata structure of the current configuration block; wherein the first field is used to indicate the identification bits of the segmentation position, and the second field is used to indicate the hash address of the previous configuration block before the current configuration block.
[0138] In a possible implementation, the insertion unit is further configured to:
[0139] In a case where the number of configuration blocks between the current configuration block and the first configuration block in the full node chain satisfies a first number requirement, it is determined that the number of blocks in the full node chain satisfies a segmentation condition; wherein the first configuration block is a configuration block in which an identification bit is inserted immediately before the current configuration block in the full node chain.
[0140] In a possible implementation, the searching unit is further configured to:
[0141] In a possible implementation, the searching unit is further configured to:
[0142] In a possible implementation, the searching unit is further configured to:
[0143] In a possible implementation, the algorithm network alliance chain includes a plurality of organizations, and each of the organizations includes an anchor node and an endorsement node; wherein the endorsement node is configured to receive a full node block sent by a master node in the organization, and the anchor node is configured to receive a light node block sent by the master node in the organization.
[0144] In a possible implementation, the apparatus is further configured to:
[0145] In a possible implementation, the apparatus is further configured to:
[0146] In a possible implementation, the apparatus is further configured to:
[0147] In a possible implementation, the apparatus is further configured to:
[0148] In a possible implementation, the apparatus is further configured to:
[0149] In a possible implementation, the apparatus is further configured to:
[0150] In a possible implementation, the apparatus is further configured to:
[0151] In a possible implementation, in a case where the backup node includes a master backup node and a slave backup node, the apparatus is further configured to:
[0152] calculate a first Merkle tree root hash value based on block headers of the backup blocks in the primary backup node, and calculate a second Merkle tree root hash value based on block headers of the backup blocks in the secondary backup node;
[0153] verify consistency of the backup blocks in the primary backup node and the secondary backup node based on the first Merkle tree root hash value and the second Merkle tree root hash value.
[0154] In a possible implementation, the apparatus further includes:
[0155] After replacing the full node blocks with the corresponding light node blocks, calculate root values of Bucket trees of state databases on a full node chain in each organization of the computing network alliance chain, to obtain a plurality of root plants;
[0156] Verify consistency and integrity of a world state in the computing network alliance chain according to the plurality of root plants.
[0157] The description of the processing procedure of each module in the apparatus and the interaction procedure between the modules can refer to the related description in the foregoing method embodiments, and will not be described in detail here.
[0158] Corresponding to the ledger optimization method of the alliance chain in Figure 1 The present disclosure also provides an electronic device 500, as shown in Figure 5 The structural schematic diagram of the electronic device 500 provided by the present disclosure, which includes:
[0159] a processor 51, a memory 52, and a bus 53; the memory 52 is used to store execution instructions, including an internal memory 521 and an external memory 522; the internal memory 521 is also called an internal memory, which is used to temporarily store operation data in the processor 51 and exchange data with the external memory 522 such as a hard disk; the processor 51 exchanges data with the external memory 522 through the internal memory 521; when the electronic device 500 is running, the processor 51 and the memory 52 communicate through the bus 53, so that the processor 51 executes the following instructions:
[0160] In a case where it is detected that the number of blocks in the full node chain of the computing network alliance chain meets the segmentation condition, insert a target field in the current configuration block of the computing network alliance chain; the target field includes identification bits for indicating the segmentation position of the blocks in the computing network alliance chain, and a hash address of the previous configuration block;
[0161] In a case where it is detected that the full node chain meets the node replacement condition, find a block area to be replaced based on the target field in the configuration block;
[0162] In the light node chain, a light node block corresponding to each full node block in the block area to be replaced is searched, and the full node block is replaced by the corresponding light node block.
[0163] The present disclosure also provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, performs the steps of the ledger optimization method of the consortium chain described in the above method embodiments. The storage medium can be a volatile or non-volatile computer-readable storage medium.
[0164] The present disclosure also provides a computer program product carrying a program code, the program code including instructions for executing the steps of the ledger optimization method of the consortium chain described in the above method embodiments. For details, please refer to the above method embodiments, which will not be repeated here.
[0165] The computer program product can be implemented by hardware, software or a combination thereof. In an optional embodiment, the computer program product is embodied as a computer storage medium. In another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK) and the like.
[0166] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working process of the above-described system and device can refer to the corresponding process in the above method embodiments, which will not be repeated here. In several embodiments provided by the present disclosure, it should be understood that the disclosed system, device and method can be implemented by other ways. The above-described device embodiments are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some communication interface, device or unit, which can be electrical, mechanical or other forms.
[0167] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, i.e. they can be located in one place or distributed on multiple network units. According to actual needs, part or all of the units can be selected to achieve the purpose of the present embodiment.
[0168] In addition, each function unit in various embodiments of the present disclosure can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit.
[0169] If the functions are implemented in the form of software function units and sold or used as independent products, they can be stored in a nonvolatile computer readable storage medium executable by a processor. Based on this understanding, the technical solutions of the present disclosure essentially or the part that contributes to the prior art or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes several instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the methods described in various embodiments of the present disclosure. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various media that can store program codes.
[0170] Finally, it should be noted that: the above-described embodiments are merely specific embodiments of the present disclosure, used to illustrate the technical solutions of the present disclosure, rather than limit them. The protection scope of the present disclosure is not limited thereto, although the present disclosure has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand: any person skilled in the art within the technical range disclosed by the present disclosure can modify or easily think of changes to the technical solutions recorded in the foregoing embodiments, or make equivalent replacements to part of the technical features; and these modifications, changes or replacements do not make the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present disclosure, and should be covered within the protection scope of the present disclosure. Therefore, the protection scope of the present disclosure should be subject to the protection scope of the claims.
Claims
1. A ledger optimization method for consortium blockchains, characterized in that, The method comprises the following steps: In the case that the number of blocks in the full node chain of the algorithm network alliance chain meets the segmentation condition, a first field and a second field are inserted in the metadata structure of the current configuration block; the first field is used to indicate the identification bit of the segmentation position, and the second field is used to indicate the hash address of the last configuration block before the current configuration block; the target field contains the identification bit used to indicate the segmentation position of the block in the algorithm network alliance chain and the hash address of the last configuration block; In the full node chain, the first configuration block with the inserted identification bit is found in the order from back to front, and a second configuration block is obtained; A specified number of configuration blocks between the second configuration block and a third configuration block in the full node chain are determined as a to-be-replaced block area; the third configuration block is a configuration block with an inserted identification bit after the second configuration block; In the light node chain, a light node block corresponding to each full node block in the to-be-replaced block area is found, and the full node block is replaced by the corresponding light node block.
2. The method of claim 1, wherein, The detection of the number of blocks in the full node chain of the algorithm network alliance chain meeting the segmentation condition comprises: In the case that the number of configuration blocks between the current configuration block and a 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; the first configuration block is the last configuration block with an inserted identification bit in the full node chain.
3. The method of claim 1, wherein, The algorithm network alliance chain comprises a plurality of organizations, and each organization comprises an anchor node and an endorsement node; the endorsement node is used to receive a full node block sent by a master node in the organization, and the anchor node is used to receive a light node block sent by the master node in the organization.
4. The method according to claim 1 or 3, characterized in that, After the full node block is replaced by the corresponding light node block, the method further comprises: In the algorithm network alliance chain, a backup block replaced by the corresponding light node block is determined, and a virtual chain is created based on the backup block; The backup block is backed up in a backup node of a first organization, and a virtual chain is created based on the backup block; Block routing information of the backup block is written in a routing table set in the anchor node of the first organization.
5. The method of claim 4, wherein, The method further comprises: In response to a data query request, a backup organization of historical data to be queried is determined based on the routing table, and a backup node backing up the historical data is determined in the backup organization; The historical data is found based on the virtual chain running in the backup node.
6. The method of claim 4, wherein, The backup node comprises a master backup node and a slave backup node, and the method further comprises: A first Merkle tree root hash value is calculated based on the block header of the backup block in the master backup node, and a second Merkle tree root hash value is calculated based on the block header of the backup block in the slave backup node; The consistency of the backup blocks in the master backup node and the slave backup node is verified based on the first Merkle tree root hash value and the second Merkle tree root hash value.
7. The method of claim 1, wherein, After the full node block is replaced by the corresponding light node block, the method further comprises: Root values of Bucket trees of state databases on the full node chain in each organization of the algorithm network alliance chain are calculated, and a plurality of root values are obtained. According to the plurality of root check, the consistency and integrity of the world state in the algorithm network alliance chain. 8.A ledger optimization apparatus of a consortium chain, characterized by, Comprise: Insertion unit, for inserting a first field and a second field in the metadata structure of the current configuration block in the case of detecting that the number of blocks in the full node chain of the algorithm network alliance chain meets the segmentation condition; wherein the first field is used to indicate the identification bit of the segmentation position, and the second field is used to indicate the hash address of the last configuration block before the current configuration block; wherein the target field is used to indicate the segmentation position of the block in the algorithm network alliance chain, and the hash address of the last configuration block; Finding unit, for finding the first configuration block with inserted identification bit in the full node chain in the order from back to front, obtaining a second configuration block; and determining a specified number of configuration blocks between the second configuration block and a third configuration block in the full node chain as a to-be-replaced block area; wherein the third configuration block is the configuration block with inserted identification bit after the second configuration block; Block replacement unit, for finding the light node block corresponding to each full node block in the to-be-replaced block area in the light node chain, and replacing the full node block with the corresponding light node block.
9. An electronic device, comprising: Comprise: Processor, memory and bus, the memory stores machine readable instructions executable by the processor, when the electronic device runs, the processor and the memory communicate through the bus, the machine readable instructions are executed by the processor to execute the steps of the account book optimization of the alliance chain as claimed in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, which is executed by the processor to execute the steps of the account book optimization of the alliance chain as claimed in any one of claims 1 to 7.
11. A computer program product, characterised in that, The computer program product is stored in the storage medium, and the program product is executed by at least one processor to realize the steps of the account book optimization of the alliance chain as claimed in any one of claims 1 to 7.
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