Block clipping method and system based on block activeness
A predictive block pruning method for UTXO model blockchains identifies inactive blocks for targeted removal, addressing storage challenges and maintaining decentralization by selectively pruning block bodies and updating database tables, enhancing storage efficiency and scalability.
Patent Information
- Application Number
- CN202411083432.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-08
- Publication Date
- 2024-12-13
AI Technical Summary
The increasing storage requirements of blockchain systems, particularly in UTXO model blockchains like Bitcoin, pose significant challenges due to scalability issues and decentralization threats, as full nodes are overwhelmed by the need to maintain large storage capacities, leading to many users opting for less functional SPV nodes.
A method and system for block pruning based on block activity, utilizing a predictive model to identify inactive blocks by analyzing UTXO set transaction data, allowing for selective pruning of block bodies while retaining headers and high-value transactions, and updating database tables to ensure efficient storage utilization.
This approach effectively reduces storage needs by selectively pruning inactive blocks, maintaining system functionality and decentralization, while supporting real-time pruning without relying on trust assumptions, thus enhancing storage efficiency and scalability.
Smart Images

Figure CN119127870A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain, and in particular to blockchain storage saving technology. Background Art
[0002] Blockchain is a scalable and secure Internet distributed ledger technology. It can safely store Bitcoin transactions or other information, and can also automatically execute smart contracts. The information on the blockchain cannot be forged or altered. The development prospects of blockchain technology have an inestimable role in copyright protection, the Internet of Things, medical care, social networking, etc.
[0003] Bitcoin is one of the most mainstream UTXO model blockchains. Unlike the account model blockchain, the UTXO model blockchain transaction part consists of two parts: input and output. When trading, the transaction input used for payment is found from each block, and then the corresponding transaction output is calculated, and then the output is stored on the blockchain. Bitcoin stores a UTXO set in the database in the memory and disk of each node, which stores the status related to the output in the transaction and the related scripts for locking the information of the transaction. At present, the cumulative size of Bitcoin blocks has exceeded 464GB, and the growth rate of Bitcoin blocks is still increasing, which has brought tremendous pressure on ordinary users to download and store the complete Bitcoin ledger.
[0004] The increasing storage of blockchain is bound to bring great adverse effects. First of all, the huge storage pressure will affect the scalability of blockchain. Nowadays, many industries are popularizing the use of blockchain. If a new user needs the entire blockchain, he must have a device that can load 400GB of storage to join the blockchain. This greatly restricts the device that users can use to join the blockchain, and may also cause users to give up the blockchain because they cannot have this storage-level device. Secondly, there are SPV nodes and full nodes in the Bitcoin network. Excessive storage pressure will cause many nodes to choose to become SPV nodes instead of becoming full nodes. This will easily lead to a situation in which a full node is responsible for a large number of SPV nodes in the network. This not only increases the communication pressure on the full node, but also violates the decentralization of the blockchain. How to reduce the storage pressure of the blockchain is already an imminent issue.
[0005] To solve the storage pressure problem, Bitcoin Core developer James O'Beirne proposed a new way to run Bitcoin pruned nodes. A full node is a computer or custom machine that verifies whether a proposed Bitcoin transaction violates consensus, such as double spending or increasing the number of coins beyond the Bitcoin hard cap of 21 million. Full nodes verify transactions according to the Bitcoin rule set and a complete copy of the Bitcoin transaction ledger. Pruned nodes greatly reduce the amount of hard drive space required to verify incoming transactions. Pruning the blockchain makes it easy to download and store the blockchain. But simply pruning the blockchain will also bring a series of problems when it reduces storage space.
[0006] The patent document with publication number WO2020078594A1 discloses a method for pruning a blockchain of a blockchain network, including creating an active block commitment Merkle tree from the hash of the active block and creating an active smart contract commitment Merkle tree from the hash of the active smart contract, the Merkle tree is created after the number of blocks created in the blockchain reaches the threshold set by the pruning threshold parameter stored in the blockchain network, so as to allow pruning based on the threshold set by the pruning threshold parameter. This method improves the efficiency and security of the blockchain network by reducing the amount of data required to store the blockchain and ensuring the integrity of the nodes. However, this technical solution only compresses the data to facilitate the maintenance of a complete copy of the blockchain, and the storage space saved and the efficiency will be lower than the block pruning technology of deleting blocks. Moreover, this method must prune an entire blockchain at a time to prune the blockchain, and the pruning process depends on the block creator. Summary of the invention
[0007] The technical problem to be solved by the present invention is how to enable the blockchain system to efficiently prune the blockchain as much as possible without affecting other functions, thereby further improving and saving storage space.
[0008] The present invention solves the above technical problems through the following technical means: a method for performing block pruning based on block activity, comprising the following steps:
[0009] Step 1: Build a model that can predict the block activity threshold. By collecting and analyzing the UTXO set transaction data over the years, build a model that can predict the threshold of unspent outputs when the block is inactive based on the total number of unspent outputs in the block.
[0010] Step 2: When a new block is generated in the blockchain, the UTXO set generated by the new block is mapped to a bit vector set stored in the memory, and the UTXO set is traversed to obtain the total number of unspent outputs of the block. The total number is used as input to the model for predicting block activity constructed in step 1 to obtain the output of the model, that is, the activity threshold of each block, and the threshold is associated with the bit vector set;
[0011] Step 3: When a new transaction verification is generated, determine whether the block's unspent output is equal to or less than the active output according to the input source block height corresponding to the transaction-related input. If so, traverse the bit vector set to find the remaining unspent output number of the block, and determine whether it is less than the associated threshold. If it is less than the threshold, it means that the block has entered an inactive state. The inactive block is pruned after the transaction is completed, and the bit vector corresponding to the block is updated to 0; if not, only the bit vector corresponding to the block is updated;
[0012] Step 4: Prune blocks, delete the block body of inactive blocks, and only keep the block header of the block on the blockchain. At the same time, traverse the transactions in the pruned block body, and store the transactions that are still unspent and have relatively high value in the block body into the local database for preservation.
[0013] Furthermore, before the model of step 1 is established, the activity threshold of the blockchain is first defined: when a block has a sufficient block height and the number of unused transactions in the UTXO set does not change for a long period of time, the block is considered to be inactive. The number of unused transactions in the block at this time is considered to be the activity threshold of the block. When the current number of unused transactions in the block is equal to or less than the activity threshold of the block, the block is considered to be inactive.
[0014] Furthermore, the model building process in step 1 is as follows:
[0015] (1) First, we assume that there is a linear relationship between the total number of transaction outputs of a single block and the threshold of block inactivity. The goal of this model is to predict the inactivity threshold corresponding to blocks with different numbers of transactions. Let the total number of transaction outputs of a single block be x, and the transaction output that is still unspent when inactive be y. Assume that there is a linear relationship between y and x.
[0016] (2) Then data collection and data preprocessing are carried out;
[0017] (3) Then select the linear regression model, expressed as: y = θ0 + θ1 * x + ε. Where θ0 is the intercept, θ1 is the coefficient of the total number of block transaction outputs, and ε is the error term;
[0018] (4) Next is model fitting: the collected samples are fitted with a linear regression model, and the loss function is J(θ) = ∑(y(i)-Linearθ(x(i)))2, where J(θ) represents the residual, y(i) is the actual activity threshold corresponding to the i-th sample data, and Linearθ(x(i)) is the activity threshold calculated by the fitting model for the i-th sample data. The entire formula represents the sum of squares of the residuals;
[0019] (5) Finally, evaluate the model: Draw a scatter plot and a fitted straight line to visually view the model's fitting effect.
[0020] Furthermore, in step 4, there should be three types of nodes in the pruned blockchain network: pruned nodes, full nodes, and SPV nodes. Pruned nodes are nodes that have pruned inactive blocks, full nodes are nodes that have all block data, and SPV nodes are nodes that have block headers but no block bodies.
[0021] Furthermore, the method for block pruning based on block activity also includes step 5: updating the database table. After each update of the database table, the updated database table is broadcast to the attached SPV node. When the SPV node requests complete information related to a transaction, it is marked in the Bloom filter by judging whether the block height to which the transaction belongs is within the pruning block height. This mark will tell other nodes whether this block transaction should be processed by a full node or by any node.
[0022] The present invention also provides a system for performing block pruning based on block activity, comprising the following modules:
[0023] The model building module is used to build a model that can predict the threshold of block activity. By collecting and analyzing the transaction data of the UTXO set over the years, a model is established that can predict the threshold of unspent outputs when the block is inactive based on the total number of unspent outputs in the block.
[0024] A new block generation module is used to perform the following operations: when a new block is generated in the blockchain, the UTXO set generated by the new block is mapped to a bit vector set stored in the memory, and the UTXO set is traversed to obtain the total number of unspent outputs of the block, and the total number is taken as input into the model for predicting block activity constructed in step 1, and the output of the model, that is, the activity threshold of each block, is obtained, and the threshold is associated with the bit vector set;
[0025] A new transaction verification generation module is used to perform the following operations: when a new transaction verification is generated, based on the input source block height corresponding to the transaction-related input, determine whether the block's unspent output is equal to or less than the active one. If so, traverse the bit vector set to find the number of remaining unspent outputs of the block, and determine whether it is less than the associated threshold compared to the threshold. If it is less than the threshold, it means that the block has entered an inactive state. The inactive block is pruned after the transaction is completed, and the bit vector corresponding to the block is updated to 0; if not, only the bit vector corresponding to the block is updated;
[0026] The block pruning module is used to prune blocks, delete the block body of inactive blocks, and only keep the block header of the block on the blockchain. At the same time, it traverses the transactions in the pruned block body and stores the transactions that are still unspent and have relatively high value in the block body into the local database for preservation.
[0027] Furthermore, in the model building module, the activity threshold of the blockchain is first defined: when a block has reached a sufficient block height and the number of unused transactions in the UTXO set has not changed for a long period of time, the block is considered to be inactive. At this time, the number of unused transactions in the block is considered to be the activity threshold of the block. When the current number of unused transactions in the block is equal to or less than the activity threshold of the block, the block is considered to be inactive.
[0028] Furthermore, in the model building module, the model building process is as follows:
[0029] (1) First, we assume that there is a linear relationship between the total number of transaction outputs of a single block and the threshold of block inactivity. The goal of this model is to predict the inactivity threshold corresponding to blocks with different numbers of transactions. Let the total number of transaction outputs of a single block be x, and the transaction output that is still unspent when inactive be y. Assume that there is a linear relationship between y and x.
[0030] (2) Then data collection and data preprocessing are carried out;
[0031] (3) Then select the linear regression model, expressed as: y = θ0 + θ1 * x + ε. Where θ0 is the intercept, θ1 is the coefficient of the total number of block transaction outputs, and ε is the error term;
[0032] (4) Next is model fitting: the collected samples are fitted with a linear regression model, and the loss function is J(θ) = ∑(y(i)-Linearθ(x(i)))2, where J(θ) represents the residual, y(i) is the actual activity threshold corresponding to the i-th sample data, and Linearθ(x(i)) is the activity threshold calculated by the fitting model for the i-th sample data. The entire formula represents the sum of squares of the residuals;
[0033] (5) Finally, evaluate the model: Draw a scatter plot and a fitted straight line to visually view the model's fitting effect.
[0034] Furthermore, in the block pruning module, there should be three types of nodes in the pruned blockchain network: pruned nodes, full nodes, and spv nodes. Pruned nodes are nodes that have pruned inactive blocks, full nodes are nodes that have all block data, and spv nodes are nodes that have the block header of the block but do not have the block body of the block.
[0035] Furthermore, the system for performing block pruning based on block activity also includes a database table update module, which is used to perform the following operations: after each update of the database table, the updated database table is broadcast to the attached SPV nodes. When the SPV node requests complete information related to a transaction, it is marked in the Bloom filter by judging whether the block height to which the transaction belongs is within the pruning block height. This mark will tell other nodes whether this block transaction should be processed by a full node or by any node.
[0036] The advantages of the present invention are:
[0037] 1. The present invention and the prior art have different definitions of active blocks:
[0038] The existing technology defines block activity as follows: if a block has at least one transaction with a UTXO, and an active smart contract commitment Merkle tree is created based on the hash value of the active smart contract, then the block is active;
[0039] The present invention defines block activity as follows: if the unspent output (UTXO) of a block is always used, it means that the block is always accessed, and the block is active; if the unspent output of a block has not been used for a long time, it means that the block has not been accessed for a long time, and the block is inactive. By defining block activity in this way, it is possible to better label blocks with low access frequency in the blockchain, and to facilitate the screening of blocks that need to be pruned, thus solving the disadvantage that the pruning process of the comparative solution needs to rely on the block creator.
[0040] 2. The criteria for determining whether a block needs to be cropped are different:
[0041] The prior art determines whether a block is pruned mainly by referring to the number of created blocks becoming greater than or equal to a pruning threshold parameter representing a network pruning threshold.
[0042] The present invention determines whether a block is pruned mainly by referring to whether the current number of UTXOs of each block is equal to or less than the block activity threshold. The pruning standard of the present invention is predicted by the model. The comparative invention needs to first count the number of blocks created in the network, which takes a certain amount of time, while the model prediction only needs to train the model in advance. With the help of the model prediction, the blocks that need to be pruned can be found in time, and additional threads can be opened separately to prune the blocks during the block activity, without the need to wait for the entire blockchain activity to end before pruning as in the comparative solution.
[0043] 3. The working principle of pruning blocks is different:
[0044] The working principle of the existing technology of pruning blocks: 1) The pruning threshold parameter defines how many blocks are retained in the local copy after pruning. 2) Each node can decide how to operate on its local copy of the blockchain. The existing technology can use modern compression algorithms (such as GZIP) to compress the data of the blocks that can be pruned according to the pruning threshold parameter, or apply deduplication technology (such as block-based or Rabin-based deduplication). The existing technology prunes blocks at a time to prune an entire blockchain.
[0045] The working principle of the file pruning block of the present invention is: by collecting the UTXO set information of previous years, a model is established to predict the activity threshold of each block, and the block itself is deleted when the number of unspent transactions in each block is less than or equal to the activity threshold. When deleting, all nodes except the full node only retain the information of the block header and remove the entire block body. When removing the block body information, the block information will be screened again, and valid transactions with transaction procedures not exceeding 1 / 3 of the transaction value will be selected, and these transactions will be saved in the local database. The solution in this article prunes each block separately, and there is no need to prune all blocks at once. The block pruning principle of the present invention determines whether each block needs to be pruned individually, and the block pruning process is also targeted at a single block itself, and does not need to rely on the block creator to prune. Therefore, this solution supports pruning an entire blockchain or a single block at a time. Compared with the comparative invention that can only prune an entire blockchain at a time, it is more flexible and solves the disadvantage that the comparative solution must prune an entire blockchain at a time. In addition, the pruning principle of this article is to prune the entire block body instead of compressing the data. The present invention is more efficient in saving storage space. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Figure 1 It is a flow chart of a model for predicting a block activity threshold in an embodiment of the present invention;
[0047] Figure 2 is a flow chart of obtaining an activity threshold value of a new block in an embodiment of the present invention;
[0048] Figure 3 is a flowchart of block clipping in an embodiment of the present invention;
[0049] Figure 4 It is a schematic diagram of the blockchain network structure after cutting in an embodiment of the present invention;
[0050] Figure 5 is a schematic diagram of a blockchain after being cut out in an embodiment of the present invention;
[0051] Figure 6 This is a flow chart of SPV node message propagation in an embodiment of the present invention. DETAILED DESCRIPTION
[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in combination with the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0053] The present invention proposes a new blockchain pruning method based on the UTXO (Unspent Transaction Output) model blockchain, analyzes the application scenarios of the current blockchain, combines actual needs, proposes the inactivity of blocks, and establishes a model to predict the inactivity of blocks. It proposes a strategy that can meet the increasing blockchain storage pressure by pruning inactive blocks to solve the storage problem, and does the corresponding post-pruning work, improves the block network structure after pruning, and ensures the security of the block network and the integrity query function of the blockchain. The specific implementation steps are as follows:
[0054] Step 1: Build a model that can predict the block activity threshold.
[0055] See also Figure 1 , this step builds a model that can predict the block activity threshold. First, the activity threshold of the blockchain is defined: when a block has a sufficient block height and the number of unused transactions in the UTXO set does not change for a long period of time, the block is considered to be inactive. The number of unused transactions in the block at this time is considered to be the activity threshold of the block. When the current number of unused transactions in the block is equal to or less than the activity threshold of the block, the block can be considered inactive. By collecting and analyzing the UTXO set transaction data over the years, a model is established that can predict the threshold of unspent outputs when the block is inactive based on the total number of unspent outputs of the block. The model building process is as follows:
[0056] (1) First, we assume that there is a linear relationship between the total number of transaction outputs of a single block and the threshold of the block’s inactivity (the number of transaction outputs that are still unspent when inactive). The goal of this model is to predict the inactivity threshold corresponding to blocks with different numbers of transactions. Here, let the total number of transaction outputs of a single block be x, and the number of transaction outputs that are still unspent when inactive be y. We assume that there is a linear relationship between y and x.
[0057] (2) Then data collection and data preprocessing are carried out;
[0058] (3) Then select the linear regression model, expressed as: y = θ0 + θ1 * x + ε. Where θ0 is the intercept, θ1 is the coefficient of the total number of block transaction outputs, and ε is the error term;
[0059] (4) Next is model fitting: fit the collected samples to a linear regression model. The loss function should be J(θ) = ∑(y(i)-Linearθ(x(i)))2, where J(θ) represents the residual, y(i) is the actual activity threshold corresponding to the i-th sample data, and Linearθ(x(i)) is the activity threshold calculated by the fitting model for the i-th sample data. The entire formula represents the sum of squares of the residuals.
[0060] (5) Finally, evaluate the model: Draw a scatter plot and a fitted line to visually view the model's fitting effect;
[0061] Step 2: See Figure 2 , when a new block is generated in the blockchain, the UTXO set generated by the new block is mapped to a bit vector set stored in the memory, and the UTXO set is traversed to obtain the total number of unspent outputs of the block, and the total number is taken as input into the model for predicting block activity constructed in step 1, and the output of the model, that is, the activity threshold of each block, is obtained, and the threshold is associated with the bit vector set;
[0062] Step 3: Read Figure 3 When a new transaction verification is generated, the block unspent output is determined to be equal to or less than the active output according to the input source block height corresponding to the transaction-related input. If so, the remaining unspent output of the block is traversed in the bit vector set to determine whether it is less than the associated threshold. If it is less than the threshold, it means that the block has entered an inactive state. The inactive block is pruned after the transaction is completed, and the bit vector corresponding to the block is updated to 0; if not, only the bit vector corresponding to the block is updated.
[0063] Step 4: Continue reading Figure 3, prune the blocks, delete the block bodies of inactive blocks, and only keep the block headers of the blocks on the blockchain. At the same time, traverse the transactions in the pruned block bodies, and store the transactions that are still unspent and have relatively high value in the block bodies into the local database for preservation. The structure of the blockchain after pruning is as follows: Figure 5 There should be three types of nodes in the pruned blockchain network: pruned nodes, full nodes, and SPV nodes. Pruned nodes are nodes that have pruned inactive blocks, full nodes are nodes that have all block data, and SPV nodes are nodes that have block headers but no block bodies. The network structure of the blockchain is as follows: Figure 4 shown.
[0064] Step 5: Update the database table that the pruning node has established locally to store the pruning block height. Each time the database table is updated, the updated database table is broadcast to the attached SPV nodes. When the SPV node requests complete information about a transaction, it determines whether the block height to which the transaction belongs is within the pruning block height and marks it in the Bloom filter. This mark tells other nodes whether the block transaction should be processed by a full node or can be processed by any node, such as Figure 6 shown.
[0065] Compared with the existing blockchain pruning scheme, the present invention has its own unique advantages. Some existing blockchain pruning schemes only retain the data that they are concerned about, and lack complete query rules. Compared with them, the present invention has complete query rules, or the existing blockchain pruning scheme needs to rely on the security trust assumption of the block creator to complete the screening of the pruning block. The present invention does not need to rely on any security trust assumption and can be directly transplanted on the current UTXO type blockchain. Therefore, the present invention realizes a blockchain pruning method that can support complete queries, does not rely on trust assumptions, and supports real-time pruning on the basis of ensuring high storage performance. The main innovation is that the inactivity of the block is proposed based on the transaction changes of the UTXO set of the blockchain over the years, and then based on the inactivity of the block, a model is established for predictive analysis, so as to obtain a storage saving scheme that can prune the block according to the inactivity of the block.
[0066] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for performing block pruning based on block activity, characterized in that: The steps include: Step 1: Build a model that can predict the block activity threshold. By collecting and analyzing the UTXO set transaction data over the years, build a model that can predict the threshold of unspent outputs when the block is inactive based on the total number of unspent outputs in the block. Step 2: When a new block is generated in the blockchain, the UTXO set generated by the new block is mapped to a bit vector set stored in the memory, and the UTXO set is traversed to obtain the total number of unspent outputs of the block. The total number is used as input to the model for predicting block activity constructed in step 1 to obtain the output of the model, that is, the activity threshold of each block, and the threshold is associated with the bit vector set; Step 3: When a new transaction verification is generated, determine whether the block's unspent output is equal to or less than the active output according to the input source block height corresponding to the transaction-related input. If so, traverse the bit vector set to find the remaining unspent output number of the block, and determine whether it is less than the associated threshold. If it is less than the threshold, it means that the block has entered an inactive state. The inactive block is pruned after the transaction is completed, and the bit vector corresponding to the block is updated to 0; if not, only the bit vector corresponding to the block is updated; Step 4: Prune blocks, delete the block body of inactive blocks, and only keep the block header of the block on the blockchain. At the same time, traverse the transactions in the pruned block body, and store the transactions that are still unspent and have relatively high value in the block body into the local database for preservation.
2. A method for performing block pruning based on block activity as claimed in claim 1, characterized in that: Before establishing the model of step 1, the activity threshold of the blockchain is first defined: when a block has a sufficient block height and the number of unused transactions in the UTXO set does not change for a long period of time, the block is considered to be inactive. The number of unused transactions in the block at this time is considered to be the activity threshold of the block. When the current number of unused transactions in the block is equal to or less than the activity threshold of the block, the block is considered to be inactive.
3. The method for performing block pruning based on block activity according to claim 1, characterized in that: The model building process in step 1 is as follows: (1) First, we assume that there is a linear relationship between the total number of transaction outputs of a single block and the threshold of block inactivity. The goal of this model is to predict the inactivity threshold corresponding to blocks with different numbers of transactions. Let the total number of transaction outputs of a single block be x, and the transaction output that is still unspent when inactive be y. Assume that there is a linear relationship between y and x. (2) Then data collection and data preprocessing are carried out; (3) Then select the linear regression model, expressed as: y = θ0 + θ1 * x + ε. Where θ0 is the intercept, θ1 is the coefficient of the total number of block transaction outputs, and ε is the error term; (4) Next is model fitting: the collected samples are fitted with a linear regression model, and the loss function is J(θ) = ∑(y(i)-Linearθ(x(i)))2, where J(θ) represents the residual, y(i) is the actual activity threshold corresponding to the i-th sample data, and Linearθ(x(i)) is the activity threshold calculated by the fitting model for the i-th sample data. The entire formula represents the sum of squares of the residuals; (5) Finally, evaluate the model: Draw a scatter plot and a fitted straight line to visually view the model's fitting effect.
4. The method for performing block pruning based on block activity according to claim 1, characterized in that: In step 4, there should be three types of nodes in the pruned blockchain network: pruned nodes, full nodes, and spv nodes. Pruned nodes are nodes that have pruned inactive blocks, full nodes are nodes that have all block data, and spv nodes are nodes that have block headers but no block bodies.
5. The method for performing block pruning based on block activity according to claim 4, characterized in that: It also includes step 5: updating the database table. After each update of the database table, the updated database table will be broadcast to the attached SPV nodes. When the SPV node requests complete information related to a transaction, it will mark the Bloom filter by judging whether the block height to which the transaction belongs is within the clipped block height. This mark will tell other nodes whether this block transaction should be processed by a full node or any node.
6. A system for performing block pruning based on block activity, characterized in that: Includes the following modules: The model building module is used to build a model that can predict the threshold of block activity. By collecting and analyzing the transaction data of the UTXO set over the years, a model is established that can predict the threshold of unspent outputs when the block is inactive based on the total number of unspent outputs in the block. A new block generation module is used to perform the following operations: when a new block is generated in the blockchain, the UTXO set generated by the new block is mapped to a bit vector set stored in the memory, and the UTXO set is traversed to obtain the total number of unspent outputs of the block, and the total number is taken as input into the model for predicting block activity constructed in step 1, and the output of the model, that is, the activity threshold of each block, is obtained, and the threshold is associated with the bit vector set; A new transaction verification generation module is used to perform the following operations: when a new transaction verification is generated, based on the input source block height corresponding to the transaction-related input, determine whether the block's unspent output is equal to or less than the active one. If so, traverse the bit vector set to find the number of remaining unspent outputs of the block, and determine whether it is less than the associated threshold compared to the threshold. If it is less than the threshold, it means that the block has entered an inactive state. The inactive block is pruned after the transaction is completed, and the bit vector corresponding to the block is updated to 0; if not, only the bit vector corresponding to the block is updated; The block pruning module is used to prune blocks, delete the block body of inactive blocks, and only keep the block header of the block on the blockchain. At the same time, it traverses the transactions in the pruned block body and stores the transactions that are still unspent and have relatively high value in the block body into the local database for preservation.
7. A system for performing block pruning based on block activity as claimed in claim 6, characterized in that: In the model building module, the activity threshold of the blockchain is first defined: when a block has reached a sufficient block height and the number of unused transactions in the UTXO set does not change for a long period of time, the block is considered to be inactive. At this time, the number of unused transactions in the block is considered to be the activity threshold of the block. When the current number of unused transactions in the block is equal to or less than the activity threshold of the block, the block is considered to be inactive.
8. A system for performing block pruning based on block activity as claimed in claim 6, characterized in that: In the model building module, the model building process is as follows: (1) First, we assume that there is a linear relationship between the total number of transaction outputs of a single block and the threshold of block inactivity. The goal of this model is to predict the inactivity threshold corresponding to blocks with different numbers of transactions. Let the total number of transaction outputs of a single block be x, and the transaction output that is still unspent when inactive be y. Assume that there is a linear relationship between y and x. (2) Then data collection and data preprocessing are carried out; (3) Then select the linear regression model, expressed as: y = θ0 + θ1 * x + ε. Where θ0 is the intercept, θ1 is the coefficient of the total number of block transaction outputs, and ε is the error term; (4) Next is model fitting: the collected samples are fitted with a linear regression model, and the loss function is J(θ) = ∑(y(i)-Linearθ(x(i)))2, where J(θ) represents the residual, y(i) is the actual activity threshold corresponding to the i-th sample data, and Linearθ(x(i)) is the activity threshold calculated by the fitting model for the i-th sample data. The entire formula represents the sum of squares of the residuals; (5) Finally, evaluate the model: Draw a scatter plot and a fitted straight line to visually view the model's fitting effect.
9. A system for performing block pruning based on block activity as claimed in claim 6, characterized in that: In the block pruning module, there should be three types of nodes in the pruned blockchain network: pruned nodes, full nodes, and spv nodes. Pruned nodes are nodes that have pruned inactive blocks, full nodes are nodes that have all block data, and spv nodes are nodes that have block headers but no block bodies.
10. A system for performing block pruning based on block activity as claimed in claim 9, characterized in that: It also includes a database table update module, which is used to perform the following operations: after each update of the database table, the updated database table is broadcast to the attached SPV nodes. When the SPV node requests complete information related to a transaction, it determines whether the block height to which the transaction belongs is within the clipped block height, and marks it in the Bloom filter. This mark will tell other nodes whether this block transaction should be processed by a full node or by any node.
Citation Information
Patent Citations
Secure and transparent pruning for blockchains
WO2020078594A1
