Block chain-based data processing method, device, and readable storage medium
By archiving transaction data at the transaction granularity level in the blockchain, obtaining transaction identifiers and storing them in the archiving device, the problem of insufficient blockchain storage resources is solved, and storage efficiency and query performance are improved.
Patent Information
- Application Number
- PCT/CN2025/085267
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2024-05-06
- Filing Date
- 2025-03-27
- Publication Date
- 2025-11-13
AI Technical Summary
The blockchain suffers from insufficient storage resources, leading to problems of insufficient storage space and slowed response speed as data continues to increase.
By comparing the space occupied by the transaction data with the archiving threshold, the transaction identifier is obtained and sent to the archiving device for storage. The transaction data is then deleted from the blockchain. The transaction granularity archiving method is adopted to dynamically select the archiving object based on the transaction characteristics.
It reduces the storage space occupied by the blockchain, improves the efficiency of storage resource utilization, optimizes query performance, and realizes the flexibility and scalability of the blockchain.
Smart Images

Figure CN2025085267_13112025_PF_FP_ABST
Abstract
Description
A blockchain-based data processing method, device, and readable storage medium
[0001] This application claims priority to Chinese Patent Application No. 2024105541619, filed on May 6, 2024, entitled "A Data Processing Method, Device and Readable Storage Medium Based on Blockchain", the entire contents of which are incorporated herein by reference. Technical Field
[0002] This application relates to the field of Internet technology, and in particular to a data processing method, device and readable storage medium based on blockchain. Background Technology
[0003] With the rapid development of network technology and enterprises' emphasis on data security, blockchain has received great attention and application.
[0004] For a credible blockchain, its storage space is limited. As the blockchain continues to operate, the amount of data it stores will continue to increase. At this point, the blockchain will face the dilemma of insufficient storage resources. Summary of the Invention
[0005] This application provides a blockchain-based data processing method, device, and readable storage medium, which can reduce the storage resources required for blockchain.
[0006] This application provides, in one aspect, a blockchain-based data processing method, executed by a first blockchain node, the method comprising:
[0007] Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data;
[0008] If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data;
[0009] The first transaction data carrying the transaction identifier is sent to the archiving device so that the archiving device can store the first transaction data according to the transaction identifier;
[0010] In response to the successful archiving message for the first transaction data returned by the archiving device, the first transaction data is deleted from the first block.
[0011] One embodiment of this application provides a blockchain-based data processing device, which operates on a first blockchain node and includes:
[0012] The acquisition module is used to acquire the first transaction data in the first block, acquire the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data;
[0013] The acquisition module is also used to acquire a transaction identifier used to uniquely identify the first transaction data if the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold.
[0014] The sending module is used to send the first transaction data carrying the transaction identifier to the archiving device, so that the archiving device can store the first transaction data according to the transaction identifier;
[0015] The deletion module is used to delete the first transaction data in the first block in response to a successful transaction archiving message returned by the archiving device for the first transaction data.
[0016] In one possible implementation, the acquisition module retrieves the first transaction data from the first block and performs the following operations:
[0017] Active blocks are determined in the blockchain based on a preset number of active blocks; active blocks are those that are not archived.
[0018] Blocks in the blockchain other than active blocks are designated as archive blocks; the block height of an archive block is less than the block height of an active block; an archive block is a block that undergoes archiving processing; an archive block includes the first block;
[0019] Retrieve the first transaction data in the first block.
[0020] In one possible implementation, the acquisition module is also used to perform the following operations:
[0021] Obtain the archiving gradient rules; the archiving gradient rules include the number of active blocks and the number of blocks corresponding to multiple different transaction archiving thresholds; the number of active blocks is used to indicate the number of blocks in the blockchain that are not archived; the number of blocks corresponding to a transaction archiving threshold is used to indicate the number of archived blocks corresponding to a transaction archiving threshold;
[0022] If the number of blocks in the blockchain is less than or equal to the number of active blocks, then the blocks in the blockchain are identified as active blocks.
[0023] If the number of blocks in the blockchain is greater than the number of active blocks, then according to the archiving gradient rule, the active blocks in the blockchain and the archive blocks corresponding to the multiple transaction archiving thresholds are determined respectively; the block height of the active block is greater than the block height corresponding to the multiple archive blocks respectively; the multiple transaction archiving thresholds include the first transaction archiving threshold; the multiple archive blocks include the first block.
[0024] In one possible implementation, multiple transaction archiving thresholds include transaction archiving threshold B. c and transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of multiple transaction archiving thresholds;
[0025] The acquisition module, based on the archiving gradient rules, determines the active blocks in the blockchain and the archived blocks corresponding to multiple distinct transaction archiving thresholds, and performs the following operations:
[0026] If the transaction archiving threshold B c Greater than the transaction archiving threshold B c+1 Then determine the transaction archiving threshold B. c The corresponding block priority is greater than the transaction archiving threshold B. c+1 Corresponding block priority;
[0027] Determine the block priority corresponding to the number of active blocks, and the block priorities corresponding to multiple transaction archiving thresholds respectively;
[0028] Active blocks are determined in the blockchain based on the block priority corresponding to the number of active blocks.
[0029] Based on the block priority corresponding to each of the multiple transaction archiving thresholds, the archive blocks corresponding to each of the multiple transaction archiving thresholds are determined in the blockchain.
[0030] In one possible implementation, the acquisition module determines the archive blocks corresponding to the multiple transaction archiving thresholds in the blockchain according to the block priorities of each threshold, and performs the following operations:
[0031] Determine the first number of the first remaining blocks in the blockchain, excluding the active blocks;
[0032] If the transaction archiving threshold B c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is greater than the transaction archiving threshold B. c The corresponding number of blocks is then selected from the first remaining blocks that are adjacent to the active blocks, and the number of these blocks is equal to the transaction archiving threshold B. c The corresponding number of blocks is determined as the transaction archiving threshold B. c The corresponding archive block;
[0033] Determine the first remaining block excluding the transaction archiving threshold B. c The second remaining block outside the corresponding archive block;
[0034] Based on the block priority corresponding to the second transaction archiving threshold, the archiving block corresponding to the second transaction archiving threshold is determined from the second remaining blocks; the second transaction archiving threshold includes multiple transaction archiving thresholds, excluding transaction archiving threshold B. c Other than the transaction archiving threshold.
[0035] In one possible implementation, the acquisition module is also used to perform the following operations:
[0036] If the transaction archiving threshold B c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is less than or equal to the transaction archiving threshold B. c The corresponding number of blocks is used to determine the first remaining block as the transaction archiving threshold B. c The corresponding archived block; the first transaction archive threshold is transaction archive threshold B. c ; Transaction archiving threshold B c The corresponding archive block includes the first block;
[0037] The empty set is identified as the archive block corresponding to the second transaction archiving threshold.
[0038] In one possible implementation, the acquisition module obtains the first transaction archiving threshold corresponding to the first block and performs the following operations:
[0039] From multiple archive blocks, determine the archive block to which the first block belongs;
[0040] Among multiple transaction archiving thresholds, the transaction archiving threshold corresponding to the archiving block to which the first block belongs is determined as the first transaction archiving threshold.
[0041] In one possible implementation, the acquisition module will obtain the first transaction archiving threshold corresponding to the first block, and use it to perform the following operations:
[0042] At the first moment, the first transaction archiving threshold corresponding to the first block is obtained; at the first moment, the blockchain includes the second block with the largest block height; the second block is an active block;
[0043] The acquisition module is also used to perform the following operations:
[0044] If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, the third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and the third block; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block;
[0045] If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; if the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to multiple transaction archiving thresholds;
[0046] If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data will be archived.
[0047] In one possible implementation, the acquisition module determines the third transaction archiving threshold corresponding to the first block based on the archiving gradient rules and the third block, and performs the following operations:
[0048] Based on the archiving gradient rules, the updated active block in the blockchain storing the third block is determined, as well as the updated archive blocks corresponding to multiple transaction archiving thresholds; the block height corresponding to the updated active block is greater than the block height of the active block; the block height corresponding to multiple updated archive blocks is greater than the block height corresponding to multiple archive blocks;
[0049] From multiple update archive blocks, determine the update archive block to which the first block belongs;
[0050] Among multiple transaction archiving thresholds, the transaction archiving threshold corresponding to the update archiving block to which the first block belongs is determined as the third transaction archiving threshold.
[0051] In one possible implementation, the acquisition module is also used to perform the following operations:
[0052] Obtain the archiving rule retrieval request sent by the service device, and return the archiving gradient rules to the service device according to the archiving rule retrieval request;
[0053] The system retrieves the maximum block height request sent by the business device and returns the maximum block height of the blockchain to the business device based on the request. This enables the business device to determine the predicted transaction archiving threshold corresponding to the first transaction data based on the predicted block height of the first transaction data, the archiving gradient rules, and the maximum block height. The predicted transaction archiving threshold is then compared with the predicted space occupied by the first transaction data generated by the business device. This comparison process is used to determine the archiving prediction result for the first transaction data.
[0054] If the archived prediction result is the prediction result to be archived, then obtain the transaction query request sent by the business device, which includes the transaction identifier;
[0055] Based on the transaction query request, a transaction archiving message is generated; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction identifier has been archived to the archiving device;
[0056] The transaction archiving message is returned to the business device, so that the business device can send a transaction query request to the archiving device based on the transaction archiving message; the archiving device returns the first transaction data to the business device based on the transaction identifier in the transaction query request.
[0057] In one possible implementation, if the archived prediction result is an archived prediction result, the business device is used to send a transaction query request to the archive device; the archive device is used to return the first transaction data to the business device according to the transaction identifier in the transaction query request.
[0058] In one possible implementation, the sending module sends first transaction data carrying a transaction identifier to the archiving device, so that the archiving device stores the first transaction data according to the transaction identifier for performing the following operations:
[0059] The first transaction data carrying the transaction identifier is signed using the node's private key to obtain the data signature;
[0060] The archiving component is invoked, and the first transaction data carrying the data signature and transaction identifier is sent to the archiving device through the archiving component. The archiving device then verifies the data signature using the node's public key and obtains the verification result. The verification result includes a successful verification result. The successful verification result indicates that the first transaction data carrying the transaction identifier has legal attributes, and it also instructs the archiving device to store the first transaction data according to the transaction identifier.
[0061] In one possible implementation, the sending module is also used to perform the following operations:
[0062] Generate a transaction deletion message including a transaction identifier, and send the transaction deletion message to the second blockchain node so that the second blockchain node deletes the first transaction data according to the transaction identifier in the transaction deletion message.
[0063] This application provides a computer device, including: a processor, a memory, and a network interface;
[0064] The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to call the computer programs so that the computer device executes the methods in the embodiments of this application.
[0065] One aspect of this application provides a computer-readable storage medium storing a computer program adapted to be loaded by a processor and executed by the method described in this application.
[0066] One embodiment of this application provides a computer program product, which includes a computer program stored in a computer-readable storage medium; a processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, causing the computer device to perform the method of this application embodiment.
[0067] In this embodiment, a computer device obtains first transaction data from a first block, obtains a first transaction archiving threshold corresponding to the first block, and compares the space occupied by the first transaction data with the first transaction archiving threshold. If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, a transaction identifier is obtained to uniquely identify the first transaction data. The first transaction data carrying the transaction identifier is sent to an archiving device so that the archiving device stores the first transaction data according to the transaction identifier. In response to a successful transaction archiving message returned by the archiving device, the first transaction data is deleted from the first block. As can be seen from the above, this embodiment can archive transaction data that is equal to or greater than the transaction archiving threshold. Through archiving, the storage of large-space transaction data in the blockchain can be reduced, thus alleviating storage resource requirements. Attached Figure Description
[0068] Figure 1 is a schematic diagram of a system architecture provided in an embodiment of this application;
[0069] Figure 2 is a schematic diagram of a data processing scenario based on blockchain provided in an embodiment of this application;
[0070] Figure 3 is a flowchart illustrating a data processing method based on blockchain according to an embodiment of this application;
[0071] Figure 4 is a schematic diagram of the internal structure of a blockchain node provided in an embodiment of this application;
[0072] Figure 5 is a schematic flowchart of a data processing method based on blockchain provided in an embodiment of this application;
[0073] Figure 6 is a schematic diagram of a data processing scenario based on blockchain provided in an embodiment of this application;
[0074] Figure 7 is a schematic flowchart of a data processing method based on blockchain provided in an embodiment of this application;
[0075] Figure 8 is a schematic flowchart of a blockchain-based data processing method provided in an embodiment of this application;
[0076] Figure 9 is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application;
[0077] Figure 10 is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0078] To facilitate understanding, the following brief explanations are provided for some of the terms:
[0079] 1. Blockchain: In a narrow sense, blockchain is a chain-like data structure with blocks as the basic unit. Blocks use digital digests to verify previously obtained transaction history, making it suitable for the tamper-proof and scalable requirements of distributed ledger scenarios. In a broader sense, blockchain also refers to the distributed ledger technology implemented using the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, and smart contracts. The goal of blockchain is to implement a distributed data record ledger that only allows additions, not deletions. The underlying basic structure of the ledger is a linear linked list. The linked list consists of a series of "blocks," with each subsequent block recording the hash value of the previous block. The validity of each block (and the transactions within it) can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, the block must be confirmed through a consensus mechanism.
[0080] For a credible blockchain, its computing resources and storage space are limited. Therefore, as the number of blocks increases, the available storage space corresponding to the credible blockchain may be insufficient, and the response may be slower than the request. At this time, it is necessary to alleviate the storage space of the blockchain.
[0081] 2. Block Ledger: The block ledger is the core data structure in a blockchain system, used to store and manage all confirmed blocks. Organized in a chain-like structure, each block contains a set of transactions, a block header (including metadata such as the hash value and timestamp of the previous block), and other information. The block ledger provides a public, immutable history of transactions for the blockchain system, ensuring the system's transparency and consistency.
[0082] 3. Transaction Pool: A transaction pool (also known as a mempool) is a data structure in a blockchain network used to store transactions that have not yet been packaged into blocks. When a business device submits a new transaction to the blockchain network, the transaction first enters the transaction pool. When preparing to generate a new block, blockchain nodes select a certain number of transactions from the transaction pool to package. The transaction pool helps improve the processing capacity of the blockchain network and can also be used as a strategy to allow block-producing nodes to prioritize packaging transactions with higher transaction fees, thereby increasing block production rewards.
[0083] 4. Block Data Archiving: Block data archiving refers to the process of transferring old block data in the blockchain from primary storage (usually a high-performance and costly storage system) to an archiving center (referred to as an archiving device in this application). This process typically involves data backup, migration, and storage management. The purpose of block data archiving is to optimize the use of primary storage space, maintain the efficient operation of the blockchain network, and ensure the integrity and accessibility of old data.
[0084] 5. Archiving Center: Also referred to as archiving equipment in this embodiment, an archiving center is a system or service specifically designed for long-term storage of blockchain data. Its main purpose is to alleviate the storage burden on the blockchain network by transferring data that is no longer frequently accessed to a more economical storage solution. Archiving centers typically possess high-capacity storage capabilities and can guarantee data integrity and retrievability. In a blockchain system, the archiving center may be a distributed network or a centralized data warehouse. It can receive archiving requests from blockchain nodes and store the corresponding block data according to preset rules or strategies. In this embodiment, the blockchain nodes store transaction data in the archiving center.
[0085] 6. Hash Value: Also known as an information feature value or characteristic value, a hash value is generated by converting input data of arbitrary length into cryptography using a hash algorithm and producing a fixed output. The original input data cannot be retrieved by decrypting the hash value; it is a one-way encryption function. The hash value is a core and crucial aspect of blockchain technology, preserving the authenticity of recorded and viewed data, as well as the integrity of the blockchain as a whole.
[0086] 7. Blockchain Nodes: Blockchain networks divide nodes into consensus nodes (also known as core nodes or full nodes) and business nodes (also known as light nodes). Consensus nodes are responsible for the consensus process across the entire blockchain network; business nodes are responsible for synchronizing the ledger information from the consensus nodes, i.e., synchronizing the latest block data. Both consensus nodes and business nodes include network communication components in their internal structure, because a blockchain network is essentially a peer-to-peer network and requires communication with other nodes in the blockchain network through these components. Resources and services in the blockchain network are distributed across various nodes, and information transmission and service implementation occur directly between nodes without the need for intermediaries or centralized servers (third parties).
[0087] Please refer to Figure 1, which is a schematic diagram of a system architecture provided in an embodiment of this application. As shown in Figure 1, the system architecture can be a blockchain network 10, which may include a witness network 10a (also called a business network) and a consensus network 10b. Nodes in the witness network 10a can be called business nodes, which possess some data. Business nodes mainly perform business execution and do not participate in the accounting consensus. They obtain block header data and some authorized visible data from the consensus network 10b through identity authentication. The consensus network 10b can also be called the core network and the accounting network. Nodes in the consensus network 10b can be called consensus nodes, which possess all the data. The witness network 10a and the consensus network 10b are located in different network environments. Generally speaking, the witness network 10a is located in a public network while the consensus network 10b is located in a private network. The two interact through a routing boundary.
[0088] Please refer to Figure 1 again. Witness network 10a may include business node 101a, business node 102a, business node 103a, ..., business node 104a. It is understood that witness network 10a may include one or more witness networks. In practical applications, due to different application scenarios, one or more types of witness networks can be set up; the number of witness networks will not be limited here. Witness network 10a may include one or more business nodes; the number of business nodes will not be limited here.
[0089] Please refer to Figure 1 again. The consensus network 10b may include consensus node 101b, consensus node 102b, consensus node 103b, ..., consensus node 104b. It is understood that the aforementioned consensus network 10b may include one or more consensus networks. In practical applications, due to different application scenarios, one or more types of consensus networks can be set up; the number of consensus networks will not be limited here. The aforementioned consensus network 10b may include one or more consensus nodes; the number of consensus nodes will not be limited here.
[0090] Each blockchain node (including the consensus node in consensus network 10b and the business node in witness network 10a) can receive business transactions sent by clients during normal operation, generate blocks based on the received business transactions, and then perform block on-chain processing. It is understood that in the specific embodiments of this application, data related to user information (such as business transactions) is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use, and processing of related data must comply with the relevant laws, regulations, and standards of the relevant regions.
[0091] To ensure data communication between blockchain nodes, data connections can exist between each blockchain node. For example, there is a data connection between business node 101a and business node 102a, a data connection between business node 101a and business node 103a, and a data connection between consensus node 101b and consensus node 104b.
[0092] Furthermore, there are data connections between witness network 10a and consensus network 10b. For example, there are data connections between business node 101a and consensus node 102b, business node 101a and consensus node 103b, and consensus node 101b and business node 104a.
[0093] It is understandable that blockchain nodes can transmit data or blocks through the aforementioned data connections. These data connections between blockchain nodes can be based on node identifiers. Each blockchain node in the blockchain network 10 has a corresponding node identifier, and each blockchain node can store the node identifiers of other blockchain nodes that are connected to it. This allows it to broadcast acquired data or generated blocks to other blockchain nodes based on their node identifiers. For example, business node 101a can maintain a node identifier list as shown in Table 1, which stores the node names and node identifiers of other blockchain nodes.
[0094] Table 1
[0095] The node identifier can be an Internet Protocol (IP) address used for interconnecting networks, or any other information that can be used to identify a blockchain node in a blockchain network.
[0096] Assuming the node identifier of business node 101a is FFFFF, business node 101a can send a transaction to be uploaded to the blockchain to consensus node 104b through the node identifier CCCCC. Consensus node 104b can determine that the transaction to be uploaded to the blockchain was sent by business node 101a through the node identifier FFFFF. Similarly, consensus node 104b can send a block consensus request to consensus node 102b through the node identifier BBBBB. Consensus node 102b can determine that the block consensus request was sent by consensus node 104b through the node identifier CCCCC. Data transmission between other blockchain nodes is also in the same way, so it will not be elaborated on one by one.
[0097] It is understood that the above data connection is not limited to the connection method. It can be connected directly or indirectly through wired communication, or directly or indirectly through wireless communication, or through other connection methods. This application does not impose any restrictions on this.
[0098] It is understood that the blockchain-based data processing method provided in this application embodiment can be executed by computer equipment, including but not limited to business nodes (which can be terminal devices or servers) or consensus nodes (which can be terminal devices or servers). The aforementioned server can be an independent physical server, a server cluster composed of multiple physical servers, or a distributed system. It can also be a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The aforementioned terminal devices include but are not limited to mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft. The terminal devices and servers can be directly or indirectly connected via wired or wireless means, and this application embodiment does not impose any restrictions on this.
[0099] Further, please refer to Figure 2, which is a schematic diagram of a data processing scenario based on blockchain provided in an embodiment of this application. The implementation process of this blockchain-based data processing scenario can be carried out on the first blockchain node in the blockchain network. The first blockchain node can be any blockchain node in the blockchain network 10 of the embodiment corresponding to Figure 1 above. Figure 2 uses blockchain node 20a as an example for description.
[0100] As shown in Figure 2, blockchain node 20a stores the first block 201a, which may include multiple transactions. Figure 2 illustrates this by showing that the first block 201a includes transactions 1, 2, and 3. When the first block 201a is an archive block, blockchain node 20a performs space occupancy identification processing on each transaction in the first block 201a. Figure 2 uses transaction 1 as the first transaction data 20b for illustration. Blockchain node 20a obtains the space occupancy 201b of transaction 1. Figure 2 illustrates this space occupancy 201b as 6 kilobytes (kb). Based on the block height of the first block 201a and the current highest block height of the blockchain, blockchain node 20a obtains the first transaction archiving threshold 20c corresponding to the first block 201a. The first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data. Figure 2 illustrates this first transaction archiving threshold 20c as 5 kilobytes (5kb).
[0101] As shown in Figure 2, blockchain node 20a compares the first transaction archiving threshold 20c with the space occupied by transaction 1 201b. Clearly, the space occupied by 201b (6kb in the example) is greater than the first transaction archiving threshold 20c (5kb in the example). Therefore, blockchain node 20a obtains the transaction identifier 202b corresponding to transaction 1 (representing the first transaction data 20b). The transaction identifier 202b can be any information that can uniquely identify transaction 1 in the blockchain. Figure 2 uses the transaction hash of transaction 1 as an example of the transaction identifier 202b for transaction 1, i.e., ABC4g...df in Figure 2.
[0102] Furthermore, blockchain node 20a sends the first transaction data 20b (Figure 2 uses ABC4g...df as an example) carrying transaction identifier 202b to the archiving device 20d, whereby the archiving device 20d includes, but is not limited to, terminal devices or servers. The aforementioned server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, content delivery networks (CDNs), and big data and artificial intelligence platforms. The aforementioned terminal devices include, but are not limited to, mobile phones, computers, smart voice interaction devices, smart home appliances, vehicle terminals, and aircraft.
[0103] The archiving device 20d stores the first transaction data 20b according to the transaction identifier 202b. For example, as shown in Figure 2, it constructs and stores index key-value pairs using the transaction identifier as the index key and the transaction (transaction data) as the index value. The index key-value table 20e in Figure 2 includes three index key-value pairs: the first index key-value pair includes the index key generated by Sfg56...87 and the index value generated by transaction a; the second index key-value pair includes the index key generated by Df53b...ju and the index value generated by transaction b; the third index key-value pair includes the index key generated by ABC4g...df and the index value generated by transaction 1.
[0104] Subsequently, the archiving device 20d returns a successful archiving message for the first transaction data 20b (transaction 1 in the example of Figure 2) to the blockchain node 20a. Therefore, based on the successful archiving message, the blockchain node 20a can delete the first transaction data 20b from the first block 201a. As shown in Figure 2, the blockchain node 20a deletes transaction 1 from the first block 201a, resulting in block 202a after the deletion of transaction 1. It is understood that the data in the block header of block 202a will not change, but the block body will not include transaction 1.
[0105] The transaction data described in this application embodiment includes business transactions and transaction execution results. It is understood that the processing procedure of blockchain node 20a for transactions 2 and 3 in Figure 2 is the same as that for transaction 1, and therefore will not be repeated here.
[0106] As described above, this application proposes a transaction-level archiving method. Compared to block-level archiving, transaction-level archiving is a more refined data archiving method. It does not archive the entire block's data, but rather determines whether to archive based on the size, importance, or other specific criteria of individual transactions. This method allows the system to dynamically select which transactions need to be archived and which can be retained in the main storage (blockchain) based on the characteristics of each transaction. Transaction-level archiving can improve the utilization efficiency of storage resources, reduce unnecessary archiving operations, and optimize query performance based on the access frequency and importance of transactions. This archiving method provides greater flexibility and scalability for blockchain data management.
[0107] Further, please refer to Figure 3, which is a flowchart illustrating a blockchain-based data processing method according to an embodiment of this application. This blockchain-based data processing method can be executed by a first blockchain node in the blockchain network, where the first blockchain node can be any blockchain node in the blockchain network. As shown in Figure 3, this blockchain-based data processing method may include at least the following steps S101-S104.
[0108] Step S101: Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data.
[0109] Specifically, based on the preset number of active blocks, active blocks are determined in the blockchain; active blocks are blocks that are not archived; blocks other than active blocks in the blockchain are determined as archive blocks; the block height of archive blocks is less than the block height of active blocks; archive blocks are blocks that are archived; archive blocks include the first block; the first transaction data in the first block is obtained.
[0110] Specifically, from multiple archive blocks, the archive block to which the first block belongs is determined; and from multiple transaction archive thresholds, the transaction archive threshold corresponding to the archive block to which the first block belongs is determined as the first transaction archive threshold.
[0111] Understandably, newly generated blocks in a blockchain are accessed or queried more frequently than blocks with lower block heights. Therefore, based on block height, blocks in a blockchain can be divided into archived blocks and active blocks. For example, if a blockchain contains 1000 blocks, this can be understood as the current maximum block height being 1000. The number of active blocks is an adjustable parameter, which can be set according to the actual application scenario. For ease of understanding and explanation, this step uses 100 as an example for the number of active blocks. The 100 most recently generated blocks can be identified as active blocks, meaning they do not require archiving. All other blocks in the blockchain, excluding these active blocks, require archiving and are called archived blocks. Any block in the archived blocks can be called the first block.
[0112] Step S102: If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data.
[0113] Specifically, the first transaction data may include business transactions and transaction execution results. This application embodiment does not limit the transaction type of business transactions, including but not limited to business transactions corresponding to the financial services industry, business transactions corresponding to the supply chain, business transactions corresponding to the medical services industry, business transactions corresponding to legal compliance and auditing, and business transactions corresponding to big data analysis.
[0114] The space occupied by the first transaction data refers to the space or capacity occupied by the first transaction data in the blockchain. The first transaction archiving threshold refers to the storage space threshold for the transaction data (including the first transaction data) in the evaluation block (including the first block) that can be archived. It is an adjustable parameter that can be set according to the actual application scenario.
[0115] The transaction identifier can be any information that can be used to uniquely identify the first transaction data. Figure 2 above uses the transaction hash of transaction 1 as an example to illustrate the transaction identifier 202b of transaction 1. In actual application scenarios, the transaction identifier can be one or a combination of at least two of the following: transaction hash, transaction sequence number in the blockchain, block height, and transaction sequence number in the block.
[0116] Step S103: Send the first transaction data carrying the transaction identifier to the archiving device so that the archiving device stores the first transaction data according to the transaction identifier.
[0117] Specifically, the first transaction data carrying the transaction identifier is signed using the node's private key to obtain a data signature; the archiving component is invoked, and the first transaction data carrying the data signature and transaction identifier is sent to the archiving device, so that the archiving device verifies the data signature using the node's public key to obtain a verification result; the verification result includes a successful verification result; the successful verification result is used to indicate that the first transaction data carrying the transaction identifier has legal attributes, and the successful verification result is used to instruct the archiving device to store the first transaction data according to the transaction identifier.
[0118] Step S104: In response to the successful archiving message for the first transaction data returned by the archiving device, delete the first transaction data in the first block.
[0119] Specifically, a transaction deletion message including a transaction identifier is generated and sent to the second blockchain node, so that the second blockchain node deletes the first transaction data according to the transaction identifier in the transaction deletion message.
[0120] The second blockchain node includes the remaining blockchain nodes in the blockchain network besides the first blockchain node.
[0121] This application proposes a system architecture for a dynamic blockchain data archiving scheme based on transaction granularity and block height. The internal implementation of the blockchain node (including the first blockchain node) and the interactions between its components are described in detail below. Please refer to Figure 4, which is a schematic diagram of the internal structure of a blockchain node provided in this application embodiment, detailed as follows:
[0122] 1. Network Components: The network components are responsible for communication between blockchain nodes, including sending and receiving data. They handle all network protocol-related tasks, such as connection management, data transmission, node discovery, and message broadcasting. The network components ensure that blockchain nodes can correctly transmit information within the blockchain network and remain synchronized with other blockchain nodes.
[0123] 2. Verification Component: The verification component is responsible for checking the validity of transactions and blocks. This component typically contains two sub-components:
[0124] 2.1 Certificate Verification Sub-component: Responsible for verifying identity certificates in the blockchain network to ensure that the source of transactions or blocks is trustworthy.
[0125] 2.2 Permission Verification Subcomponent: Responsible for checking whether the entity initiating the transaction has the permission to execute the transaction, and whether the transaction complies with the network rules.
[0126] 3. Transaction Pool Component: The transaction pool component is a temporary storage area used to store transactions waiting to be packaged into blocks. When transactions are received by network nodes, they are first placed in the transaction pool, and then selected and added to new blocks according to certain rules (such as fees, timestamps, etc.).
[0127] 4. Scheduling Component: The scheduling component is responsible for managing the core business logic of blockchain nodes, including the following sub-components:
[0128] 4.1 Block Generator: Responsible for creating new blocks. It selects transactions from the transaction pool, performs the necessary verifications, and packages them into a new block.
[0129] 4.2 Transaction Scheduling Subcomponent: Responsible for deciding which transactions should be included in the next block, which may be based on factors such as transaction fees and priority.
[0130] 4.3 Contract Repository: Stores the code and related metadata of smart contracts.
[0131] 4.4 Contract Process Pool: The environment responsible for executing smart contracts, which can process the execution of multiple smart contracts in parallel.
[0132] 5. Consensus Component: The consensus component is the part of a blockchain node used to implement the network consensus mechanism. It ensures that all nodes reach a consensus on the consistency of the network state. This component can implement different consensus algorithms, such as Proof-of-Work (PoW), Proof-of-Stake (PoS), or Byzantine Fault Tolerance (BFT).
[0133] 6. Archiving Component: The archiving component is responsible for handling the data archiving process and includes the following sub-components:
[0134] 6.1 Archiving Algorithm Model: Responsible for determining which data should be archived, as well as the timing and method of archiving.
[0135] 6.2 Archive Center Client: In this embodiment of the application, it is also referred to as the archive component. As an interface for communicating with the archive center, it is responsible for sending data to the archive center and retrieving data from it.
[0136] 6.3 Block Transaction Incremental Archiver: Responsible for archiving transactions at the granular level, selecting transactions of large size or those determined according to other criteria for archiving.
[0137] 7. Storage Component: The storage component is responsible for the persistence of node data and includes the following sub-components:
[0138] 7.1 State Database: Stores the current state of the blockchain, such as account balances and the state of smart contracts.
[0139] 7.2 Block Ledger: Stores historical data of the blockchain, including all blocks and transaction records that have been generated.
[0140] These components work together to ensure that blockchain nodes can process transactions, generate and verify blocks, and maintain the overall state of the blockchain.
[0141] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.
[0142] Please refer to Figure 5, which is a schematic flowchart of a blockchain-based data processing method according to an embodiment of this application. This blockchain-based data processing method can be executed by a first blockchain node, which can be any blockchain node in the blockchain network 10 of the embodiment corresponding to Figure 1. As shown in Figure 5, the method may include at least the following steps.
[0143] Step S201: Obtain the archiving gradient rules; the archiving gradient rules include the number of active blocks and the number of blocks corresponding to multiple different transaction archiving thresholds; the number of active blocks is used to indicate the number of blocks in the blockchain that are not archived; the number of blocks corresponding to a transaction archiving threshold is used to indicate the number of archived blocks corresponding to a transaction archiving threshold.
[0144] Specifically, this application embodiment does not limit the archiving gradient rules, which can be set according to the actual application scenario. For ease of understanding and description, please refer to Figure 6, which is a schematic diagram of a data processing scenario based on blockchain provided by this application embodiment. As shown in Figure 6, blockchain node 60a (as the first blockchain node) obtains archiving gradient rules 60b. The archiving gradient rule 60b in Figure 6 includes three important fields: archiving threshold, quantity, and priority. Among them, the archiving threshold refers to the transaction archiving threshold, which is used to confirm the archiving of transaction data in the block. Figure 6 illustrates five transaction archiving thresholds, namely positive infinity (+∞), 4 kilobytes (4kb), 3 kilobytes (3kb), 2 kilobytes (2kb), and 1 kilobyte (1kb).
[0145] In the archiving gradient rule 60b, the quantity represents the number of blocks corresponding to a transaction archiving threshold. In the example in Figure 6, the number of blocks corresponding to a transaction archiving threshold with a value of positive infinity is 50. The number of blocks corresponding to a transaction archiving threshold with a value of positive infinity can represent the number of active blocks in this embodiment. The number of blocks corresponding to a transaction archiving threshold with a value of 4kb is 100, the number of blocks corresponding to a transaction archiving threshold with a value of 3kb is 200, the number of blocks corresponding to a transaction archiving threshold with a value of 2kb is 300, and the number of blocks corresponding to a transaction archiving threshold with a value of 1kb is the remaining number. The meaning of the remaining number is explained in conjunction with the priority.
[0146] In the archiving gradient rule 60b, priority represents block priority. The value of the transaction archiving threshold is positively correlated with the block priority, that is, the larger the transaction archiving threshold, the higher the block priority. Therefore, the block priority corresponding to the transaction archiving threshold of +∞ (value 5) is greater than the block priority corresponding to the transaction archiving threshold of 4kb (value 4). Thus, the blockchain node first determines the block corresponding to the transaction archiving threshold of +∞, and then determines the block corresponding to the transaction archiving threshold of 4kb. It can be understood that the block corresponding to +∞ is the active block. Similarly, the block priority corresponding to a transaction archiving threshold of 4kb is greater than the block priority corresponding to a transaction archiving threshold of 3kb (value 3), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 4kb, and then determines the block corresponding to the transaction archiving threshold of 3kb; the block priority corresponding to a transaction archiving threshold of 3kb is greater than the block priority corresponding to a transaction archiving threshold of 2kb (value 2), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 3kb, and then determines the block corresponding to the transaction archiving threshold of 2kb; the block priority corresponding to a transaction archiving threshold of 2kb is greater than the block priority corresponding to a transaction archiving threshold of 1kb (value 1), so the blockchain node first determines the block corresponding to the transaction archiving threshold of 2kb, and then determines the block corresponding to the transaction archiving threshold of 1kb.
[0147] In summary, blockchain nodes first obtain the blocks corresponding to the transaction archiving threshold of +∞. When the number of blocks in the blockchain is greater than 50, the last 50 generated blocks are determined as active blocks (i.e., the blocks corresponding to the transaction archiving threshold of +∞).
[0148] When the number of blocks in the blockchain is greater than 150, the blockchain node determines the last 50 generated blocks as active blocks and the 100 blocks adjacent to the active blocks as archive blocks corresponding to the transaction archiving threshold of 4kb. For ease of description, the archive blocks corresponding to the transaction archiving threshold of 4kb are simply referred to as the first archive blocks.
[0149] When the number of blocks in the blockchain exceeds 350, the blockchain nodes determine the last 50 generated blocks as active blocks, the 100 blocks adjacent to the active blocks as archive blocks corresponding to a transaction archiving threshold of 4kb, i.e., the first archive blocks, and the 200 blocks adjacent to the first archive blocks as archive blocks corresponding to a transaction archiving threshold of 3kb. For ease of description, the archive blocks corresponding to a transaction archiving threshold of 3kb are simply referred to as the second archive blocks.
[0150] When the number of blocks in the blockchain exceeds 650, the last 50 generated blocks are designated as active blocks. The 100 blocks adjacent to the active blocks are designated as archive blocks corresponding to a transaction archiving threshold of 4kb, i.e., the first archive blocks. The 200 blocks adjacent to the first archive blocks are designated as archive blocks corresponding to a transaction archiving threshold of 3kb, i.e., the second archive blocks. The 300 blocks adjacent to the second archive blocks are designated as archive blocks corresponding to a transaction archiving threshold of 2kb. For ease of description, the archive blocks corresponding to a transaction archiving threshold of 2kb are referred to as the third archive blocks. The remaining blocks in the blockchain, excluding the active blocks, the first archive blocks, the second archive blocks, and the third archive blocks, are designated as archive blocks corresponding to a transaction archiving threshold of 1kb.
[0151] As can be seen from the above, the transaction archiving proposed in this application embodiment will have different archiving threshold requirements for transaction size based on different block heights. Transactions in a block that exceed this archiving threshold will be placed in the archiving center.
[0152] Step S202: If the number of blocks in the blockchain is less than or equal to the number of active blocks, then the blocks in the blockchain are determined to be active blocks.
[0153] Specifically, the number of active blocks refers to the number of blocks that are not archived, i.e., the number of blocks corresponding to active blocks. Referring again to Figure 6, if the transaction archiving threshold is positive infinity, then the corresponding number represents the number of active blocks. In the example in Figure 6, the number of active blocks is 50. When blockchain 60c is stored, since blockchain 60c has 4 blocks (meaning it contains 4 blocks), and the number of blocks (4) is less than the number of active blocks, blockchain node 60a determines these 4 blocks in blockchain 60c as active blocks. Because the number of blocks is less than the number of active blocks, there are no blocks in blockchain 60c that are archived, i.e., there are no archived blocks.
[0154] Step S203: If the number of blocks in the blockchain is greater than the number of active blocks, then according to the archiving gradient rule, determine the active blocks in the blockchain and the archive blocks corresponding to the multiple transaction archiving thresholds respectively; the block height of the active blocks is greater than the block heights corresponding to the multiple archive blocks respectively; the multiple transaction archiving thresholds include the first transaction archiving threshold; the multiple archive blocks include the first block.
[0155] Specifically, multiple transaction archiving thresholds include transaction archiving threshold B. c and transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of multiple transaction archiving thresholds.
[0156] If the transaction archiving threshold B c Greater than the transaction archiving threshold Bc+1 Then determine the transaction archiving threshold B. c The corresponding block priority is greater than the transaction archiving threshold B. c+1 The corresponding block priority; determine the block priority corresponding to the number of active blocks, and the block priority corresponding to multiple transaction archiving thresholds respectively; determine the active blocks in the blockchain according to the block priority corresponding to the number of active blocks; determine the archived blocks corresponding to multiple transaction archiving thresholds respectively in the blockchain according to the block priority corresponding to multiple transaction archiving thresholds respectively.
[0157] The specific process of determining the archived blocks corresponding to multiple transaction archiving thresholds in the blockchain, based on the block priorities corresponding to each threshold, may include: determining the first number of the first remaining blocks in the blockchain excluding active blocks; if the transaction archiving threshold B... c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is greater than the transaction archiving threshold B. c The corresponding number of blocks is then selected from the first remaining blocks that are adjacent to the active blocks, and the number of these blocks is equal to the transaction archiving threshold B. c The corresponding number of blocks is determined as the transaction archiving threshold B. c The corresponding archived block; determine the first remaining block excluding the transaction archived threshold B. c The second remaining block besides the corresponding archived block; according to the block priority corresponding to the second transaction archiving threshold, determine the archived block corresponding to the second transaction archiving threshold in the second remaining block; the second transaction archiving threshold includes multiple transaction archiving thresholds, excluding transaction archiving threshold B. c Other than the transaction archiving threshold.
[0158] This step may also include: if the transaction archiving threshold B c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is less than or equal to the transaction archiving threshold B. c The corresponding number of blocks is used to determine the first remaining block as the transaction archiving threshold B. c The corresponding archived block; the first transaction archive threshold is transaction archive threshold B. c ; Transaction archiving threshold B c The corresponding archived blocks include the first block; the empty set is determined as the archived block corresponding to the second transaction archived threshold.
[0159] This application embodiment does not limit the number of multiple transaction archiving thresholds, nor does it limit the value of each transaction archiving threshold. The number of transaction archiving thresholds and the value of each transaction archiving threshold can be determined according to the actual application scenario. Similarly, this application embodiment does not limit the number of archived blocks corresponding to a transaction archiving threshold, and can also set it according to the actual application scenario.
[0160] Please refer to Figure 6 again. As the blockchain network continuously reaches consensus on new blocks, blockchain 60c will continuously add new blocks. For example, blockchain node 60a generates blockchain 601c, which has 60 blocks. This can be understood as blockchain 601c adding 56 new blocks to blockchain 60c, for a total of 60 blocks. Since the number of blocks in blockchain 601c (60) is greater than the number of active blocks (50) in the example in Figure 6, blockchain node 60a can identify the 50 newly generated blocks in blockchain 601c as active blocks. This can be understood as the block height range corresponding to active blocks being [11, 60], indicating that blocks 11 to 60 are active blocks and do not require archiving.
[0161] In blockchain 601c, the 10 blocks excluding the active blocks can be represented as the first remaining blocks, i.e., blocks 1-10 belong to the first remaining blocks. Since the first number of blocks corresponding to the first remaining blocks (10) is less than the number of blocks corresponding to the transaction archiving threshold of 4kb (100), blockchain node 60a determines blocks 1-10 as the archived blocks corresponding to the transaction archiving threshold of 4kb. In blockchain 601c, there are no archived blocks corresponding to transaction archiving thresholds of 3kb, 2kb, and 1kb, respectively.
[0162] Subsequently, blockchain node 60a generates blockchain 602c, which has 999 blocks. This can be understood as blockchain 602c adding 939 new blocks to blockchain 601c, for a total of 999 blocks. Since the number of blocks in blockchain 602c (999) is greater than the number of active blocks (50) in the example shown in Figure 6, blockchain node 60a can identify the 50 newly generated blocks in blockchain 602c as active blocks. It is important to emphasize that the active blocks corresponding to blockchain 602c are different from those corresponding to blockchain 601c. The block height range for the active blocks in blockchain 602c is [950, 999], indicating that blocks 950 to 999 are active blocks.
[0163] In blockchain 602c, the 949 blocks excluding the active blocks can be represented as the first remaining blocks, i.e., blocks 1 to 949 belong to the first remaining blocks. Since the first number of the first remaining blocks (949) is greater than the number of blocks corresponding to the transaction archiving threshold of 4kb (100), blockchain node 60a determines blocks 850 to 949 as the archived blocks corresponding to the transaction archiving threshold of 4kb. Further, according to the priority example in Figure 6, blockchain node 60a determines blocks 650 to 849 as the archived blocks corresponding to the transaction archiving threshold of 3kb; determines blocks 350 to 649 as the archived blocks corresponding to the transaction archiving threshold of 2kb; and determines the remaining blocks in blockchain 602c, i.e., blocks 1 to 349, as the archived blocks corresponding to the transaction archiving threshold of 1kb.
[0164] In summary, as the blockchain continuously adds blocks, the block corresponding to each transaction archiving threshold changes. Conversely, the transaction archiving threshold corresponding to each block is updated. The further away a block is from the current largest block, the smaller its corresponding transaction archiving threshold, and therefore the greater the probability of it being archived.
[0165] Step S204: Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data.
[0166] Specifically, it can be understood that the space occupied by the first transaction data is a fixed value, but the first transaction archiving threshold corresponding to the first transaction data will be updated as the blockchain grows. Please refer to Figure 6 again. Assuming that the first block is block 5, if blockchain node 60a generates blockchain 601c, then the first block of block 5 belongs to the archiving block corresponding to the transaction archiving threshold of 4kb. Therefore, the first transaction archiving threshold corresponding to the first block is equal to 4kb.
[0167] If blockchain node 60a generates blockchain 602c, then the first block of block 5 belongs to the archived block corresponding to a transaction archiving threshold of 1kb. In this case, the first transaction archiving threshold corresponding to the first block is equal to 1kb. Obviously, the transaction archiving thresholds corresponding to the first block of block 5 are different in blockchains 601c and 602c as illustrated in Figure 6.
[0168] Step S205: If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data.
[0169] Step S206: Send the first transaction data carrying the transaction identifier to the archiving device so that the archiving device stores the first transaction data according to the transaction identifier.
[0170] Specifically, as described in steps S205-S206, many current blockchain systems support blockchain archiving, but the granularity of archiving is based on blocks, meaning an entire block is archived at a time. This method is straightforward and simple, but the archiving effect is poor because, in order to save storage space on blockchain nodes, as many blocks as possible are stored in the archiving center, which puts a lot of query pressure on the archiving center. Therefore, this application proposes an archiving scheme based on transaction granularity, which can identify transactions with large storage space in a block and save them to the archiving center, while retaining transactions with smaller storage space, thus avoiding a large influx of query requests into the archiving center. Simultaneously, since older blocks are queried less frequently, this embodiment of the application combines block height; older blocks further from the current latest block are more likely to be archived. Therefore, the archiving threshold for transactions in a block is dynamically updated during the block production process.
[0171] This application proposes a dynamic blockchain data archiving scheme based on transaction granularity and block height, which focuses on solving the aforementioned problems. The main innovations of this application are as follows:
[0172] 1. Adaptive Transaction Size-Aware Incremental Blockchain Data Archiving Mechanism: This innovation involves a novel archiving mechanism that dynamically determines whether to archive transaction data based on the transaction size (i.e., the space it occupies). This mechanism identifies and separates large (space-consuming) transactions, archiving them independently, while retaining smaller (space-consuming) transactions in main storage. This approach not only effectively reduces query pressure on the archiving center but also optimizes storage space usage, avoiding unnecessary archiving of small transactions and thus reducing storage requirements for the archiving center.
[0173] 2. Dynamic Archiving Threshold Adjustment Strategy Based on Block Height Differentiation: The second innovation is a dynamic archiving threshold adjustment strategy based on block height. In this strategy, the system dynamically adjusts the archiving threshold based on the height difference between a block and the current latest block (i.e., the block's "age"). As the block height increases, older blocks become "older," and the system lowers the transaction size threshold for archiving, allowing more transactions to meet the archiving criteria. This method ensures that blockchain storage space is released more efficiently over time while maintaining fast access to transactions in new blocks. Implementing this strategy can significantly improve the storage efficiency and query performance of the blockchain system.
[0174] Step S207: In response to the successful archiving message for the first transaction data returned by the archiving device, delete the first transaction data in the first block.
[0175] Specifically, the advantages of the embodiments of this application are as follows:
[0176] 1. Optimize storage space utilization: Traditional archiving schemes typically archive the entire block of data, without considering the actual size and importance of each transaction within the block. This scheme identifies and archives large transactions while retaining smaller transactions in main storage, allowing for more granular management of storage space. This transaction-level archiving method reduces the storage requirements of the archiving center, thereby lowering storage costs and improving storage space utilization efficiency.
[0177] 2. Improve Query Performance and Response Speed: In traditional solutions, the coarse-grained nature of archiving operations can lead to frequently accessed data being archived, increasing query latency. This solution dynamically adjusts the archiving threshold, ensuring that small transactions in newer, frequently accessed blocks remain in main storage, while large transactions in older blocks are archived. This strategy reduces query requests to the archiving center, improving query performance and system response speed, especially for applications with high real-time requirements.
[0178] 3. Enhanced System Scalability and Flexibility: This solution introduces dynamic archiving threshold adjustment based on block height. This means that as the blockchain grows, the system can adaptively adjust its archiving strategy to adapt to different storage and query needs. This adaptive capability allows the blockchain system to optimize more flexibly in the face of constantly changing data access patterns and storage pressure. Furthermore, this strategy can be adjusted according to actual business needs and storage costs, providing more possibilities for the long-term operation and expansion of the blockchain system.
[0179] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.
[0180] Please refer to Figure 7, which is a schematic flowchart of a blockchain-based data processing method according to an embodiment of this application. This blockchain-based data processing method can be executed by a first blockchain node, which can be any blockchain node in the blockchain network 10 of the embodiment corresponding to Figure 1. As shown in Figure 7, the method may include at least the following steps.
[0181] Step S301: Obtain the first transaction data in the first block; at the first moment, obtain the first transaction archiving threshold corresponding to the first block; compare the space occupied by the first transaction data with the first transaction archiving threshold; at the first moment, the blockchain includes the second block with the largest block height; the second block is an active block.
[0182] Specifically, it is understandable that the blockchain is constantly increasing over time, so the blockchain at different times includes different blocks. As illustrated in Figure 6 above, suppose that blockchain node 60a stores blockchain 601c at the first time and blockchain 602c at the second time. Blockchain 602c is generated based on blockchain 601c, but the latest block of blockchain 601c (which can represent the second block) is block 60, and the latest block of blockchain 602c (which can represent the third block described below) is block 999.
[0183] Step S302: If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data.
[0184] Step S303: Send the first transaction data carrying the transaction identifier to the archiving device so that the archiving device stores the first transaction data according to the transaction identifier.
[0185] Step S304: In response to the successful archiving message for the first transaction data returned by the archiving device, delete the first transaction data in the first block.
[0186] For the specific implementation process of steps S302-S304, please refer to steps S102-S104 in the embodiment corresponding to Figure 3 above, which will not be repeated here.
[0187] Step S305: If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, the third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and the third block; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block.
[0188] Specifically, based on the archiving gradient rules, the updated active block in the blockchain storing the third block, as well as the updated archive blocks corresponding to multiple transaction archiving thresholds, are determined; the block height corresponding to the updated active block is greater than the block height of the active block; the block height corresponding to multiple updated archive blocks is greater than the block height corresponding to multiple archive blocks; from the multiple updated archive blocks, the updated archive block to which the first block belongs is determined; and the transaction archive threshold corresponding to the updated archive block to which the first block belongs, among the multiple transaction archiving thresholds, is determined as the third transaction archive threshold.
[0189] It is understandable that the process by which a blockchain node determines the active block and the archived blocks corresponding to multiple transaction archived thresholds according to the archived gradient rules at the first moment is the same as the process by which it determines the updated active block and the updated archived blocks corresponding to multiple transaction archived thresholds according to the archived gradient rules at the second moment. Therefore, it will not be described in detail here, but can be referred to the description in the above embodiment.
[0190] Step S306: If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to multiple transaction archiving thresholds.
[0191] Step S307: If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data is archived.
[0192] Specifically, referring to steps S306-S307, for ease of understanding and description, the example first block is block 3 in Figure 6, and the space occupied by the first transaction data is 3kb. At the first moment, blockchain node 60a generates blockchain 601c. The first block (block 3 in the example) belongs to the archive block corresponding to a transaction archiving threshold of 4kb. Therefore, the first transaction archiving threshold corresponding to the first transaction data is equal to 4kb. Since the space occupied by the first transaction data is 3kb, which is less than the first transaction archiving threshold of 4kb, blockchain node 60a does not perform archiving processing on the first transaction data; that is, the first transaction data is stored in the blockchain.
[0193] Subsequently, the blockchain network continuously adds new blocks. The archive blocks to which the first block (e.g., block 3 in Figure 6) belongs are updated. For example, at the second moment, the length of the blockchain is 153, and the maximum block height is 153. In this scenario, active blocks include blocks 153 to 104, archive blocks corresponding to a transaction archiving threshold of 4kb include blocks 4 to 103, and archive blocks corresponding to a transaction archiving threshold of 3kb include blocks 1 to 3. Clearly, block 3 belongs to the archive blocks corresponding to the transaction archiving threshold of 4kb, and is updated to belong to the archive blocks corresponding to the transaction archiving threshold of 3kb. Therefore, the transaction archiving threshold corresponding to block 3 is updated from 4kb to 3kb. However, the space occupied by the first transaction data does not change and remains 3kb. At this time, the space occupied by the first transaction data is 3kb, which is equal to the transaction archiving threshold of 3kb corresponding to block 3. Therefore, at the second moment, the blockchain node archives the first transaction data.
[0194] The blockchain node can execute the embodiment of this application each time a new block is generated. That is, according to the archiving gradient rule, it determines the active blocks in the blockchain and the archive blocks corresponding to multiple transaction archiving thresholds. For each block, it first determines the archive block to which it belongs, and then determines the corresponding transaction archiving threshold. Then, it compares the space occupied by the transactions in each block with the transaction archiving threshold corresponding to the block to determine whether to archive the transactions in the block.
[0195] In one feasible implementation, blockchain nodes can also set a batch block value, for example, a batch block value of 20. Then, the blockchain network performs an archiving process every 20 newly generated blocks. That is, if fewer than 20 new blocks are generated after the last batch archiving, no archiving process is performed until the number of newly generated blocks equals 20. Then, according to the archiving gradient rules, the active blocks in the blockchain and the archiving blocks corresponding to the multiple transaction archiving thresholds are re-determined. The subsequent process is the same as above, so it will not be repeated here.
[0196] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.
[0197] Please refer to Figure 8, which is a flowchart illustrating a blockchain-based data processing method according to an embodiment of this application. This blockchain-based data processing method can be executed by a first blockchain node, which can be any blockchain node in the blockchain network 10 of the embodiment corresponding to Figure 1. As shown in Figure 8, the method may include at least the following steps.
[0198] Step S401: Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data.
[0199] Step S402: If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data.
[0200] Step S403: Send the first transaction data carrying the transaction identifier to the archiving device so that the archiving device stores the first transaction data according to the transaction identifier.
[0201] In step S404, in response to the successful archiving message for the first transaction data returned by the archiving device, the first transaction data is deleted from the first block.
[0202] For the specific implementation process of steps S401-S404, please refer to steps S101-S104 in the embodiment corresponding to Figure 3 above, which will not be repeated here.
[0203] Step S405: Obtain the archiving rule retrieval request sent by the service device, and return the archiving gradient rule to the service device according to the archiving rule retrieval request.
[0204] Specifically, the application scenarios of this solution on the product side include, but are not limited to, the following aspects:
[0205] 1. Blockchain Applications in the Financial Services Industry: In the financial services industry, blockchain technology is used in various aspects such as transaction recording, asset management, and compliance monitoring. This solution's adaptive transaction size-aware incremental blockchain data archiving mechanism can optimize transaction data storage. For example, transaction records with large resource values may occupy more storage space due to their importance and complexity. This solution can prioritize archiving these transactions with large resource values, thus preserving fast access for more frequent transactions with smaller resource values. Simultaneously, a dynamic archiving threshold adjustment strategy based on block height differentiation can automatically adjust the archiving strategy over time, ensuring that older transaction records are effectively archived without affecting query performance.
[0206] 2. Supply Chain Management: Blockchain applications in supply chain management require recording and tracing large amounts of commodity flow information. Over time, the frequency of querying certain historical transaction data decreases. This solution can dynamically archive this data based on transaction size and block height, thereby providing more storage space and faster access speeds for currently active transaction data. This is highly valuable for supply chain management systems that need to monitor the status and location of goods in real time.
[0207] 3. Healthcare Data Management: Blockchain applications in the healthcare field involve massive amounts of data and medical records. This data is typically highly sensitive and requires long-term storage. This solution can help healthcare institutions dynamically archive medical records based on data size and access frequency, ensuring rapid access to critical medical data while rationally managing long-term storage costs.
[0208] 4. Legal Compliance and Auditing: Legal compliance and auditing applications require the long-term storage of large amounts of transaction records and contract information. This solution provides an efficient data archiving method for these applications, ensuring that older contracts and transaction records meet compliance requirements without consuming excessive main storage space. A strategy that dynamically adjusts archiving thresholds automatically optimizes the archiving process based on audit cycles and compliance requirements.
[0209] 5. Big Data Analytics and Blockchain: Big data analytics requires processing and storing massive datasets. In big data analytics applications combined with blockchain technology, this solution can help dynamically manage the large amounts of data generated during the analysis process. Through transaction-level archiving, frequently accessed data can be ensured to be quickly available, while large, infrequently used datasets can be archived to save storage space.
[0210] In the application scenarios described above, the innovations of this solution can help enterprises and organizations manage blockchain data more effectively, improve system performance, reduce storage costs, and provide a better user experience.
[0211] Step S406: Obtain the maximum block height acquisition request sent by the business device. Based on the maximum block height acquisition request, return the maximum block height of the blockchain to the business device, so that the business device can determine the predicted transaction archiving threshold corresponding to the first transaction data based on the predicted block height of the first transaction data, the archiving gradient rule, and the maximum block height. The predicted transaction archiving threshold is used to compare with the predicted space occupied by the first transaction data generated by the business device. The comparison process is used to determine the archiving prediction result for the first transaction data.
[0212] Specifically, if the archived prediction result is an archived prediction result, the business device is used to send a transaction query request to the archive device; the archive device is used to return the first transaction data to the business device based on the transaction identifier in the transaction query request.
[0213] The predicted block height refers to the block height predicted by the business device for the first transaction data. This prediction may differ from the actual block height of the first transaction data in the blockchain. Similar to blockchain nodes, the business device can also determine the active blocks of the blockchain and the archived blocks corresponding to multiple transaction archiving thresholds based on archiving gradient rules and the maximum block height. Therefore, it can determine whether the predicted block height belongs to an active block or an archived block corresponding to a specific transaction archiving threshold. If the business device determines that the predicted block height corresponds to an archived block corresponding to a transaction archiving threshold, then that transaction archiving threshold is determined as the predicted transaction archiving threshold.
[0214] Furthermore, the business equipment predicts the space occupied by the first transaction data, and this predicted space is called the predicted space. The difference between this predicted space and the actual space occupied by the first transaction data is small. The business equipment compares the predicted space occupied by the first transaction data with the predicted transaction archiving threshold. If the predicted space occupied is equal to or greater than the predicted transaction archiving threshold, the business equipment predicts that the first transaction data has been archived. The archived prediction result is determined as the archived prediction result. Therefore, the business equipment sends a transaction query request for the first transaction data to the archiving device, so that the archiving device can query the first transaction data in its own database according to the transaction query request.
[0215] If the first transaction data has been stored in the archiving device, the archiving device will return the first transaction data to the business device. If the archiving device has not stored the first transaction data, that is, the first transaction data is still stored in the blockchain, the archiving device can forward the transaction query request for the first transaction data to the blockchain network, so that the blockchain network can return the first transaction data to the business device according to the transaction query request. Alternatively, the archiving device returns a query failure message to the business device. In this case, the business device can send the transaction query request for the first transaction data to the blockchain network, so that the blockchain network can return the first transaction data to the business device according to the transaction query request.
[0216] Understandably, determining whether transaction data should be archived based on estimated transaction size and block range, and then directly accessing it, has a high probability of success.
[0217] Step S407: If the archived prediction result is the prediction result to be archived, then obtain the transaction query request sent by the service device, which includes the transaction identifier.
[0218] Specifically, if the predicted space occupied is less than the predicted transaction archiving threshold, the business device predicts that the first transaction data has not been archived. The prediction result to be archived is determined as the archived prediction result. Therefore, the business device will send the transaction query request for the first transaction data to the blockchain network so that the blockchain network can query the first transaction data in the blockchain according to the transaction query request.
[0219] If the first transaction data has already been stored in the archiving device, meaning the first transaction data has actually been archived, the blockchain node can forward the transaction query request for the first transaction data to the archiving device, so that the archiving device can return the first transaction data to the business device according to the transaction query request; or, the blockchain node returns a query failure message to the business device, in which case the business device can send the transaction query request for the first transaction data to the archiving device, so that the archiving device can return the first transaction data to the business device according to the transaction query request.
[0220] If the first transaction data is stored on the blockchain, the blockchain node will return the first transaction data to the business device.
[0221] Step S408: Generate a transaction archiving message based on the transaction query request; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction identifier has been archived to the archiving device.
[0222] Step S409: Return the transaction archiving message to the business device so that the business device can send a transaction query request to the archiving device based on the transaction archiving message; the archiving device returns the first transaction data to the business device based on the transaction identifier in the transaction query request.
[0223] Specifically, the architecture of this application embodiment can be as follows:
[0224] 1. This paper describes the system architecture of a dynamic blockchain data archiving scheme based on transaction granularity and block height. The system architecture of the entire scheme is designed, including the network component, verification component, transaction pool component, scheduling component, archiving component, consensus component, and storage component of the blockchain node.
[0225] It also details the dynamic blockchain data archiving interaction diagram based on transaction granularity and block height, the direct query scheme based on transaction size estimation, and the phased dynamic transaction archiving interaction scheme.
[0226] The above system architecture forms the foundation for the entire environment's operation, ensuring efficient and stable system operation through the aforementioned solutions and system architecture.
[0227] 2. A full lifecycle process for a dynamic blockchain data archiving scheme based on transaction granularity and block height was designed. This includes a dynamic incremental transaction archiving process based on block height changes (the process of incrementally archiving transactions when the block height changes and reaches the threshold), and a direct transaction query process based on transaction size (the process where business devices directly query transactions from blockchain nodes or the archiving center based on the estimated range of transaction size and block height).
[0228] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.
[0229] Further, please refer to Figure 9, which is a schematic diagram of the structure of a blockchain-based data processing device provided in an embodiment of this application. This blockchain-based data processing device can operate on a first blockchain node, and the aforementioned blockchain-based data processing device 1 can be used to execute the corresponding steps in the method provided in the embodiment of this application. As shown in Figure 9, the blockchain-based data processing device 1 may include: an acquisition module 11, a sending module 12, and a deletion module 13.
[0230] The acquisition module 11 is used to acquire the first transaction data in the first block, acquire the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data;
[0231] The acquisition module 11 is also used to acquire a transaction identifier for uniquely identifying the first transaction data if the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold.
[0232] The sending module 12 is used to send the first transaction data carrying the transaction identifier to the archiving device, so that the archiving device stores the first transaction data according to the transaction identifier;
[0233] The deletion module 13 is used to delete the first transaction data in the first block in response to a successful transaction archiving message returned by the archiving device for the first transaction data.
[0234] In one possible implementation, module 11 retrieves the first transaction data from the first block and performs the following operations:
[0235] Active blocks are determined in the blockchain based on a preset number of active blocks; active blocks are those that are not archived.
[0236] Blocks in the blockchain other than active blocks are designated as archive blocks; the block height of an archive block is less than the block height of an active block; an archive block is a block that undergoes archiving processing; an archive block includes the first block;
[0237] Retrieve the first transaction data in the first block.
[0238] In one possible implementation, module 11 is also used to perform the following operations:
[0239] Obtain the archiving gradient rules; the archiving gradient rules include the number of active blocks and the number of blocks corresponding to multiple different transaction archiving thresholds; the number of active blocks is used to indicate the number of blocks in the blockchain that are not archived; the number of blocks corresponding to a transaction archiving threshold is used to indicate the number of archived blocks corresponding to a transaction archiving threshold;
[0240] If the number of blocks in the blockchain is less than or equal to the number of active blocks, then the blocks in the blockchain are identified as active blocks.
[0241] If the number of blocks in the blockchain is greater than the number of active blocks, then according to the archiving gradient rule, the active blocks in the blockchain and the archive blocks corresponding to the multiple transaction archiving thresholds are determined respectively; the block height of the active block is greater than the block height corresponding to the multiple archive blocks respectively; the multiple transaction archiving thresholds include the first transaction archiving threshold; the multiple archive blocks include the first block.
[0242] In one possible implementation, multiple transaction archiving thresholds include transaction archiving threshold B. c and transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of multiple transaction archiving thresholds;
[0243] Module 11, based on the archiving gradient rules, determines the active blocks in the blockchain and the archived blocks corresponding to multiple distinct transaction archiving thresholds, and performs the following operations:
[0244] If the transaction archiving threshold B c Greater than the transaction archiving threshold B c+1 Then determine the transaction archiving threshold B. c The corresponding block priority is greater than the transaction archiving threshold B. c+1 Corresponding block priority;
[0245] Determine the block priority corresponding to the number of active blocks, and the block priorities corresponding to multiple transaction archiving thresholds respectively;
[0246] Active blocks are determined in the blockchain based on the block priority corresponding to the number of active blocks.
[0247] Based on the block priority corresponding to each of the multiple transaction archiving thresholds, the archive blocks corresponding to each of the multiple transaction archiving thresholds are determined in the blockchain.
[0248] In one possible implementation, the acquisition module 11 determines the archive blocks corresponding to the multiple transaction archiving thresholds in the blockchain according to the block priorities of each threshold, and performs the following operations:
[0249] Determine the first number of the first remaining blocks in the blockchain, excluding the active blocks;
[0250] If the transaction archiving threshold B c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is greater than the transaction archiving threshold B. c The corresponding number of blocks is then selected from the first remaining blocks that are adjacent to the active blocks, and the number of these blocks is equal to the transaction archiving threshold B. c The corresponding number of blocks is determined as the transaction archiving threshold B. c The corresponding archive block;
[0251] Determine the first remaining block excluding the transaction archiving threshold B. c The second remaining block outside the corresponding archive block;
[0252] Based on the block priority corresponding to the second transaction archiving threshold, the archiving block corresponding to the second transaction archiving threshold is determined from the second remaining blocks; the second transaction archiving threshold includes multiple transaction archiving thresholds, excluding transaction archiving threshold B. c Other than the transaction archiving threshold.
[0253] In one possible implementation, module 11 is also used to perform the following operations:
[0254] If the transaction archiving threshold B c The largest transaction archiving threshold among multiple transaction archiving thresholds, and the first number is less than or equal to the transaction archiving threshold B. c The corresponding number of blocks is used to determine the first remaining block as the transaction archiving threshold B. c The corresponding archived block; the first transaction archive threshold is transaction archive threshold B. c ; Transaction archiving threshold B c The corresponding archive block includes the first block;
[0255] The empty set is identified as the archive block corresponding to the second transaction archiving threshold.
[0256] In one possible implementation, the acquisition module 11 acquires the first transaction archiving threshold corresponding to the first block, and performs the following operations:
[0257] From multiple archive blocks, determine the archive block to which the first block belongs;
[0258] Among multiple transaction archiving thresholds, the transaction archiving threshold corresponding to the archiving block to which the first block belongs is determined as the first transaction archiving threshold.
[0259] In one possible implementation, the acquisition module 11 acquires the first transaction archiving threshold corresponding to the first block, and performs the following operations:
[0260] At the first moment, the first transaction archiving threshold corresponding to the first block is obtained; at the first moment, the blockchain includes the second block with the largest block height; the second block is an active block;
[0261] The acquisition module 11 is also used to perform the following operations:
[0262] If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, the third transaction archiving threshold corresponding to the first block is determined according to the archiving gradient rule and the third block; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block;
[0263] If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; if the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to multiple transaction archiving thresholds;
[0264] If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data will be archived.
[0265] In one possible implementation, the acquisition module 11 determines the third transaction archiving threshold corresponding to the first block based on the archiving gradient rules and the third block, and performs the following operations:
[0266] Based on the archiving gradient rules, the updated active block in the blockchain storing the third block is determined, as well as the updated archive blocks corresponding to multiple transaction archiving thresholds; the block height corresponding to the updated active block is greater than the block height of the active block; the block height corresponding to multiple updated archive blocks is greater than the block height corresponding to multiple archive blocks;
[0267] From multiple update archive blocks, determine the update archive block to which the first block belongs;
[0268] Among multiple transaction archiving thresholds, the transaction archiving threshold corresponding to the update archiving block to which the first block belongs is determined as the third transaction archiving threshold.
[0269] In one possible implementation, module 11 is also used to perform the following operations:
[0270] Obtain the archiving rule retrieval request sent by the service device, and return the archiving gradient rules to the service device according to the archiving rule retrieval request;
[0271] The system retrieves the maximum block height request sent by the business device and returns the maximum block height of the blockchain to the business device based on the request. This enables the business device to determine the predicted transaction archiving threshold corresponding to the first transaction data based on the predicted block height of the first transaction data, the archiving gradient rules, and the maximum block height. The predicted transaction archiving threshold is then compared with the predicted space occupied by the first transaction data generated by the business device. This comparison process is used to determine the archiving prediction result for the first transaction data.
[0272] If the archived prediction result is the prediction result to be archived, then obtain the transaction query request sent by the business device, which includes the transaction identifier;
[0273] Based on the transaction query request, a transaction archiving message is generated; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction identifier has been archived to the archiving device;
[0274] The transaction archiving message is returned to the business device, so that the business device can send a transaction query request to the archiving device based on the transaction archiving message; the archiving device returns the first transaction data to the business device based on the transaction identifier in the transaction query request.
[0275] In one possible implementation, if the archived prediction result is an archived prediction result, the business device is used to send a transaction query request to the archive device; the archive device is used to return the first transaction data to the business device according to the transaction identifier in the transaction query request.
[0276] In one possible implementation, the sending module 12 sends the first transaction data carrying the transaction identifier to the archiving device, so that the archiving device stores the first transaction data according to the transaction identifier for performing the following operations:
[0277] The first transaction data carrying the transaction identifier is signed using the node's private key to obtain the data signature;
[0278] The archiving component is invoked, and the first transaction data carrying the data signature and transaction identifier is sent to the archiving device through the archiving component. The archiving device then verifies the data signature using the node's public key and obtains the verification result. The verification result includes a successful verification result. The successful verification result indicates that the first transaction data carrying the transaction identifier has legal attributes, and it also instructs the archiving device to store the first transaction data according to the transaction identifier.
[0279] In one possible implementation, the sending module 12 is also used to perform the following operations:
[0280] Generate a transaction deletion message including a transaction identifier, and send the transaction deletion message to the second blockchain node so that the second blockchain node deletes the first transaction data according to the transaction identifier in the transaction deletion message.
[0281] As can be seen from the above, the embodiments of this application can archive transaction data that is equal to or greater than the transaction archiving threshold. By archiving, the storage of transaction data that occupies a large amount of space in the blockchain can be reduced, thus alleviating storage resources.
[0282] Further, please refer to Figure 10, which is a schematic diagram of the structure of a computer device provided in an embodiment of this application. As shown in Figure 10, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a user interface 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to implement communication between these components. In some embodiments, the user interface 1003 may include a display screen and a keyboard, and the network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory, such as at least one disk storage device. Optionally, the memory 1005 may also be at least one storage device located remotely from the aforementioned processor 1001. As shown in Figure 10, the memory 1005, as a computer storage medium, may include an operating system, a network communication module, a user interface module, and a device control application.
[0283] In the computer device 1000 shown in Figure 10, the network interface 1004 provides network communication functions; the user interface 1003 is mainly used to provide an input interface for the user; and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0284] Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data;
[0285] If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain the transaction identifier used to uniquely identify the first transaction data;
[0286] The first transaction data carrying the transaction identifier is sent to the archiving device so that the archiving device can store the first transaction data according to the transaction identifier;
[0287] In response to the successful archiving message for the first transaction data returned by the archiving device, the first transaction data is deleted from the first block.
[0288] It should be understood that the computer device 1000 described in the embodiments of this application can perform the data processing methods or apparatus based on blockchain described in the preceding embodiments, and will not be repeated here. In addition, the beneficial effects of using the same method will also not be repeated.
[0289] This application also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the blockchain-based data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.
[0290] The aforementioned computer-readable storage medium can be the internal storage unit of the blockchain-based data processing apparatus provided in any of the foregoing embodiments or the computer device, such as the hard drive or memory of the computer device. The computer-readable storage medium can also be an external storage device of the computer device, such as a plug-in hard drive, smart media card (SMC), secure digital (SD) card, flash card, etc., provided on the computer device. Furthermore, the computer-readable storage medium can include both internal and external storage units of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium can also be used to temporarily store data that has been output or will be output.
[0291] This application also provides a computer program product, which includes a computer program stored in a computer-readable storage medium. A processor of a computer device reads the computer program from the computer-readable storage medium and executes the computer program, enabling the computer device to perform the blockchain-based data processing methods or apparatus described in the preceding embodiments, which will not be repeated here. Furthermore, the beneficial effects of using the same method will also not be repeated.
[0292] The terms "first," "second," etc., in the specification, claims, and drawings of this application are used to distinguish different objects, not to describe a specific order. Furthermore, the term "comprising," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, apparatus, product, or device that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules not listed, or may optionally include other step units inherent to these processes, methods, apparatuses, products, or devices.
[0293] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0294] The above-disclosed embodiments are merely preferred embodiments of this application and should not be construed as limiting the scope of this application. Therefore, any equivalent variations made in accordance with the claims of this application shall still fall within the scope of this application.
Claims
1. A data processing method based on blockchain, characterized in that, The method is executed by the first blockchain node, and the method includes: Obtain the first transaction data in the first block, obtain the first transaction archiving threshold corresponding to the first block, compare the space occupied by the first transaction data with the first transaction archiving threshold, where the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data; If the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold, then obtain a transaction identifier used to uniquely identify the first transaction data; The first transaction data carrying the transaction identifier is sent to the archiving device so that the archiving device stores the first transaction data according to the transaction identifier; In response to a successful transaction archiving message for the first transaction data returned by the archiving device, the first transaction data is deleted from the first block.
2. The method according to claim 1, characterized in that, The step of obtaining the first transaction data in the first block includes: Based on a preset number of active blocks, active blocks are determined in the blockchain; the active blocks refer to blocks that are not archived. Blocks in the blockchain other than the active blocks are designated as archive blocks; the height of the archive blocks is less than the height of the active blocks; the archive blocks refer to blocks that undergo archiving processing; the archive blocks include the first block; Obtain the first transaction data from the first block.
3. The method according to claims 1-2, characterized in that, The method further includes: Obtain the archiving gradient rules; the archiving gradient rules include the number of active blocks and the number of blocks corresponding to multiple different transaction archiving thresholds; the number of active blocks is used to indicate the number of blocks in the blockchain that are not archived; the number of blocks corresponding to a transaction archiving threshold is used to indicate the number of archived blocks corresponding to a transaction archiving threshold; If the number of blocks in the blockchain is less than or equal to the number of active blocks, then the blocks in the blockchain are determined to be active blocks; If the number of blocks in the blockchain is greater than the number of active blocks, then according to the archiving gradient rule, the active blocks in the blockchain and the archived blocks corresponding to the multiple transaction archiving thresholds are determined respectively; the block height of the active blocks is greater than the block heights corresponding to the multiple archived blocks respectively; the multiple transaction archiving thresholds include the first transaction archiving threshold; the multiple archived blocks include the first block.
4. The method according to claims 1 to 3, characterized in that, The multiple transaction archiving thresholds include transaction archiving threshold B. c and transaction archiving threshold B c+1 c is a positive integer and c is less than the total number of the multiple transaction archiving thresholds; The step of determining the active blocks in the blockchain and the archived blocks corresponding to the multiple transaction archiving thresholds according to the archiving gradient rules includes: If the transaction archiving threshold B c Greater than the transaction archiving threshold B c+1 Then determine the transaction archiving threshold B. c The corresponding block priority is greater than the transaction archiving threshold B. c+1 Corresponding block priority; The block priority corresponding to the number of active blocks is determined to be greater than the block priority corresponding to the multiple transaction archiving thresholds respectively; Active blocks are determined in the blockchain based on the block priority corresponding to the number of active blocks; Based on the block priorities corresponding to the multiple transaction archiving thresholds, the archive blocks corresponding to the multiple transaction archiving thresholds are determined in the blockchain.
5. The method according to claims 1 to 4, characterized in that, The step of determining the archive blocks corresponding to the multiple transaction archiving thresholds in the blockchain according to the block priorities corresponding to the multiple transaction archiving thresholds includes: Determine the first number of the first remaining blocks in the blockchain, excluding the active blocks; If the transaction archiving threshold B c The first number is the largest transaction archiving threshold among the plurality of transaction archiving thresholds, and is greater than the transaction archiving threshold B. c The corresponding number of blocks is then determined by selecting the first remaining blocks that are adjacent to the active blocks, and the number of these adjacent blocks is equal to the transaction archiving threshold B. c The corresponding number of blocks is determined as the transaction archiving threshold B. c The corresponding archive block; Determine that, in the first remaining block, excluding the transaction archiving threshold B... c The second remaining block outside the corresponding archive block; Based on the block priority corresponding to the second transaction archiving threshold, the archive block corresponding to the second transaction archiving threshold is determined in the second remaining blocks; the second transaction archiving threshold includes, except for the transaction archiving threshold B, among the plurality of transaction archiving thresholds. c Other than the transaction archiving threshold.
6. The method according to claims 1 to 5, characterized in that, Also includes: If the transaction archiving threshold B c The first number is the largest transaction archiving threshold among the plurality of transaction archiving thresholds, and is less than or equal to the transaction archiving threshold B. c The corresponding number of blocks, then the first remaining block is determined as the transaction archiving threshold B. c The corresponding archived block; the first transaction archived threshold is the transaction archived threshold B. c The transaction archiving threshold B c The corresponding archive block includes the first block; The empty set is determined as the archive block corresponding to the second transaction archiving threshold.
7. The method according to claims 1 to 6, characterized in that, The step of obtaining the first transaction archiving threshold corresponding to the first block includes: From the plurality of archive blocks, determine the archive block to which the first block belongs; The transaction archiving threshold corresponding to the archiving block to which the first block belongs among the multiple transaction archiving thresholds is determined as the first transaction archiving threshold.
8. The method according to claims 1 to 7, characterized in that, The step of obtaining the first transaction archiving threshold corresponding to the first block includes: At the first moment, the first transaction archiving threshold corresponding to the first block is obtained; at the first moment, the blockchain includes a second block with the maximum block height; the second block belongs to the active block; The method further includes: If the space occupied by the first transaction data is less than the first transaction archiving threshold, then at the second time point, according to the archiving gradient rule and the third block, the third transaction archiving threshold corresponding to the first block is determined; the third block is the block with the maximum block height in the blockchain at the second time point; the second time point is later than the first time point; the block height of the third block is greater than the block height of the second block; If the third transaction archiving threshold is different from the first transaction archiving threshold, then the space occupied by the first transaction data is compared with the third transaction archiving threshold; the third transaction archiving threshold is less than the first transaction archiving threshold, and the third transaction archiving threshold belongs to the plurality of transaction archiving thresholds; If the space occupied by the first transaction data is equal to or greater than the third transaction archiving threshold, then the first transaction data is archived.
9. The method according to claims 1 to 8, characterized in that, The step of determining the third transaction archiving threshold corresponding to the first block based on the archiving gradient rule and the third block includes: Based on the archiving gradient rules, the updated active block in the blockchain storing the third block, and the updated archive blocks corresponding to the multiple transaction archiving thresholds are determined respectively; the block height corresponding to the updated active block is greater than the block height of the active block; the block height corresponding to the multiple updated archive blocks is greater than the block height corresponding to the multiple archive blocks. From the plurality of update archive blocks, determine the update archive block to which the first block belongs; The transaction archiving threshold corresponding to the update archiving block to which the first block belongs among the multiple transaction archiving thresholds is determined as the third transaction archiving threshold.
10. The method according to claims 1 to 9, characterized in that, The method further includes: Obtain the archiving rule retrieval request sent by the service device, and return the archiving gradient rule to the service device according to the archiving rule retrieval request; The system acquires a maximum block height acquisition request sent by the service device, and returns the maximum block height of the blockchain to the service device based on the maximum block height acquisition request. This allows the service device to determine a predicted transaction archiving threshold corresponding to the first transaction data based on the predicted block height of the first transaction data, the archiving gradient rule, and the maximum block height. The predicted transaction archiving threshold is used to compare with the predicted space occupied for the first transaction data generated by the service device. The comparison process is used to determine the archiving prediction result for the first transaction data. If the archiving prediction result is the prediction result to be archived, then obtain the transaction query request sent by the service device, which includes the transaction identifier; Based on the transaction query request, a transaction archiving message is generated; the transaction archiving message is used to indicate that the first transaction data indicated by the transaction identifier has been archived to the archiving device; The transaction archiving message is returned to the service device, so that the service device sends the transaction query request to the archiving device according to the transaction archiving message; the archiving device returns the first transaction data to the service device according to the transaction identifier in the transaction query request.
11. The method according to claims 1 to 10, characterized in that, If the archived prediction result is an archived prediction result, the service device is used to send the transaction query request to the archive device; the archive device is used to return the first transaction data to the service device according to the transaction identifier in the transaction query request.
12. The method according to claims 1 to 11, characterized in that, The step of sending the first transaction data carrying the transaction identifier to the archiving device, so that the archiving device stores the first transaction data according to the transaction identifier, includes: The first transaction data carrying the transaction identifier is signed using the node's private key to obtain a data signature; An archiving component is invoked, through which the first transaction data carrying the data signature and the transaction identifier is sent to the archiving device, so that the archiving device verifies the data signature using the node public key to obtain a verification result; the verification result includes a verification success result; the verification success result is used to indicate that the first transaction data carrying the transaction identifier has a legitimate attribute, and the verification success result is used to instruct the archiving device to store the first transaction data according to the transaction identifier.
13. The method according to claims 1 to 12, characterized in that, The method further includes: A transaction deletion message including the transaction identifier is generated, and the transaction deletion message is sent to the second blockchain node so that the second blockchain node deletes the first transaction data according to the transaction identifier in the transaction deletion message.
14. A data processing device based on blockchain, characterized in that, The device operates on the first blockchain node, and the device includes: The acquisition module is used to acquire the first transaction data in the first block, acquire the first transaction archiving threshold corresponding to the first block, and compare the space occupied by the first transaction data with the first transaction archiving threshold; the first transaction archiving threshold refers to the storage space threshold required to archive the first transaction data; The acquisition module is further configured to acquire a transaction identifier for uniquely identifying the first transaction data if the space occupied by the first transaction data is equal to or greater than the first transaction archiving threshold. The sending module is used to send the first transaction data carrying the transaction identifier to the archiving device, so that the archiving device stores the first transaction data according to the transaction identifier; The deletion module is used to obtain a successful transaction archiving message for the first transaction data returned by the archiving device, and delete the first transaction data in the first block according to the successful transaction archiving message.
15. A computer device, characterized in that, include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication functions, the memory is used to store computer programs, and the processor is used to invoke the computer programs to cause the computer device to perform the method according to any one of claims 1 to 13.
16. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program adapted to be loaded and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-13.
17. A computer program product, characterized in that, The computer program product includes a computer program stored in a computer-readable storage medium, the computer program being adapted to be read and executed by a processor to cause a computer device having the processor to perform the method of any one of claims 1-13.
Citation Information
Patent Citations
Block chain-based offline archiving system and method
CN110413621A
Data archiving method and device, electronic equipment and storage medium
CN112416937A
Block chain data management method and device, electronic equipment and medium
CN112925479A
Block chain data dynamic archiving method and system based on BaaS platform
CN115481083A
A system for data archival in a blockchain network and a method thereof
WO2023111882A1
Cited By
Financial transaction historical data storage optimization method
CN121365043A