A Blockchain Data Storage and Reading Method Based on Block Aggregation Encoding
Through block aggregation coding and optimized reading process, the problems of high storage redundancy of blockchain systems and low data processing efficiency when the number of nodes changes are solved, more efficient data storage and reading are achieved, and the availability and scalability of blockchain systems are improved.
Patent Information
- Application Number
- CN202510743966.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-05
- Publication Date
- 2025-08-05
- Estimated Expiration
- 2045-06-05
AI Technical Summary
The blockchain system has high storage redundancy and low data processing efficiency when the number of nodes changes. The existing erasure coding technology has problems such as low access efficiency and large communication overhead in blockchain systems.
The block aggregation encoding method is adopted, and multiple blocks are encoded using erasure coding, and the recoding process in different scenarios is designed when the number of nodes changes, combining the optimized reading process of local node download, node download and off-site encoding group block download.
While reducing storage redundancy, it improves data processing efficiency and reading speed, reduces data transmission volume and processing delay, and improves the availability and scalability of blockchain systems.
Smart Images

Figure CN120255826B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of blockchain and erasure codes, and specifically relates to a blockchain data storage and reading method based on block aggregation coding. Background Art
[0002] As a key breakthrough in core technology, blockchain represents a crucial direction for the development of the digital economy, boasting broad application prospects in finance, the Internet of Things, public administration, transportation, health insurance, education, and other fields. In finance, blockchain technology can directly connect users without the need for third-party institutions to intervene in transactions. In logistics, it can enable full traceability of goods throughout the entire process, thereby reducing logistics costs and optimizing logistics management processes. In health insurance, the application of blockchain smart contracts can automatically process claims for eligible policies, streamlining the insurance claims process.
[0003] Blockchain's decentralized and tamper-proof nature offers a promising solution for addressing diverse challenges across various sectors. However, the highly redundant storage mechanisms of existing blockchain systems limit their further development. In practical applications, to ensure data consistency across nodes within the system, blockchain relies on a storage mechanism where all intact nodes store data. While this approach enhances data fault tolerance, it also leads to issues such as low storage performance and poor scalability.
[0004] The requirement for all nodes to maintain a copy of the entire blockchain creates enormous storage pressure. As the number of blockchain nodes increases, this pressure, far from being alleviated, becomes a significant barrier to new node onboarding, severely impacting blockchain scalability and limiting its further development. To address this issue, numerous studies have attempted to optimize the storage mechanisms of blockchain systems to enhance their scalability. Erasure coding, a technology widely used in traditional distributed storage systems, is being explored for integration into blockchain systems, aiming to significantly improve data storage efficiency while ensuring block data consistency. However, while current approaches to optimizing blockchain system performance using erasure coding can reduce storage redundancy to a certain extent, they still suffer from issues such as low block access efficiency and high cross-node communication overhead. Summary of the Invention
[0005] The purpose of this invention is to solve the problems of high redundancy in blockchain data storage and low data processing efficiency when the number of nodes in the system changes. A blockchain data storage and reading method based on block aggregation coding is proposed.
[0006] The technical solution of the present invention is as follows: In the first aspect, a blockchain data storage method based on block aggregation coding comprises the following steps:
[0007] Based on the block storage characteristics, multiple blocks are aggregated and encoded using erasure codes to obtain coded blocks;
[0008] According to the data migration characteristics when the scale of blockchain nodes changes, the coding blocks are re-encoded to complete the blockchain data storage.
[0009] Preferably, the erasure code adopts RS code; and according to the block storage characteristics, the erasure code is used to aggregate and encode multiple blocks to obtain a coded block, specifically:
[0010] Use RS code for encoding operation, and the encoding parameters are set to 、 ,in, and Indicates encoding parameters, Indicates the total number of nodes, Indicates the upper limit of the number of malicious nodes tolerated. Each block is packaged and encoded as a block set;
[0011] Each node stores the latest consensus block in the local cache, and responds to the number of blocks in the local cache reaching , through the node The blocks are taken out to form a block set, and the block set is encoded.
[0012] Preferably, the encoding of the block set is specifically as follows:
[0013] Taking the largest block size in the same block set as the standard, the remaining blocks are expanded to the same size as the largest block by adding 0 at the end to generate Check blocks of the same size, and then get Blocks of the same size are taken as a coding group, and the coding group is given a unique identifier epoch that increases gradually;
[0014] Sort all nodes by their general information;
[0015] Use the epoch known to all nodes and the current number of nodes Initialize the pseudo-random number generator;
[0016] The same natural number sequence is generated for all nodes by initializing the pseudo-random number generator, and the natural number sequence contains 1~ common natural number, each node selects a block in the coding group to store, natural number The first in the sequence bits, then the sorting is The node storage code group blocks, and delete the remaining blocks in the block set where the selected block is located.
[0017] As a preference, when the blockchain node scale changes, the total number of nodes Change, the upper limit of the number of malicious nodes tolerated There are two situations: change and constancy.
[0018] As a preference, the new node access causes the upper limit of the number of malicious nodes to be tolerated When the data of the coding block changes, the data is re-encoded as follows:
[0019] On the new node side, the block request of the current encoding round is broadcast to the original node, and in response to the original node receiving blocks, re-encodes them, and generates a new check data block; calculates the storage location of the check data block using a pseudo-random number, and in the next round of re-encoding broadcasting, sends the check data block to the target node storing the check data block through the new node;
[0020] At the original node, in response to the new node's broadcast information, check whether the broadcast information correctly contains the previous round The node obtains the signature of each node and returns the corresponding block stored locally in this encoding round and the signature of this node. If the original node needs to store the verification data block calculated by the new node in the previous round, it checks whether the broadcast information contains the verification data block and stores it.
[0021] The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed.
[0022] As a preference, the node exit causes the upper limit of the number of malicious nodes to be tolerated When the data of the coding block changes, the data is re-encoded as follows:
[0023] At the node to be exited, the locally stored block data of the current encoding round is sent to all other nodes;
[0024] On all other nodes, in response to the block data of the node to be exited, a response is sent to the node to be exited. The node storing the check block updates the local check block data based on the block data and adds the updated check block data hash to the response.
[0025] At the node to be exited, in response to all other nodes The replica node responds and broadcasts the hash of the verification block data to all other nodes;
[0026] On all other nodes, in response to the broadcast message from the node to be exited, the block hash is stored locally and a response is sent to the node to be exited.
[0027] The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed.
[0028] As a preference, when a new node joins, the upper limit of the number of malicious nodes tolerated When the data of the coding block is unchanged, the data is re-encoded as follows:
[0029] Send broadcast information through the new node to all original nodes to request each All blocks of the wheel;
[0030] In response to the broadcast message sent by the new node, the block is returned through the original node;
[0031] Use the new node to store the corresponding block, and send the corresponding block to the node storing the verification data block through the new node, send the block received by the new node to the target node that needs to exchange blocks through the new node, and send the block of the previous round to all nodes through the new node. The response signature of each node;
[0032] In response to the information of the new node, the node storing the check data block updates the stored check data block of this round;
[0033] The target node that needs to exchange blocks returns the replacement block and determines whether the broadcast message contains The node response signature of the previous round, if it contains it, it will sign and respond, if not, it will not respond;
[0034] The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed;
[0035] Node exit, the upper limit of the number of malicious nodes tolerated When the data of the coding block is unchanged, the data is re-encoded as follows:
[0036] Send broadcast information through the node to be exited to all other nodes. All blocks of the wheel;
[0037] In response to the broadcast message from the node to be exited, all other nodes send a response to the received block data;
[0038] In response to the responses from all other nodes, a broadcast message is sent through the node to be exited, notifying the node storing the check block to calculate and process the original check block;
[0039] Based on the received block data, the node storing the check block updates the original check block locally and broadcasts the new check block data hash.
[0040] The beneficial effects of the present invention are:
[0041] The present invention uses erasure codes to encode and store blocks, and designs block recoding processes for different scenarios with changing numbers of nodes, which has lower data transmission volume and data processing delay, and improves the overall usability of the method.
[0042] In a second aspect, a blockchain data reading method based on block aggregation coding comprises the following steps:
[0043] According to the data reading characteristics of the coding block, an optimized reading process based on local node download, node download and remote coding group block download is adopted for block reading.
[0044] Preferably, the data reading characteristics of the coding block include three types: uncoded cache, local storage or cross-node acquisition;
[0045] The uncoded cached coded blocks are downloaded by the local node to complete the block reading;
[0046] The locally stored coded blocks are downloaded from remote nodes to complete block reading;
[0047] The coding blocks that need to be obtained across nodes are read by downloading blocks of the coding group in a different location.
[0048] Preferably, the block reading is performed by optimizing the reading process according to the data reading characteristics of the coding block, specifically:
[0049] Responding to the client's block Request to verify the height of the latest block and the block Is the height difference less than or equal to the current latest block index divided by If the remainder is For unencoded cached chunks, retrieve and return the chunk from the local cache ;
[0050] If the height of the latest block is The height difference is greater than the current latest block index divided by The remainder of the block Does not belong to the latest block group to be encoded, using block The height of determines the current encoding round and calculates the block position in its coding round;
[0051] Calculate and locate the actual storage block Node;
[0052] If the block For locally stored blocks located on the local node, the block is retrieved and returned from the node state database ;
[0053] If the block For blocks that need to be obtained across nodes, send The target node sends a request and starts the timer;
[0054] If the target node does not respond before the timer expires, or due to network delays, the block If it fails to arrive in time, it will broadcast the request to the entire network, seeking to obtain the stored blocks from other nodes The remaining blocks of the encoding group.
[0055] The beneficial effects of the present invention are:
[0056] The present invention uses erasure codes to encode and store blocks, and designs an optimized reading process for block acquisition, thereby further improving block reading efficiency and achieving efficient data processing while ensuring that block storage redundancy is reduced. BRIEF DESCRIPTION OF THE DRAWINGS
[0057] Figure 1 The figure shows a flowchart of a blockchain data storage method based on block aggregation coding provided by Example 1 of the present invention.
[0058] Figure 2 The figure shows a schematic diagram of the block data aggregation coding storage principle based on the erasure code technology provided by Example 1 of the present invention.
[0059] Figure 3 FIG2 is a schematic diagram of a data recoding process when f changes due to blockchain expansion provided in Example 1 of the present invention.
[0060] Figure 4 FIG2 is a schematic diagram of the data migration process when f remains unchanged due to blockchain expansion provided by Example 1 of the present invention.
[0061] Figure 5 FIG2 is a schematic diagram of a data recoding process when f remains unchanged due to blockchain expansion provided in Example 1 of the present invention.
[0062] Figure 6 FIG2 is a schematic diagram of the data migration process when f remains unchanged due to blockchain expansion provided by Example 1 of the present invention. DETAILED DESCRIPTION
[0063] The exemplary embodiments of the present invention will now be described in detail with reference to the accompanying drawings. It should be understood that the embodiments shown and described in the accompanying drawings are merely exemplary and are intended to illustrate the principles and spirit of the present invention, rather than to limit the scope of the present invention.
[0064] Example 1:
[0065] like Figure 1 As shown, a blockchain data storage method based on block aggregation coding includes the following steps:
[0066] S1. Aggregate and encode multiple blocks using erasure codes based on block storage characteristics to obtain coded blocks.
[0067] S2. Based on the data migration characteristics when the blockchain node scale changes, the encoded block is re-encoded to complete the blockchain data storage.
[0068] In this embodiment, the present invention first packages multiple blocks into a block set and encodes the block set using RS code. Then, when the encoding is completed, a single node only stores one block in the set and deletes the remaining blocks, thereby improving storage efficiency. The complete process is as follows: Figure 2 As shown, the step S1 is specifically as follows:
[0069] The erasure code adopts RS code; according to the block storage characteristics, multiple blocks are aggregated and encoded using the erasure code to obtain a coded block, specifically:
[0070] Use RS code for encoding operation, and the encoding parameters are set to 、 ,in, and Indicates encoding parameters, Indicates the total number of nodes, Indicates the upper limit of the number of malicious nodes tolerated. Each block is packaged and encoded as a block set;
[0071] Each node stores the latest consensus block in the local cache, and responds to the number of blocks in the local cache reaching , through the node The blocks are taken out to form a block set, and the block set is encoded, specifically:
[0072] Taking the largest block size in the block set as the standard, the remaining blocks are expanded to the same size by adding 0 at the end to generate Check blocks of the same size, and then get The blocks of the same size are regarded as a coding group, and are given a unique identifier epoch which increases gradually.
[0073] Since there are a large number of access requests for block data in the blockchain system, and the check blocks generated by the code are meaningless 01 sequences, the node storing the check blocks needs to forward the request to other nodes when receiving the block request, which indirectly increases the load of the node. Therefore, in order to balance the number of check blocks stored by each node, the present invention first sorts all nodes according to the common information such as the IP address of each node. The sorting can be automatically reached by all nodes. Then, a pseudo-random number generator is used to determine the order of the check blocks in the coding group. How are blocks stored in the system? On each node, use the epoch known to all nodes and the current number of nodes To initialize the pseudo-random number generator, all nodes can generate the same natural number sequence, which contains 1~ common natural numbers, if the natural number The first in the sequence bits, then the sorting is The node will store the first blocks. Each node is based on the natural number and sort The corresponding rule selects a block from the encoding group for storage and deletes the remaining blocks in the block set containing the block selected according to the rule. This approach allows all nodes to store different blocks from the encoding group, and the storage locations of the encoding blocks are completely random, ensuring load balancing between nodes.
[0074] When applying erasure codes to blockchain systems, it is necessary to ensure the security and recoverability of each block while reducing storage redundancy. Since all blocks are stored only once, the encoding parameters and The setting of must be consistent with the number of malicious nodes that the PBFT protocol tolerates. malicious or downtime nodes, so for a block encoding group, the encoding parameters should also be set to be able to tolerate up to blocks are lost or damaged, so it can be concluded that the size of r needs to be set to at least , The maximum size is The encoding method adopted by the present invention can improve the storage efficiency of blocks to the theoretical optimum while ensuring the safety and recoverability of blocks.
[0075] When only erasure codes are considered, the present invention can reduce the data storage complexity from Reduce to , that is, the data storage consumption does not show an obvious linear change with the increase in the number of nodes, but is only related to the size of the block data in the entire network.
[0076] In this embodiment, in step S2, when the blockchain node scale changes, the total number of nodes Change, the upper limit of the number of malicious nodes tolerated There are two situations: change and no change. Specifically, when nodes join or exit the system, the number changes are divided into multiple types, and the availability of block data after the change in the number of nodes is guaranteed by migrating the internal data of the nodes or re-encoding them.
[0077] When the number of nodes in the system changes, it indicates that nodes in the blockchain network are dynamically joining or leaving. This involves a large amount of data transmission and requires data replication across the entire network. Furthermore, the processing of network changes by existing erasure codes introduced into blockchain research further increases the amount of data transmitted, often reaching several or even dozens of times the total network data volume. Based on this, the embodiments of the present invention analyze the data migration and recoding patterns when the number of nodes changes, thereby reducing the amount of data transmission involved in this process and improving blockchain operational efficiency.
[0078] When a node in the embodiment of the present invention joins, the number of nodes in the entire network will increase by one, but the maximum number of malicious nodes that can be tolerated is There are two cases: change and no change (it should be noted that in this embodiment of the present invention, the downtime of the newly added node during the re-encoding process is regarded as a successful addition to the blockchain).
[0079] When the number of nodes changes, the total number of nodes in the system will Changes, when a new node is added to the system, Will add one, that is , but the upper limit of the number of malicious nodes tolerated There may be two situations: change and no change, that is, only when When a node joins, the system state changes to ,in , and in or When the number of nodes increases by one, it will only make changes, and constant.
[0080] Node joining causes change, The change is that a check block needs to be added for each block in the coding group. Therefore, when a new node joins, all nodes need to calculate a new check block for each original block in the coding group and store it on the new node. To ensure a balanced distribution of check blocks, the new node needs to exchange blocks with other nodes in a probabilistic manner.
[0081] Specifically, due to When the change is made, the check block is operated, and the check block can be calculated, generated or deleted immediately, so compared to The unchanged situation, The change is relatively simple. The newly added node needs to request blocks from all other nodes and encode them. A new verification data block is generated for each encoding round. Then, in order to maintain the uniform distribution of the verification data blocks, it needs to randomly exchange the blocks of the encoding round with an existing node. The specific process is as follows: Figure 3 shown.
[0082] The re-encoding protocol cyclically re-encodes historical blocks according to each encoding round of the block until all data is processed:
[0083] At the newly added node, the newly added node broadcasts the block request of the current encoding round to the rest of the nodes (including the block request of the previous round). signatures of corresponding nodes), due to the PBFT protocol, it is guaranteed that at least Correct blocks, the node receives After a block is generated, the new block is re-encoded, a new check data block is generated, and the storage location of the block is calculated using a pseudo-random number. Then, during the next round of re-encoding broadcast, the newly added node sends the check block to the target node that should store the check block at the same time.
[0084] On the original node side, when the original node receives the broadcast information of the newly added node, it first checks whether it correctly contains the previous round of The node obtains the signature of each node and then returns the corresponding block stored locally in this encoding round and the signature of this node. At the same time, if the node needs to store the verification data block calculated by the newly added node in the previous round, it will also check whether the broadcast information contains the verification data block and store it.
[0085] The withdrawal of new nodes leads to the upper limit of the number of malicious nodes tolerated When the block size changes, the encoding block is re-encoded. Specifically, the node to be exited sends the block data of the current encoding round stored locally to all other nodes. After receiving the block data, all other nodes send a response to the node to be exited. The node storing the check block needs to update the local check block data according to the block data and add the updated check block data hash to the response. The node to be exited receives the check block data. After the backup node responds, it broadcasts the hash of the verification block data to all other nodes; after all other nodes receive the broadcast message, they store the block hash locally and send a response to the node to be exited; the historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed.
[0086] In order to enable all nodes in the network to reach a consensus on the storage location of the newly calculated check block in each encoding round, the present invention adopts (Epoch, ) is used as the pseudo-random number generator seed to uniformly distribute the storage locations of new check blocks for that round. Furthermore, to enable nodes to verify the correctness of the newly calculated check blocks in each re-encoding round, all nodes in the network pre-calculate the possible future check blocks (0-2) when encoding and storing each new consensus block. However, they do not store the block bodies, only the block headers for subsequent verification.
[0087] Node Join When unchanged, No need to add any new blocks, just store The entire network data on the nodes is redistributed to +1 nodes, that is, for each block in the coding group, a new real block needs to be added to its real block set. A simple approach is to take a real block from the next coding group and add it to the coding group. However, this approach will cause a large number of block migrations between nodes. The present invention replaces the newly added real block by adding a blank block to each coding group. The blank blocks of each coding group are randomly distributed on different nodes to achieve uniform distribution of block data across the entire network. Subsequently, the new consensus blocks will be filled into the blank blocks in order. Specifically: The invariance is essentially equivalent to the data migration of the real block and the recalculation of the coded block. When the number of nodes increases from 7 to 8, Figure 4 As shown, the change of block data can be regarded as the change of each of the seven nodes ( ) The real blocks in the encoding rounds are distributed to each of the eight nodes ( ) coding rounds, and modify this ( ) of the encoding rounds In order to ensure the uniform distribution of the verification data blocks, the newly added nodes need to randomly exchange blocks with the original nodes.
[0088] and The same changes are made. The present invention also cyclically recodes the historical blocks according to each encoding round of the blocks until all the data are processed. Figure 5 Here is the detailed process of the agreement:
[0089] The newly added node sends a broadcast message to request all blocks in each round from all other nodes;
[0090] The remaining nodes return the block after receiving the broadcast information;
[0091] New node storage corresponding block (get After a response), send a message to all other nodes (send the corresponding block to the node that stores the check block in this round, send the block received by the newly added node in this round to the target node that needs to exchange blocks, and send the block received in the previous round to all nodes). response signature of each node);
[0092] All nodes perform corresponding operations and respond after receiving the message (the verification node of this round performs an update operation on the stored verification block of this round after receiving the block of this round, and the target node that needs to exchange the block returns the replacement block, and all nodes determine whether the broadcast message contains The previous round of node response signatures, if included, will sign and respond).
[0093] The upper limit of the number of malicious nodes tolerated by new nodes When the data of the coding block is unchanged, the data is re-encoded as follows:
[0094] After the node exits, it sends a broadcast message to all other nodes. All blocks of the wheel;
[0095] Other nodes send responses that indicate they have received the block data;
[0096] The node to be exited sends a broadcast message to notify the node storing the verification block to calculate and process the original verification block;
[0097] The node storing the check block updates the original check block locally based on the received block data and broadcasts the new check block data hash.
[0098] Example 2:
[0099] On the basis of Example 1, an embodiment of the present invention further provides a blockchain data reading method based on block aggregation coding, which is used to read the blockchain data stored by the blockchain data storage method according to Example 1. The blockchain data reading method based on block aggregation coding comprises the following steps:
[0100] According to the data reading characteristics of the coding block, an optimized reading process based on local node download, node download and remote coding group block download is adopted for block reading.
[0101] The data reading characteristics of the coding block include three types: uncoded cache, local storage or cross-node acquisition; the coding block of the uncoded cache is downloaded by the local node to complete the block reading; the coding block stored locally is downloaded through the node to complete the block reading; the coding block that needs to be obtained across nodes is downloaded by the remote coding group block to complete the block reading.
[0102] The blockchain's inherent high data redundancy not only ensures state consistency between nodes but also maximizes the speed of block data reading. However, after the introduction of erasure codes, blocks are encoded and stored, and each node only stores a portion of the entire chain's blocks. Therefore, when a node needs to obtain information about an unstored block, it must download the block through cross-node network communication, causing communication delays. To address this issue, the present invention redesigns the block reading process, achieving the goal of node normal block acquisition through two methods: direct acquisition and computational repair. To respond to external block access requests, the embodiment of the present invention completes the response to block requests through three target block download methods, including local node download, remote node download, and remote coding group block download. Encoded storage based on erasure codes will lead to inconsistent block storage locations. Therefore, the key to block reading is to calculate the storage location of the target block based on information such as block height and encoding round number, and finally obtain the block through the corresponding target block download method.
[0103] Figure 6 Shows the detailed steps of the node processing block access request. When the node receives the block access request from the client When a request is made, the system will first verify the height of the latest block in the current system and the block The difference between the heights (Height-height) is greater than the current latest block index divided by The remainder [Height%(nf)], if yes, it means the block It has not yet been stored in the reverse encoding and exists in the local cache of all formula nodes. The nodes directly retrieve and return the block from the local cache. ;
[0104] If the height of the latest block is The height difference is greater than the current latest block index divided by The remainder indicates that the block Does not belong to the latest block group to be encoded, the system will use the block The height of the current encoding round is determined by and through Computational Block The position in its encoding round, where Indicates the block location, Represents modular operation;
[0105] calculate Locating the actual storage block Node;
[0106] If the block For locally stored blocks located on the local node, the block is retrieved and returned from the node state database ;
[0107] If the block For blocks that need to be obtained across nodes, send The target node sends a request and starts a timer; if the target node does not respond before the timer expires, or due to network delays, the block If the block fails to arrive in time, the node will broadcast the request to the entire network, seeking to obtain the stored block from other nodes. The remaining blocks of the encoding group.
[0108] Due to the characteristics of PBFT, this node can receive at least Valid block data or checksum data can be used to decode and recover the requested block. Once the block is successfully decoded, the system will temporarily cache it locally and return it to the client.
[0109] Those skilled in the art will appreciate that the embodiments described herein are intended to help readers understand the principles of the present invention, and it should be understood that the scope of protection of the present invention is not limited to such specific descriptions and embodiments. Those skilled in the art can make various other specific variations and combinations based on the technical teachings disclosed in the present invention without departing from the essence of the present invention, and such variations and combinations are still within the scope of protection of the present invention.
Claims
1. A blockchain data storage method based on block aggregation coding, characterized in that: The following steps are involved: Based on the block storage characteristics, multiple blocks are aggregated and encoded using erasure codes to obtain coded blocks; According to the data migration characteristics when the blockchain node scale changes, the coding block is re-encoded to complete the blockchain data storage; The erasure code adopts RS code; according to the block storage characteristics, multiple blocks are aggregated and encoded using the erasure code to obtain a coded block, specifically: Use RS code for encoding operation, and the encoding parameters are set to 、 ,in, and Indicates encoding parameters, Indicates the total number of nodes, Indicates the upper limit of the number of malicious nodes tolerated, Each block is packaged and encoded as a block set; The node stores each latest consensus block in the local cache, and responds to the number of blocks in the local cache reaching , through the node The blocks are taken out to form a block set, and the block set is encoded; The block set is encoded as follows: Taking the largest block size in the same block set as the standard, the remaining blocks are expanded to the same size as the largest block by adding 0 at the end to generate Check blocks of the same size, and then get Blocks of the same size are taken as a coding group, and the coding group is given a unique identifier epoch that increases gradually; Sort all nodes by their general information; Use the epoch known to all nodes and the current number of nodes Initialize the pseudo-random number generator; The same natural number sequence is generated for all nodes by initializing the pseudo-random number generator, and the natural number sequence contains 1~ common A natural number, each node selects a block in the coding group to store, a natural number The first in the sequence bits, then the sorting is The node storage code in the group blocks, and delete the remaining blocks in the block set where the selected block is located.
2. The blockchain data storage method based on block aggregation coding according to claim 1 is characterized in that: When the blockchain node scale changes, the total number of nodes Change, the upper limit of the number of malicious nodes tolerated There are two situations: change and invariance.
3. The blockchain data storage method based on block aggregation coding according to claim 2 is characterized in that: The new node access leads to the upper limit of the number of malicious nodes tolerated When the data of the coding block changes, the data is re-encoded as follows: On the new node side, the block request of the current encoding round is broadcast to the original node, and in response to the original node receiving blocks, re-encode and generate new check data blocks; The storage location of the check data block is calculated using a pseudo-random number, and in the next round of re-encoding broadcasting, the check data block is sent to the target node storing the check data block through the new node; At the original node, in response to the new node's broadcast information, check whether the broadcast information correctly contains the previous round The signature of each node is returned, and the corresponding block stored locally in this encoding round and the signature of this node are returned; If the original node needs to store the verification data block calculated by the new node in the previous round, it checks whether the broadcast information contains the verification data block and stores it; The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed.
4. The blockchain data storage method based on block aggregation coding according to claim 2 is characterized in that: The node exit causes the upper limit of the number of malicious nodes to be tolerated When the data of the coding block changes, the data is re-encoded as follows: At the node to be exited, the locally stored block data of the current encoding round is sent to all other nodes; On all other nodes, in response to the block data of the node to be exited, a response is sent to the node to be exited. The node storing the check block updates the local check block data based on the block data and adds the updated check block data hash to the response. At the node to be exited, in response to all other nodes The replica node responds and broadcasts the hash of the verification block data to all other nodes; On all other nodes, in response to the broadcast message from the node to be exited, the block hash is stored locally and a response is sent to the node to be exited. The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed.
5. The blockchain data storage method based on block aggregation coding according to claim 2 is characterized in that: When a new node joins, the upper limit of the number of malicious nodes tolerated When the data of the coding block is unchanged, the data is re-encoded as follows: Send broadcast information through the new node to all original nodes to request each All blocks of the wheel; In response to the broadcast message sent by the new node, the block is returned through the original node; Use the new node to store the corresponding block, and send the corresponding block to the node storing the verification data block through the new node, send the block received by the new node to the target node that needs to exchange blocks through the new node, and send the block of the previous round to all nodes through the new node. The response signature of each node; In response to the information of the new node, the node storing the check data block updates the stored check data block of this round; The target node that needs to exchange blocks returns the replacement block and determines whether the broadcast message contains The node response signature of the previous round, if it contains it, it will sign and respond, if not, it will not respond; The historical blocks are cyclically re-encoded according to each encoding round of the block until all the data is processed; Node exit, the upper limit of the number of malicious nodes tolerated When the data of the coding block is unchanged, the data is re-encoded as follows: Send broadcast information through the node to be exited to all other nodes. All blocks of the wheel; In response to the broadcast message from the node to be exited, all other nodes send a response to the received block data; In response to the responses from all other nodes, a broadcast message is sent through the node to be exited, notifying the node storing the check block to calculate and process the original check block; Based on the received block data, the node storing the check block updates the original check block locally and broadcasts the new check block data hash.
6. A blockchain data reading method according to any one of claims 1 to 5, characterized in that: The following steps are involved: According to the data reading characteristics of the coding block, an optimized reading process based on local node download, node download and remote coding group block download is adopted for block reading.
7. The blockchain data reading method according to claim 6, characterized in that: The data reading characteristics of the coding block include uncoded cache, local storage or cross-node acquisition; The uncoded cached coded blocks are downloaded by the local node to complete the block reading; The locally stored coded blocks are downloaded from remote nodes to complete block reading; The coding blocks that need to be obtained across nodes are read by downloading blocks of the coding group in a different location.
8. The blockchain data reading method according to claim 7, characterized in that: The block reading is performed by optimizing the reading process according to the data reading characteristics of the coding block, specifically: Responding to the client's block Request to verify the height of the latest block and the block Is the height difference less than or equal to the current latest block index divided by If the remainder is For unencoded cached chunks, retrieve and return the chunk from the local cache ; If the height of the latest block is The height difference is greater than the current latest block index divided by The remainder of Does not belong to the latest block group to be encoded, using block The height of determines the current encoding round and calculates the block position in its coding round; Calculate and locate the actual storage block Node; If the block For locally stored blocks located on the local node, the block is retrieved and returned from the node state database ; If the block For blocks that need to be obtained across nodes, send The target node sends a request and starts the timer; If the target node does not respond before the timer expires, or due to network delays, the block If it fails to arrive in time, it will broadcast the request to the entire network, seeking to obtain the stored blocks from other nodes The remaining blocks of the encoding group.
Citation Information
Patent Citations
Block chain domain name resolution-oriented erasure code low-overhead storage system and method
CN114047878A
Deoxyribose nucleic acid (DNA) data storage method and reading method based on erasure code and assembly technology and terminal
CN116564424A