Blockchain system lightweight storage encoding method, decoding method and node device

Through the combination of RS encoding and Merkle tree, the problem of high and centralized blockchain storage costs is solved, low-cost and high-security blockchain storage and decoding is achieved, and the decentralization and robustness of the blockchain network is enhanced.

CN116233160BActive Publication Date: 2025-08-19ZHENGZHOU UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310260923.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-17
Publication Date
2025-08-19
Estimated Expiration
2043-03-17

AI Technical Summary

Technical Problem

The cost of existing blockchain technology is high to store and process data in devices or scenarios with limited resources. Lightweight blockchains may lead to centralization and security issues. The existing erasure coding technology has high computational complexity and network dependence on leader nodes is vulnerable to attack.

Method used

The block fragment is encoded by RS encoder, a code block is generated and a Merkle tree is constructed, the node stores the code block and deletes the block fragment, proves the validity of the codeword through Merkle, and uses encoding inverse operation to decode and restore the block. The node device includes a memory, an encoder and a decoder.

Benefits of technology

It greatly reduces node storage requirements, reduces storage costs, enhances network decentralization and security, and improves the robustness and scalability of blockchain networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116233160B_ABST
    Figure CN116233160B_ABST
Patent Text Reader

Abstract

The present invention provides an encoding method, a decoding method, and a node device for lightweight storage of a blockchain system. The encoding storage method uses a method in which, when storing an account book, a block is added to the account book and a code block generated by block encoding is stored; wherein, a Reed-Solomon encoder is used to encode the block fragment; then, a hash value of the codeword is calculated, a Merkle tree is constructed, and a Merkle proof is generated; finally, the codeword, the Merkle proof, and the block header of the block fragment corresponding to the codeword are packaged into a code block. In the decoding method, the node sends a decoding request to other nodes. When a code block is received from another node, the validity of the codeword of the code block is first verified, and then the codeword is placed in a codeword matrix. Finally, the inverse operation of the encoding is used to decode the codeword matrix to recover the block. The node device includes a memory used as a blockchain node repository, an encoder for executing the encoding storage method, and a decoder for executing the block decoding method.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of blockchain technology, and specifically relates to an encoding method, a decoding method, and a node device for lightweight storage of a blockchain system. Background Art

[0002] Blockchain, as an emerging technology, has garnered significant attention since its inception, with its application scope continuously expanding to encompass numerous fields, including finance, supply chain, and the Internet of Things. However, due to the inherent characteristics of blockchain technology, including decentralization, trustworthiness, and security, the cost of storing and processing data is high. This poses a significant challenge for resource-constrained devices or application scenarios, such as IoT devices and mobile devices. To address this issue, researchers have proposed various blockchain lightweighting technologies aimed at reducing the storage, computational, and network load of blockchain systems, thereby enabling wider application of blockchain technology in various scenarios.

[0003] Storage is a crucial issue in blockchain. In traditional blockchain systems, the decentralized nature of blockchains necessitates that all participants store historical transaction records to verify the legitimacy of transactions on the blockchain. This approach ensures blockchain security and decentralization, but it also leads to increasing storage requirements. In a blockchain, each block contains a certain amount of transaction information, and as transaction volume increases, so does the amount of data.

[0004] To address this issue, new technologies have been proposed, such as lightweight blockchains or sharding. A lightweight blockchain is designed to operate in resource-constrained environments. Unlike traditional blockchains, lightweight blockchains store transaction history elsewhere, rather than requiring every node to store the complete blockchain. This approach reduces storage requirements, but may sacrifice some security and decentralization.

[0005] Solution 1: Light Node Based on Simple Payment Verification

[0006] When Satoshi Nakamoto designed the blockchain, he proposed simplified payment verification, which led to the creation of a class of light nodes that require minimal storage space. Light nodes can participate in payment verification in blockchain systems without requiring full network nodes. Light nodes only need to store a copy of the block header of the longest proof-of-work chain, and then query other network nodes to confirm the longest chain and obtain the Merkle branch of the transaction timestamp block. Figure 1As shown, as long as a light node stores the block header, it can verify the inclusion of "Transaction 3" in the block using "Hash 01" and "Hash 2" provided by a full node. Although light nodes cannot verify transactions, this simplified payment verification method is reliable as long as the network is controlled by honest nodes. However, this method becomes vulnerable if the network is controlled by an attacker. To prevent attackers from deceiving light nodes, users can accept invalid block warnings from other network nodes and download the entire block and the warned transaction to check for consistency. Compared to full nodes, light nodes have the advantage of requiring less storage space. Light nodes only need to store a copy of the block headers of the longest proof-of-work chain, significantly saving storage space compared to full nodes, which must store the entire blockchain data.

[0007] Disadvantages: The widespread use of light nodes can lead to blockchain centralization. This is because the responsibility for verifying and maintaining the entire blockchain is concentrated in a small number of full nodes. These full nodes may become targets for attackers and regulatory oversight, threatening the decentralization and security of the blockchain.

[0008] Option 2: Blockchain Pruning

[0009] Blockchain pruning technology is a technology that effectively reduces node storage costs by deleting some blockchain data. In this technology, the root node of the Merkle tree is included in the hash value of the block, and the branches can be pruned by the nodes. As the blockchain continues to grow, more and more transaction data is stored in the nodes. If this data is not cleaned up, the storage cost will continue to increase. Therefore, blockchain pruning technology was introduced to reduce storage costs by deleting some old transaction data, while new transaction data is added to the latest block of the blockchain. Figure 2 As shown in Figure 2, in blockchain pruning, transaction data is hashed into a Merkle tree, with only the root node included in the block's hash. When the latest transaction for a particular currency is covered by enough blocks, the previous payment transactions can be deleted to save disk space. In this way, older blocks can be compressed by pruning branches, without having to save the hashes within the branches. This method does not affect the block's hash value and can significantly reduce storage space usage.

[0010] Disadvantages: If a piece of data is pruned by all nodes, then the data will be lost, which will damage the traceability of the blockchain. At the same time, this technology may also lead to centralization and security issues of the blockchain, because only a small number of nodes have complete blockchain data, while other nodes only have partial data.

[0011] Option 3: Permissioned Blockchain Storage Partitioning via Erasure Coding

[0012] Researchers from East China Normal University designed a Byzantine fault-tolerant storage engine called BFT-Store for permissioned blockchain systems. Figure 3 As shown. The engine uses erasure coding technology to reduce the storage complexity of each block from O(n) to O(1), which helps to improve the storage capacity of the entire system. Specifically, the design of BFT-Store combines erasure coding and Byzantine fault-tolerant consensus protocol, thereby improving the scalability of storage and making the system more suitable for processing large amounts of data. In addition, in order to reduce the overhead of node decoding in a Byzantine environment, BFT-Store also uses threshold signature technology. This technology can ensure the integrity and security of data by checking the codewords generated by block encoding. Finally, BFT-Store also has a 4-phase re-encoding protocol that can help the system handle the addition and deletion of nodes. In general, BFT-Store is a powerful, efficient and reliable storage engine that can play an important role in permissioned blockchain systems.

[0013] Disadvantages: BFT-Store has a high computational complexity, and the network operation depends on the leader node. Once the leader node is attacked or acts maliciously, the system may be destroyed. Summary of the Invention

[0014] The purpose of the present invention is to address the deficiencies of the existing technology and provide an encoding method, a decoding method and a node device for lightweight storage of a blockchain system.

[0015] In order to achieve the above object, the technical solution adopted by the present invention is:

[0016] The first aspect of the present invention provides a blockchain lightweight storage encoding method, the method comprising:

[0017] When a block is added to the ledger, the node stores the code block generated by the block encoding.

[0018] Method for generating code blocks by block coding:

[0019] Check the length of the block; if the block length meets the requirements, split the block into k equal-length block fragments; otherwise, pad the block to meet the requirements and then split the block into k equal-length block fragments; where 1<k≤n, n is the number of nodes in the blockchain;

[0020] Use the RS encoder to encode the block fragment to generate a set of n codewords; calculate the hash value of the n codewords, and construct a Merkle tree accordingly, and generate a Merkle proof at the same time;

[0021] Pack a codeword, its Merkle proof, and the header of the corresponding block fragment into a codeblock.

[0022] How nodes store code blocks:

[0023] The node stores a code block generated by encoding and deletes the corresponding block fragment.

[0024] Based on the above, each node in the blockchain has a unique ID; when storing code blocks, each node selects code blocks to store based on its ID.

[0025] Based on the above, the method of encoding the block fragment using the RS encoder is as follows:

[0026] The RS encoder predetermines a (n, k) coding pattern;

[0027] The data in the block fragment is split and converted into elements in the Galois field GF(256). The split and converted data is represented by the matrix B:

[0028]

[0029] Then use the encoding matrix M whose first k rows are the identity matrix converted from the Vandermonde matrix to encode the matrix B to obtain the codeword matrix U;

[0030]

[0031] The codeword matrix U serves as a codeword set.

[0032] A second aspect of the present invention provides a verifiable block decoding method for decoding code blocks stored by the blockchain lightweight storage encoding method;

[0033] The block decoding method comprises the following steps:

[0034] The node obtains the codeword and the Merkle proof of the codeword from its locally stored code block, and calculates the root of the Merkle tree based on the codeword and the Merkle proof.

[0035] Each node maintains a codeword matrix and adds codewords to the matrix;

[0036] The node sends a decoding request to other nodes to obtain the missing code blocks. After receiving the decoding request from the node, the other nodes send their stored code blocks to the node.

[0037] When this node receives a code block from another node, it verifies whether the codeword of the code block is valid by checking the Merkle proof of the received code block; if the codeword passes the verification, it puts it into the codeword matrix, otherwise it continues to receive code blocks;

[0038] When the size of the codeword matrix maintained by the node reaches k, the node uses the inverse operation of the encoding to decode and recover the block fragment;

[0039] The node stitches together the data in the data matrix of the recovered block fragments in sequence to obtain the padded block, then removes the padding data from the end of the padded block to obtain the decoded block and returns it.

[0040] A third aspect of the present invention provides a blockchain node device, comprising a communication interface, a memory, an encoder, a decoder, and a communication bus, wherein the communication interface, the encoder, the decoder, and the memory communicate with each other via the communication bus;

[0041] Storage, used as a repository for blockchain nodes;

[0042] An encoder for storing computer programs and for implementing the aforementioned blockchain lightweight storage encoding method when executing the stored programs;

[0043] The decoder is used to store computer programs and is also used to implement the verifiable block decoding method when executing the stored programs.

[0044] The fourth aspect of the present invention provides a blockchain network system, which is a blockchain network system composed of the blockchain node devices connected through a network.

[0045] The present invention has outstanding substantive features and significant improvements over the prior art. Specifically:

[0046] By storing code blocks generated by block encoding, the present invention greatly reduces the amount of data that nodes need to store and reduces the storage cost of nodes, thereby promoting more nodes to join the blockchain network and enhancing the decentralization and security of the network. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] Figure 1 A schematic diagram of simplified payment verification is shown.

[0048] Figure 2 A schematic diagram of blockchain pruning is shown.

[0049] Figure 3 The BFT-Store system architecture diagram is shown.

[0050] Figure 4 The block diagram shows the principle of the blockchain network system of the present invention.

[0051] Figure 5 The encoding storage flow chart of the present invention is shown.

[0052] Figure 6 The flowchart of the check decoding of the present invention is shown. DETAILED DESCRIPTION

[0053] The technical solution of the present invention is further described in detail below through specific implementation methods.

[0054] Example 1

[0055] like Figure 4 and 5 As shown, this embodiment provides a coding method for lightweight storage of blockchain, wherein when a node stores an account book, after a block is added to the account book, a code block generated by block coding is stored.

[0056] The specific method is:

[0057] Step 1: Check the length of the block. If the block length meets the requirements, divide the block into k equal-length block fragments. Otherwise, pad the block to meet the requirements and then divide the block into k equal-length block fragments. Where 1<k≤n, n is the number of nodes in the blockchain.

[0058] Step 2: Use the RS encoder to encode the block fragment to generate a set of n codewords;

[0059] The method of encoding a block segment using the RS encoder is:

[0060] The RS encoder predetermines a (n, k) coding pattern;

[0061] The data in the block fragments are split and converted into elements in the Galois field GF(256), so that the encoding operation can be performed in a finite field and the amount of data before and after encoding is kept consistent. The split and converted data is represented by the matrix B:

[0062]

[0063] Then use the encoding matrix M whose first k rows are the identity matrix converted from the Vandermonde matrix to encode the matrix B to obtain the codeword matrix U;

[0064]

[0065] The codeword matrix U serves as a codeword set.

[0066] Step 3: Calculate the hash values of the n codewords, construct the Merkle tree accordingly, and generate the Merkle proof.

[0067] Step 4: Package a codeword, the Merkle proof of the codeword, and the block header of the block fragment corresponding to the codeword into a code block.

[0068] Step 5: The node stores a block and deletes the corresponding block fragment. Each node in the blockchain has a unique ID; when storing a block, each node selects a block to store based on its ID.

[0069] The ledger structure and block addition process of this embodiment are similar to those of traditional blockchains. However, unlike traditional blockchains, the nodes in this embodiment do not store the complete ledger, but instead store the code blocks generated by block encoding. In proposed blockchain encoding storage systems, when a block is added to the ledger, it is encoded by the nodes to generate multiple codewords, with each node storing a portion of the codewords. However, the nodes in this embodiment do not store the codewords directly. Instead, they construct a Merkle tree to store the selected codeword, the Merkle proof of the codeword, the hash value of the codeblock, and the block header of the block fragment corresponding to the codeword, and then package them into a codeblock for storage.

[0070] In this embodiment, the number of nodes is represented by n, and each node has a unique ID. When a node needs to recover a block, it needs to obtain a certain number of different code blocks, which is assumed to be k, 1<k≤n. If the number of different code blocks obtained is less than k, the recovery of the block will fail. Therefore, in order to increase the probability of block recovery, the node should store different code blocks. In this embodiment, the number of code blocks generated by encoding is equal to the number of nodes n, and the node selects the code block for storage based on its ID. After each block is encoded, n code blocks are generated, and the tth code block of each block is stored by the tth node, 0<t<n-1. In this way, each node can store different code blocks and avoid excessive encoding calculation costs.

[0071] In the present invention, nodes store code blocks generated by encoding instead of blocks, which can achieve lower storage costs as long as the amount of data in the code blocks is less than the amount of data in the blocks;

[0072] Assuming the amount of data in a block is q, it is divided into k fragments with a data size of ⌈q / k⌉ during encoding. The k fragments then generate n codewords with a data size of ⌈q / k⌉ through matrix operations. Assuming the amount of data for each hash value in the Merkle tree is p, and the amount of data for the corresponding block header is r, the data size of the code block can be calculated as , so only In practical applications, this is easy to achieve. Referring to the data of a certain digital currency system, the block size is about 1MB, of which the block header is about 80B and the hash value is 32B, that is, q=1MB, r=80B, p=32B, where M=2 20 , we can see that the size of the code block is approximately:

[0073]

[0074] In a system with n=100, we can set k=50, and the size of the code block is about 20.5KB, where K=2 10 The optimized storage cost is approximately 1 / 50 of the original cost. In a certain digital currency system, n is approximately 15,000. If k is set to 1024, the code block size is calculated to be approximately 1.5KB. The optimized storage cost is approximately 0.15% of the original cost, a decrease of three orders of magnitude.

[0075] It has been verified that if the encoding storage optimization technology of the present invention is adopted for a certain digital currency system, the storage space can be reduced by up to three orders of magnitude, that is, the total storage capacity can be reduced to several TB, and the storage space of a single node will also be reduced to no more than 1 GB.

[0076] Example 2

[0077] This embodiment provides a verifiable block decoding method, which is used to decode code blocks stored by the blockchain lightweight storage encoding method described in Example 1.

[0078] In a network where Byzantine nodes may exist, the obtained codewords need to be verified before decoding. Specifically, the Merkle proof of each codeword is checked. That is, the node obtains the codeword in its locally stored code block and the Merkle proof of the codeword, and calculates the root of the Merkle tree based on the codeword and the Merkle proof.

[0079] During the decoding process, each node maintains a codeword matrix and adds the codeword to the matrix.

[0080] The specific process of decoding:

[0081] Step 1: The node sends a decoding request to other nodes to obtain the missing code blocks. After receiving the decoding request from the node, the other nodes send their stored code blocks to the node.

[0082] Step 2: When the node receives a code block from another node, it verifies whether the codeword of the received code block is valid; if the codeword passes the verification, it puts it into the codeword matrix; otherwise, it continues to receive the code block;

[0083] Step 3: When the size of the codeword matrix maintained by the node reaches k, the node attempts to decode using the inverse operation of the encoding;

[0084] Step 4: If the decoding is successful, the node will sequentially concatenate the data in the data matrix of the decoded and recovered block to obtain the padded block, and then remove the padding data from the end of the padded block to obtain the decoded block and return it as a successful decoding result; if the decoding is unsuccessful, the decoding process ends directly.

[0085] The specific implementation method of using the inverse operation of encoding to try to decode is:

[0086] The decoder uses the same (n, k) pattern as the encoder when decoding. Assume that the k data received by the decoder is the matrix V:

[0087]

[0088] The decoder then needs to select k rows corresponding to the data numbers in V from the encoding matrix M to form a decoding matrix N. Then, according to the properties of matrix operations, the inverse matrix of the decoding matrix N is used to decode the matrix V to obtain the block matrix B.

[0089]

[0090] Example 3

[0091] This embodiment provides a blockchain node device, including a communication interface, a memory, an encoder, a decoder, and a communication bus, wherein the communication interface, the encoder, the decoder, and the memory communicate with each other via the communication bus;

[0092] Storage, used as a repository for blockchain nodes;

[0093] An encoder for storing computer programs and for implementing the encoding method for lightweight blockchain storage as described in Example 1 when executing the stored programs;

[0094] The decoder is used to store a computer program and is also used to implement the verifiable block decoding method as described in Example 2 when executing the stored program.

[0095] Example 4

[0096] This embodiment provides a blockchain network system, which is a blockchain network system composed of the blockchain node devices described in Example 3 connected through a network.

[0097] In order for the blockchain network system to operate normally, the nodes must act as encoders, storage devices, and decoders. In an embodiment, each node device is a storage device, and at the same time, they also act as encoders and decoders to encode and decode blocks during the encoding and decoding stages.

[0098] The blockchain network system of this embodiment has the following advantages:

[0099] Coding function: RS code is used to encode blocks. To ensure the reliability of the coding results, a distributed coding scheme is developed. At the same time, the encoders are required to agree on a unified coding mode to ensure the universality of the codewords generated by different encoders.

[0100] Decoding function: It realizes the decoding process of the codeword data that is unreadable after block encoding. Through the inverse operation of the matrix, the block operations during encoding are gradually eliminated, thereby recovering the original data before block encoding;

[0101] Verification function: It enables fast verification of unreadable codeword data. Through the properties of the Merkle tree, a Merkle proof of the codeword is generated during encoding, allowing nodes to quickly verify the correctness of the codeword data sent by other nodes.

[0102] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Thus, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product implemented on one or more non-transitory computer-readable storage media (including but not limited to magnetic disk storage, CD-ROMs, optical storage, etc.) containing computer program code.

[0103] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowcharts and / or block diagrams, as well as combinations of processes and / or blocks in the flowcharts and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowcharts and / or block diagrams. Figure 1 a process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0104] These computer program instructions may also be stored in a computer readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 a process or multiple processes and / or boxes Figure 1 The function specified in one or more boxes.

[0105] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operational steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing the instructions executed on the computer or other programmable device for implementing the process. Figure 1 a process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0106] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit it. Although the present invention has been described in detail with reference to the preferred embodiments, ordinary technicians in the field should understand that the specific implementation methods of the present invention can still be modified or some technical features can be replaced by equivalents without departing from the spirit of the technical solutions of the present invention. They should all be included in the scope of the technical solutions for which protection is requested by the present invention.

Claims

1. A blockchain lightweight storage encoding method, characterized in that: The method is: When a block is added to the ledger, the node stores the code block generated by the block encoding. Method for generating code blocks by block coding: Check the length of the block; if the block length meets the requirements, split the block into k equal-length fragments; otherwise, pad the block to meet the requirements and then split the block into k equal-length fragments; where 1<k≤n, n is the number of nodes in the blockchain; Use the RS encoder to encode the block fragment to generate a set of n codewords; calculate the hash value of the n codewords, and construct a Merkle tree accordingly, and generate a Merkle proof at the same time; Pack a codeword, its Merkle proof, and the header of the corresponding block fragment into a codeblock. How nodes store code blocks: The node stores a code block generated by encoding and deletes the corresponding block fragment.

2. The blockchain lightweight storage encoding method according to claim 1 is characterized in that: Each node in the blockchain has a unique ID; when storing code blocks, each node selects code blocks to store based on its ID.

3. The encoding method for lightweight storage of blockchain according to claim 1 is characterized in that: The method of encoding a block segment using the RS encoder is: The RS encoder predetermines a (n, k) coding pattern; The data in the block fragment is split and converted into elements in the Galois field GF(256). The split and converted data is represented by the matrix B: Then use the encoding matrix M whose first k rows are the identity matrix converted from the Vandermonde matrix to encode the matrix B to obtain the codeword matrix U; The codeword matrix U serves as a codeword set.

4. A verifiable block decoding method, characterized by: The block decoding method is used to decode the code block stored by the blockchain lightweight storage encoding method according to claim 1 or 2; The block decoding method comprises the following steps: The node obtains the codeword and the Merkle proof of the codeword from its locally stored code block, and calculates the root of the Merkle tree based on the codeword and the Merkle proof. Each node maintains a codeword matrix and adds codewords to the matrix; The node sends a decoding request to other nodes to obtain the missing code blocks. After receiving the decoding request from the node, the other nodes send their stored code blocks to the node. When this node receives a code block from another node, it verifies whether the codeword of the code block is valid by checking the Merkle proof of the received code block; if the codeword passes the verification, it puts it into the codeword matrix, otherwise it continues to receive code blocks; When the size of the codeword matrix maintained by the node reaches k, the node uses the inverse operation of the encoding to decode and recover the block fragment; The node stitches together the data in the data matrix of the recovered block fragments in sequence to obtain the padded block, then removes the padding data from the end of the padded block to obtain the decoded block and returns it.

5. A blockchain node device, characterized by: It includes a communication interface, a memory, an encoder, a decoder and a communication bus, wherein the communication interface, the encoder, the decoder and the memory communicate with each other via the communication bus; Storage, used as a repository for blockchain nodes; An encoder for storing a computer program and for implementing the encoding method for lightweight blockchain storage as described in any one of claims 1 to 3 when executing the stored program; The decoder is used to store a computer program and is further used to implement the verifiable block decoding method according to claim 4 when executing the stored program.

6. A blockchain network system, characterized by: The blockchain network system is a blockchain network system composed of the blockchain node devices described in claim 5 connected through a network.

Citation Information

Patent Citations

  • Blockchain data based on error correcting code storage and sharing

    CN111095218A

  • Blockchain data storage based on error correction code

    CN113826354A