Blockchain-based data processing method, apparatus, device, and storage medium

By identifying and backing up redundant blocks on the blockchain, the problem of blockchain storage pressure is solved, ensuring the normal operation of the blockchain network and the credibility of transaction data.

CN115730933BActive Publication Date: 2025-12-09TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202110997867.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-27
Publication Date
2025-12-09
Estimated Expiration
2041-08-27

AI Technical Summary

Technical Problem

As time goes on, the amount of data stored on the blockchain increases, leading to increased pressure on storage space and affecting the normal operation of the blockchain network.

Method used

By identifying blocks in a redundant state, backing them up to different storage spaces and deleting transaction data on the blockchain, the transaction data is restored to the blockchain when a retrieval request is received.

Benefits of technology

It alleviates the storage pressure on the blockchain, ensures the normal operation of the blockchain network, and improves the credibility and security of transaction data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115730933B_ABST
    Figure CN115730933B_ABST
Patent Text Reader

Abstract

Embodiments of the present application disclose a data processing method and device based on a blockchain, equipment and a storage medium, and relate to the blockchain technology. The method comprises the following steps: obtaining attribute information of a block on the blockchain; identifying a target block in a redundant state from the blockchain according to the attribute information of the block; backing up the target block into a first storage space, and deleting transaction data in the target block on the blockchain; the first storage space is different from a second storage space used for storing the blockchain; if an acquisition request for the transaction data in the target block is received, the transaction data in the target block is restored to the blockchain according to the target block backed up in the first storage space; and transaction data is read from the target block restored from the blockchain. The present application alleviates the storage pressure of the storage space used for storing the blockchain, and ensures that the business is normally processed.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of blockchains, and in particular to a data processing method and device based on a blockchain, equipment and a storage medium. BACKGROUND

[0002] A blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission (P2P transmission), consensus mechanism and encryption algorithm. A blockchain can be composed of multiple concatenated blocks. The blocks enable multiple parties to effectively record data and check the recorded data (i.e., anti-fake). Based on this, more and more users prefer to record transaction data in a blockchain. However, as time goes by, the data volume corresponding to the data stored in the blockchain will become larger and larger, which brings great storage pressure to the storage space used to store the blockchain and affects the normal operation of the blockchain network to which the blockchain belongs. SUMMARY

[0003] The technical problem to be solved by the embodiments of the present application is to provide a data processing method and device based on a blockchain, equipment and a storage medium, which can ensure that a business is processed normally.

[0004] The embodiments of the present application provide, on one hand, a data processing method based on a blockchain, comprising:

[0005] obtaining attribute information of a block on a blockchain;

[0006] identifying a target block in a redundant state from the blockchain according to the attribute information of the block;

[0007] backing up the target block into a first storage space and deleting transaction data in the target block on the blockchain; the first storage space is different from a second storage space used to store the blockchain;

[0008] if an acquisition request for the transaction data in the target block is received, restoring the transaction data in the target block to the blockchain according to the target block backed up in the first storage space;

[0009] reading transaction data from the target block restored from the blockchain.

[0010] The embodiments of the present application provide, on one hand, a data processing device based on a blockchain, comprising:

[0011] an obtaining module configured to obtain attribute information of a block on a blockchain;

[0012] an identifying module configured to identify a target block in a redundant state from the blockchain according to the attribute information of the block;

[0013] a deletion module, configured to backup the target block to a first storage space and delete transaction data in the target block on the block chain; the first storage space is different from a second storage space used to store the block chain;

[0014] a recovery module, configured to, if an acquisition request for the transaction data in the target block is received, recover the transaction data in the target block to the block chain according to the target block backed up in the first storage space;

[0015] a reading module, configured to read the transaction data in the recovered target block from the block chain.

[0016] Optionally, the deletion of the target block to the first storage space and the deletion of the transaction data in the target block on the block chain comprises:

[0017] acquiring statistical characteristics of the target block and state information of a node device in a block chain network to which the block chain belongs;

[0018] selecting a consensus node from the node device in the block chain network according to the statistical characteristics of the target block and the state information;

[0019] sending a deletion verification request for the target block to the consensus node; the deletion verification request is used to instruct the consensus node to verify the legality of the deletion operation of the target block;

[0020] acquiring a consensus result of the deletion operation of the target block from the consensus node;

[0021] if the consensus result indicates that the deletion operation of the target block is legal, backing up the target block to the first storage space and deleting the transaction data in the target block on the block chain.

[0022] Optionally, the deletion module selects the consensus node from the node device in the block chain network according to the statistical characteristics of the target block and the state information, comprising:

[0023] generating a serial number of the node device in the block chain network according to the state information;

[0024] generating a consensus random number according to the statistical characteristics of the target block;

[0025] determining the node device in the block chain network whose serial number is an integer multiple of the consensus random number as the consensus node.

[0026] Optionally, the target block comprises a block header and a block body, the block body comprising transaction data in the target block, and the block header comprising block information of the target block; the deleting module, if the consensus result indicates that the deleting operation on the target block is legal, backs up the target block into a first storage space and deletes the transaction data in the target block on the block chain, comprising:

[0027] If the consensus result indicates that the deleting operation on the target block is legal, determining location information of the target block on the block chain according to the block header of the target block;

[0028] Backing up the block header and the block body of the target block into the first storage space;

[0029] Deleting the block body in the target block on the block chain, and retaining the block header of the target block on the block chain according to the location information of the target block on the block chain.

[0030] Optionally, the restoring module restores the transaction data in the target block to the block chain according to the target block backed up in the first storage space, comprising:

[0031] Verifying validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, obtaining a verification result;

[0032] If the verification result indicates that the block body of the target block backed up in the first storage space is valid, determining location information of the target block on the block chain according to the block header of the target block backed up in the first storage space;

[0033] Restoring the block body of the target block backed up in the first storage space to the block chain according to the location information of the target block on the block chain.

[0034] Optionally, the block header of the target block on the block chain comprises a first current block hash value; the restoring module verifies validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, obtaining a verification result, comprising:

[0035] Reading a second current block hash value comprised in the block header of the target block from the first storage space;

[0036] Comparing the first current block hash value with the second current block hash value, obtaining a first comparison result;

[0037] If the first comparison result indicates that the first current block hash value is the same as the second current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid.

[0038] A verification result indicating that the block body of the target block backed up in the first storage space is valid is generated.

[0039] Optionally, the block header of the target block on the block chain includes a first current block hash value; the recovery module verifies the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, and obtains a verification result, including:

[0040] A third current block hash value is generated according to the block body of the target block backed up in the first storage space;

[0041] The first current block hash value is compared with the third current block hash value, and a second comparison result is obtained;

[0042] If the second comparison result indicates that the first current block hash value is the same as the third current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid.

[0043] A verification result indicating that the block body of the target block backed up in the first storage space is valid is generated.

[0044] Optionally, the recovery module recovers the block body of the target block backed up in the first storage space to the block chain according to the position information of the target block on the block chain, including:

[0045] The adjacent block of the target block is determined from the block chain;

[0046] The adjacent block of the target block is backed up in the first storage space, and the transaction data in the adjacent block of the target block on the block chain is deleted;

[0047] After the transaction data in the adjacent block is deleted, the block body of the target block backed up in the first storage space is recovered to the block chain according to the position information of the target block on the block chain.

[0048] Optionally, the attribute information includes the number of times that the transaction data in the block is read; the identification module identifies the target block in a redundant state from the block chain according to the attribute information of the block, including:

[0049] determining, from the blockchain, a candidate block whose read frequency is less than a frequency threshold;

[0050] determining a data amount of transaction data stored in the candidate block;

[0051] determining, as a target block in a redundant state, the candidate block whose data amount of stored transaction data is greater than a data amount threshold.

[0052] Optionally, the attribute information includes a block height of the block; and the identification module identifies, from the blockchain, the target block in the redundant state according to the attribute information of the block, including:

[0053] obtaining a maximum block height on the blockchain;

[0054] counting a difference value between the maximum block height and a block height corresponding to a block on the blockchain;

[0055] determining, as the target block in the redundant state, the block on the blockchain whose difference value is greater than a height threshold.

[0056] In an aspect, the present application provides a computer device, comprising: a processor and a memory;

[0057] The memory is configured to store a computer program, and the processor is configured to invoke the computer program to perform the following steps:

[0058] obtaining attribute information of a block on a blockchain;

[0059] identifying, from the blockchain, a target block in a redundant state according to the attribute information of the block;

[0060] backing up the target block into a first storage space, and deleting transaction data in the target block on the blockchain; the first storage space is different from a second storage space used to store the blockchain;

[0061] if an obtaining request for the transaction data in the target block is received, restoring the transaction data in the target block to the blockchain according to the target block backed up in the first storage space;

[0062] reading transaction data from the target block restored from the blockchain. In an aspect, the present application provides a computer readable storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, perform the following steps:

[0063] obtaining attribute information of a block on a blockchain;

[0064] identify a target block in a redundant state from the block chain according to attribute information of the block;

[0065] backup the target block into a first storage space, and delete transaction data in the target block on the block chain; the first storage space is different from a second storage space used to store the block chain;

[0066] if an acquisition request for the transaction data in the target block is received, restore the transaction data in the target block to the block chain according to the target block backed up in the first storage space;

[0067] read the transaction data from the target block restored from the block chain.

[0068] In the present application, the target block in the redundant state is identified according to the attribute information of the block, the target block is backed up into the first storage space, and the transaction data in the target block on the block chain is deleted; this is conducive to relieving the data storage pressure on the block chain, i.e., relieving the storage pressure of the second storage space used to store the block chain, and can ensure the normal operation of the block chain network to which the block chain belongs. At the same time, by backing up the target block, the problem that the transaction data in the target block cannot be read when the transaction data in the target block needs to be used in the future can be avoided, and the business related to the transaction data in the target block can be ensured to be processed normally. Further, when the transaction data in the target block needs to be used, the transaction data in the target block is restored to the block chain through the target block backed up in the first storage space, and the transaction data is read from the target block restored from the block chain; this is conducive to preventing the transaction data from being tampered with, improving the credibility and security of the transaction data. At the same time, the process of reading the transaction data from the block chain is witnessed by each node device in the block chain, which can effectively prevent non-authorized users from reading the transaction data from the block chain and prevent the transaction data from being leaked. BRIEF DESCRIPTION OF DRAWINGS

[0069] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative labor.

[0070] Figure 1 is a system architecture schematic diagram of a block chain network provided by the present application;

[0071] Figure 2 is a schematic diagram of a block chain provided by the present application;

[0072] Figure 3 is a flowchart of a process of generating a block on a blockchain provided by the present application;

[0073] Figure 4a is a scenario diagram of archiving and restoring transaction data on a blockchain by a node device in a blockchain network provided by the present application;

[0074] Figure 4b is a diagram of a Merkle Patricia tree provided by an embodiment of the present application;

[0075] Figure 4c is a scenario diagram of archiving and restoring transaction data on a blockchain by a node device in a blockchain network provided by the present application;

[0076] Figure 5 is a flowchart of a data processing method based on a blockchain provided by the present application;

[0077] Figure 6 is a flowchart of a data processing method based on a blockchain provided by the present application;

[0078] Figure 7 is a scenario diagram of verifying the validity of a target block backed up by a first storage space provided by the present application;

[0079] Figure 8 is a scenario diagram of verifying the validity of a target block backed up by a first storage space provided by the present application;

[0080] Figure 9 is a scenario diagram of verifying the validity of a target block backed up by a first storage space provided by the present application;

[0081] Figure 10 is a structural diagram of a data processing apparatus based on a blockchain provided by an embodiment of the present application;

[0082] Figure 11 is a structural diagram of a computer device provided by an embodiment of the present application. DETAILED DESCRIPTION

[0083] The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative labor fall within the scope of the present application.

[0084] The embodiment of the present application provides a scheme for recovering deleted data, which can save the storage space of a disk, reduce the storage pressure of the storage space, and ensure the normal operation of a blockchain network to which the blockchain belongs by deleting part of data on the blockchain. Meanwhile, when the deleted data is needed, the deleted data is recovered to the blockchain, so that the business can be normally processed, and the effectiveness and credibility of data acquisition can be improved.

[0085] First, the blockchain network to which the present scheme is applied is introduced, please refer to Figure 1 , Figure 1 A structural schematic diagram of a blockchain network provided by the embodiment of the present application. The blockchain network is an end-to-end decentralized network composed of multiple node devices, the number of node devices in the blockchain network can be deployed according to actual needs, and the number of node devices is not limited in the present application; for example Figure 1 four node devices in the blockchain network are taken as an example for illustration, and the four node devices are node device 101, node device 102, node device 103 and node device 104. It should be noted that the blockchain network in the present application can be a consortium chain-based blockchain network (such as a Fabric-based consortium chain blockchain network), and the consortium chain is a blockchain network participated by multiple organizations or institutions. That is, the consortium chain is a cluster composed of multiple private chains, and the blockchain network is managed by multiple institutions, each organization or institution manages one or more node devices, and the data is only allowed to be read, written and sent by different institutions in the system. In addition, each node device of the consortium chain usually has a corresponding entity organization, and can only join or exit the network after authorization. The organizations form an interest-related consortium and jointly maintain the healthy operation of the blockchain. Specifically, the consortium chain-based blockchain network has the following characteristics:

[0086] (1) In one embodiment, the consensus algorithm in the consortium chain-based blockchain network can be customized by the management node device in the consortium chain-based blockchain network, and the management node device can be obtained by the node device in the consortium chain-based blockchain network according to the institution attribute of each institution, the institution attribute including one or more of institution credit level, institution asset amount, institution generation time, etc. In another embodiment, the consensus algorithm in the consortium chain-based blockchain network can be customized by each node device in the consortium chain-based blockchain network.

[0087] (2) The consensus algorithm in this application is followed by each node device in the consortium chain-based blockchain network, for example, the consensus algorithm stipulates the deletion condition for deleting transaction data on the blockchain, when any node device in the consortium chain-based blockchain network needs to delete transaction data in the target block on the blockchain, the consensus node device in the consortium chain-based blockchain network needs to verify the legality of the deletion operation according to the consensus algorithm, if the deletion operation meets the deletion condition in the consensus algorithm, it is determined that the deletion operation is legal, and the transaction data in the target block on the blockchain can be deleted.

[0088] (3) Partial decentralization. Unlike public blockchain networks, consortium chain-based blockchain networks belong to the members of the consortium to some extent, and consensus is easy to reach because the number of node devices of the consortium chain is very limited.

[0089] (4) Strong controllability. Once the blockchain is formed, the public blockchain network cannot be tampered with, which is mainly due to the fact that the number of node devices of the public blockchain network is generally massive, and it is almost impossible to tamper with the data on the blockchain, while in the consortium chain-based blockchain network, as long as a majority of all institutions reach a consensus, the transactions on the blockchain can be changed (such as deleted).

[0090] (5) Data is not publicly available by default. Unlike public blockchain networks, data in consortium chain-based blockchain networks is only accessible to institutions and their users within the consortium.

[0091] It can be understood that each node device can receive data to be recorded when working normally, and maintain the blockchain based on the received data to be recorded. In order to ensure information exchange within the blockchain network, each node device in the blockchain network can have a network connection 10 between the node devices, and the node devices can transmit data through the network connection 10. For example, when any node device in the blockchain network receives data to be recorded, other node devices in the blockchain network verify the data to be recorded according to the consensus algorithm, and store the data to be recorded as data in the blockchain after successful verification (i.e. after reaching a consensus), so that the data stored on all node devices in the blockchain network is consistent.

[0092] Node devices 101, 102, 103, and 104 can each 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 node devices can be directly or indirectly connected via wired or wireless communication; this application does not impose any restrictions on this connection.

[0093] Among them, the blockchain maintained by each node device is as follows: Figure 2 As shown, this blockchain consists of multiple blocks, each block including a block header and a block body. Figure 2 This example uses a blockchain with four blocks: B0, B1, B2, and B3. Block B0, also known as the genesis block, is the earliest block generated on the blockchain. Genesis block B0 includes a block header H0 and a block body D0. The block header H0 stores block information, including the version number, block height, timestamp, difficulty, and current block hash. The block body D0 stores transaction data. The next block, B1, is the parent block of genesis block B0. Block B1 also includes a block header H1 and a block body D1. The block header H1 stores the current block hash, the parent block hash, version number, block height, timestamp, and difficulty. The block body D1 stores transaction data T1 through T4. Figure 2 In the blockchain, the next block B2, which is the parent block of block B1, includes a block header H2 and a block body D2. Block body D2 contains transaction data T5-T7. The next block B3, also a parent block of block B2, includes a block header H3 and a block body D3. Block body D3 contains transaction data T8-T9. This demonstrates that the block data stored in each block is related to the block data stored in its parent block, ensuring the security of the data within each block. It should be noted that each block can also include block metadata, which describes basic block information such as how the block was generated. This metadata can be located in the block body or in a designated area within the block, which can be any area within the block other than the block body and block header. Figure 2As shown, the metadata of the block B0, the block B1, the block B2 and the block B3 are M0, M1, M2 and M3 respectively, which are located in the block body of the corresponding block; the block metadata M0 of the genesis block B0 is used to describe how the genesis block B0 is generated. Similarly, the block metadata M1 of the block B1 is used to describe how the block B1 is generated. Similarly, the similarities are not described in detail.

[0094] When generating each block in the block chain, the node device where the block chain is located receives the transaction data, checks the transaction data, stores the transaction data into the memory pool after the checking is completed, and updates the hash tree for the transaction data; here the hash tree can be a Merkle tree, a Patricia tree, a Merkle Patricia Tree (MPT) tree, etc., then the update timestamp is updated to the time when the transaction data is received, the block height is increased by 1, and different random numbers are tried to perform feature value calculation multiple times, so that the calculated feature value can satisfy the following formula:

[0095] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET

[0096] Wherein, SHA256 is a feature value algorithm used for calculating the feature value; version (version number) is the version information of the relevant block protocol in the block chain; prev_hash is the hash value of the parent block of the current block; merkle_root is the hash value of the current block; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a constant value within a period of time, and is determined again after a fixed period of time; x is a random number; TARGET is a feature value threshold, which can be determined according to nbits.

[0097] In this way, when the random number satisfying the above formula is calculated, the information is stored correspondingly, the block header and the block body are generated, and the current block is obtained. Subsequently, the node device where the block chain is located sends the newly generated block to other nodes in the block chain network, and the other nodes check the newly generated block, and add the newly generated block to the stored block chain after the checking is completed.

[0098] For ease of understanding, further, please refer to Figures 4a-4c As shown in FIG. 1, which is a scene diagram of data interaction provided by an embodiment of the present application. As shown in FIG. 1, Figure 4a As shown in FIG. 1, Figure 4a The node device in FIG. 1 can be Figure 1Any of the node devices in the blockchain, the node device has a disk 1 in which the blockchain is stored, the blockchain in the disk 1 includes 102 blocks, which are block B0~block 101 respectively, the node device can obtain the attribute information of each block on the blockchain, the attribute information of the block includes one or more of the block height of the block, the number of times the transaction data in the block is read, the number of times the transaction data in the block is updated, the generation time of the block and the like. The node device can identify the target block in the redundant state on the blockchain according to the attribute information of the block, the target block refers to the block on the blockchain whose transaction data is read (i.e. used) with a lower probability, specifically, the target block can refer to the block on the blockchain whose time interval between the generation time and the current time is greater than the time interval threshold, or the target block can refer to the block on the blockchain whose historical reading frequency is less than the frequency threshold, or the target block can refer to the block on the blockchain whose update frequency is greater than the frequency threshold, or the target block can refer to the block on the blockchain whose block height is greater than the block height threshold, and the like.

[0099] As shown in Figure 4a In the blockchain, the node device can delete the transaction data in the block B1~block B3 on the blockchain, and backup the block B1~block B3 to the disk 2. The disk 2 can refer to the disk in the node device other than the disk 1, or the disk 2 can refer to the disk in the backup device of the node device. Figure 4a In the disk 2, the block B1~block B3 can be backed up in a chained manner, or the block B1~block B3 can be backed up in a non-chained manner.

[0100] It should be noted that the specific implementation of the node device deleting the transaction data in the block B1~block B3 on the blockchain includes: retaining the block header of the block B1~block B3 on the blockchain, and deleting the block body of the block B1~block B3 on the blockchain; that is, the block header of the block B1~block B3 is kept unchanged, which can make the blocks on the blockchain still connected in the form of a blockchain. Generally, when the transaction data in a certain block on the blockchain changes, the current block hash value in the block will also change, and then the blocks after the block cannot be stored in the form of a blockchain, and the security of the transaction data in the blocks after the block cannot be ensured. Based on this, the present scheme ensures that the current block hash value in the target block does not change after deleting the transaction data in the target block, i.e. the blocks after the target block are still stored in the form of a blockchain, which can improve the security of the transaction data on the blockchain.

[0101] Method a: the node device includes a smart contract, which stipulates that when the node device detects the deletion of transaction data in the target block, the block header of the target block is kept unchanged on the blockchain.

[0102] Method b: the transaction data in the block on the blockchain is stored based on the data storage structure of the Merkle Patricia tree, and the transaction data in the block is stored in the leaf node of the Merkle Patricia tree of the blockchain; the Merkle Patricia tree further includes an extension node and a branch node, the extension node includes a hash value of the branch node, and the extension node is connected with the branch node; the leaf node includes a key value and transaction data corresponding to the key value, the branch node is connected with the leaf node, the key value of the leaf node is composed of a key-end element in the leaf node, an element connected with the first 16 elements in the branch node and a shared element in the extension node, the key-end element in the leaf node is different from the transaction data corresponding to the key value included in the leaf node, and the data corresponding to the element connected with the first 16 elements in the branch node is the key value corresponding to the hexadecimal character of the leaf node; the key value refers to the transaction data in the leaf node. The current block hash of the block can refer to the hash value in the extension node, which can be generated according to the identifier of the branch node, and the current block hash value is irrelevant to the transaction data in the block body. Therefore, after deleting the transaction data in the block body, the current block hash value of the block will not be affected, and it can be ensured that after deleting the transaction data, each block is still stored in the form of a blockchain, thereby improving the security of the transaction data.

[0103] The Merkel Patricia tree refers to a data storage structure for storing data in a block. The storage structure generally includes branch nodes, extension nodes, and leaf nodes. Leaf nodes: have no child nodes and include a key-value pair [key, value], where key can be one or more elements of the identification (i.e., key value) of the transaction data recorded in the block, which is a hexadecimal code, and value refers to a transaction data recorded in the block. Extension nodes: also include a key-value pair [key, value], but the value here is the hash value of other nodes. This hash can be used to query other nodes in the Merkel Patricia tree, that is, it is linked to other nodes through the hash, and the hash is irrelevant to the transaction data in other nodes. The hash can be generated according to the identification of other nodes. Branch node: a 17-character string, the first 16 elements correspond to the 16 possible hexadecimal characters in key. If the node has a pair [key, value], the last element in the 17-character string represents value, that is, the branch node can search for the termination of the path or be an intermediate node of the path. That is, when the transaction data needs to be recorded in the block, first generate the target key value (i.e., key) of the transaction data, establish the nodes of the Merkel Patricia tree according to the key value of the transaction data, and record the transaction data in the established nodes. For example, when the transaction data (i.e., value) to be recorded is 10, 102, 1.1, and 0.12, the node device can generate the key value of these transaction data, that is, each value corresponds to a key, and the correspondence between value and key is shown in Table 1.

[0104] Table 1:

[0105] Key value a711355 10 a77d337 102 a7f9365 1.1 a77d397 0.12

[0106] It can be seen that these key values share the element a7, and a77d337 and a77d397 share the element a77d3. The Merkel Patricia tree can be established according to the shared relationship between these key values, Figure 4bAs shown in the figure, the Merkel Patricia tree includes 2 extension nodes, 4 leaf nodes, and 2 branch nodes. The value recorded in the leaf node 1 is 10, and the key corresponding to the value is composed of the element 1355 in the leaf node 1, the element 1 in the branch node 1, and the element a7 in the extension node 1, that is, the key corresponding to the value is recorded in the leaf node 1, the branch node 1, and the extension node 1. Similarly, the value recorded in the leaf node 2 is 1.1, and the key corresponding to the value is composed of the element 9365 in the leaf node 2, the element f in the branch node 1, and the element a7 in the extension node 1, that is, the key corresponding to the value is recorded in the leaf node 2, the branch node 1, and the extension node 1. Of course, the value here can refer to the transaction data to be recorded or the encoded value of the transaction data to be recorded. For other value values, refer to the description of the value 10 and the value 1.1, and the repeated parts are not described herein. Among them, the prefix in the node of the Merkel Patricia tree refers to the node identifier, that is, 0 indicates that the node is an extension node, and 2 and 3 both indicate that the node is a leaf node. When it is necessary to delete the transaction data in the target block, the node device can delete the transaction data (i.e., value) stored in the leaf node in the Merkel Patricia tree of the target block; the key value remains unchanged.

[0107] It can be seen that the difference between the above-mentioned mode a and mode b is that the current block hash value of the block on the blockchain in mode a is generated according to the transaction data in the block, that is, the current block hash value of the block is related to the transaction data in the block, and when the transaction data in the block is deleted, the current block hash value of the block is controlled to be unchanged through the smart contract. In mode b, the current block hash of the block can refer to the hash value in the extension node of the Merkel Patricia tree, which can be generated according to the identifier (i.e., key) of the branch node, which is irrelevant to the transaction data in the block, that is, the current block hash value of the block on the blockchain is irrelevant to the transaction data in the block, and when the transaction data in the block is deleted, the current block hash value of the block is unchanged.

[0108] Further, if a request for obtaining the transaction data in the deleted block is received, the node device can restore the deleted block to the blockchain, and read the transaction data from the block restored from the blockchain. As shown in the figure, Figure 4c As shown in the figure, if a request for obtaining the transaction data in the block B2 is received, the node device can restore the block B2 backed up in the disk 2 to the blockchain in the disk 1 according to the request, read the transaction data from the block B2 on the blockchain in the disk 1, and delete the block B2 in the disk 2 after the transaction data in the block B2 backed up in the disk 2 is restored to the blockchain.

[0109] In summary, by deleting the transaction data in the target block in a redundant state on the blockchain and backing up the target block in other disks, the storage pressure of the storage space for storing the blockchain is reduced, and the normal operation of the blockchain network to which the blockchain belongs is ensured. When the transaction data in the target block is needed, the transaction data of the target block backed up in other disks can be restored to the blockchain, and the transaction data in the target block restored from the blockchain is read. Compared with directly obtaining the transaction data of the target block from other disks, the transaction data restored from the blockchain is read, and the recovery process of the transaction data in the target block is witnessed by each node device in the blockchain network, which can improve the credibility and security of data acquisition, and at the same time, ensure that the related business of the transaction data in the target block is normally processed.

[0110] Further, please refer to Figure 5 is a flowchart of a data processing method based on a blockchain provided by an embodiment of the present application. As Figure 5 shown, the method can be executed by Figure 1 any node device, wherein the method can at least include the following S101-S104:

[0111] S101, obtain the attribute information of the block on the blockchain.

[0112] In the present application, the node device can periodically obtain the attribute information of the block on the blockchain according to the time interval, or the node device can obtain the attribute information of the block on the blockchain when receiving the writing of transaction data to the blockchain, or the node device can obtain the attribute information of the block on the blockchain when the remaining storage space of the second storage space for storing the blockchain is less than the storage space threshold. The attribute information of the block includes one or more of the block height of the block, the institution to which the transaction data in the block belongs, the number of times the transaction data in the block is read, the number of times the transaction data in the block is updated, the generation time of the block, etc. The attribute information of the block is helpful to identify the target block in a redundant state.

[0113] S102, identifying the target block in a redundant state from the blockchain according to the attribute information of the block.

[0114] In the present application, the node device can identify the target block in a redundant state from the blockchain according to the attribute information of the block, that is, the target block can specifically refer to the block in which the probability of using the transaction data on the blockchain is relatively low.

[0115] Optionally, the attribute information includes a number of times that transaction data in the block is read; the node device can identify the target block in the redundancy state according to the number of times that the transaction data in the block is read; specifically, the step S102 can include steps s11-s13 as follows:

[0116] s11, determining a candidate block with a number of times of reading less than a number threshold from the blockchain.

[0117] s12, determining a data amount of the transaction data stored in the candidate block.

[0118] s13, determining the candidate block with the data amount of the stored transaction data greater than a data amount threshold as the target block in the redundancy state.

[0119] In steps s11-s13, the block usually includes one or more pieces of transaction data; when the block includes one piece of transaction data, the number of times that the transaction data in the block is read refers to the number of times that the piece of transaction data is read; when the block includes multiple pieces of transaction data, the number of times that the transaction data in the block is read can refer to the total number, the average number or the maximum number of times that the transaction data in the block is read, etc. If the number of times that the transaction data in the block is read is greater, it indicates that the probability that the transaction data in the target block is used is higher; if the number of times that the transaction data in the block is read is smaller, it indicates that the probability that the transaction data in the target block is used is lower. Therefore, the node device can identify the target block in the redundancy state according to the number of times that the transaction data in the block is read; specifically, the node device can determine a candidate block with a number of times of reading less than a number threshold from the blockchain, and determine a data amount of the transaction data stored in the candidate block. The greater the data amount in the candidate block, the greater the storage pressure brought to the blockchain, and vice versa; therefore, the node device can determine the candidate block with the data amount of the stored transaction data greater than a data amount threshold as the target block in the redundancy state. The target block in the redundancy state is identified through the number of times that the transaction data in the block is read and the data amount in the block, that is, the target block in the redundancy state is identified through multiple dimensions, thereby improving the accuracy of identifying the target block.

[0120] Optionally, the attribute information includes a block height of the block; the node device can identify the target block in the redundancy state according to the block height of the block from the blockchain, specifically, the step S102 can include steps s21-s23 as follows:

[0121] s21, obtaining a maximum block height on the blockchain.

[0122] s22, calculate a difference between the maximum block height and a block height corresponding to a block on the blockchain.

[0123] s23, determine a block on the blockchain with a difference greater than a height threshold as a target block in a redundant state.

[0124] In steps s21-s23, the block height of a block can be used to reflect the generation time of the block to some extent, that is, the earlier the generation time of the block, the smaller the block height of the block, and the later the generation time of the block, the greater the block height of the block. For example, the block height of the genesis block is 0, and the block height of the next block of the genesis block is 1. Therefore, if the block height of a block is greater, it indicates that the generation time of the block is relatively late, that is, the probability of updating the transaction data in the block is relatively small, that is, the probability of using the transaction data in the block is higher; on the contrary, if the block height of a block is smaller, it indicates that the generation time of the block is relatively early, that is, the probability of updating the transaction data in the block is relatively large, that is, the probability of storing the updated transaction data on the blockchain is relatively large, that is, the probability of using the transaction data in the block is lower. Therefore, the node device can obtain the maximum block height on the blockchain, calculate the difference between the maximum block height and the block height corresponding to the block on the blockchain; the greater the difference, the smaller the block height of the block, and the lower the probability of using the transaction data in the block; the smaller the difference, the greater the block height of the block, and the higher the probability of using the transaction data in the block. Therefore, the node device can determine a block on the blockchain with a difference greater than a height threshold as a target block in a redundant state. By identifying the target block in the redundant state from the blockchain according to the block height of the block, it is beneficial to identify the transaction data with a lower probability of use, and to use the block to which the transaction data with a lower probability of use belongs as a target block, thereby reducing the impact on business processing after deleting the target block.

[0125] Optionally, the blockchain belongs to a consortium chain-based blockchain network, and the attribute information includes an institution to which transaction data in the block belongs; the node device can identify a target block in a redundant state from the blockchain according to the institution to which the transaction data in the block belongs. Specifically, the step S102 can include: obtaining a target institution that exits the consortium chain-based blockchain network, and determining a block in which transaction data on the blockchain belongs to the target institution as a target block in a redundant state. That is, if the target institution exits the consortium chain-based blockchain network, it indicates that the probability of using the transaction data of the target institution again is relatively low, and therefore, the block in which the transaction data on the blockchain belongs to the target institution is determined as the target block in a redundant state, which is beneficial to reducing the redundancy of the blockchain. In S103, the target block is backed up to a first storage space, and the transaction data in the target block on the blockchain is deleted; the first storage space is different from a second storage space used to store the blockchain.

[0126] In the present application, if the target block is stored on the blockchain for a long time, the storage pressure of the second storage space is increased, which causes new transaction data to be unable to be stored on the blockchain. Based on this, the node device can back up the target block to the first storage space and delete the transaction data in the target block on the blockchain; the data storage pressure on the blockchain, i.e., the storage pressure of the second storage space, can be reduced; at the same time, by backing up the target block, it is beneficial to restore the transaction data in the target block when the transaction data in the target block is needed.

[0127] It should be noted that the first storage space refers to a storage space used to back up blocks, and the second storage space can refer to a storage space used to store a blockchain. The first storage space and the second storage space can be located in the same node device or different node devices. The first storage space and the second storage space can specifically refer to a disk or a storage medium array, and the present application does not limit this.

[0128] In S104, if an acquisition request for the transaction data in the target block is received, the transaction data in the target block is restored to the blockchain according to the target block backed up in the first storage space.

[0129] It should be noted that, in order to quickly find the transaction data in the target block, the node device can generate index information of the transaction data in the target block. The index information is used to reflect the storage address of the transaction data in the target block; for example, when the transaction data in the target block is stored on the blockchain, the index information of the transaction data in the target block is used to indicate that the storage address of the transaction data in the target block is the blockchain (or the second storage space), and when the transaction data in the target block is backed up in the first storage space, the index information of the transaction data in the target block is used to indicate that the storage address of the transaction data in the target block is the first storage space.

[0130] Specifically, when the node device includes the index information of the transaction data in the target block, step S104 can include: obtaining the index information of the transaction data in the target block, when the index information indicates that the transaction data in the target block is stored in the first storage space, restoring the transaction data in the target block to the blockchain according to the target block backed up by the first storage space, and after the transaction data in the target block is restored to the blockchain, the updated index information can be obtained according to the index information of the transaction data in the target block, and the updated index information is used to indicate that the storage address of the transaction data in the target block is the blockchain. By generating the index information of the transaction data in the target block, the efficiency of querying the transaction data can be effectively improved.

[0131] S105, reading the transaction data from the target block restored from the blockchain.

[0132] In steps S104-S105, if a request for obtaining the transaction data in the target block is received, it indicates that the transaction data in the target block is needed to process the business, therefore, the node device can restore the transaction data in the target block to the blockchain according to the target block backed up by the first storage space. Specifically, the request for obtaining can include the block height of the target block, the target block is searched from the first storage space according to the block height of the target block, the transaction data in the target block is restored to the original position on the blockchain according to the block header of the target block, and the original position can refer to the storage position of the target block on the blockchain before the transaction data in the target block is deleted; then, the transaction data is read from the target block restored from the blockchain. By restoring the deleted transaction data to the blockchain, it is beneficial to ensure that the business related to the transaction data is processed normally, and by reading the transaction data from the target block restored from the blockchain, it is beneficial to prevent the transaction data from being tampered, improve the credibility and security of the transaction data.

[0133] In the present application, the target block in the redundant state is identified according to the attribute information of the block, the target block is backed up to the first storage space, and the transaction data in the target block on the block chain is deleted; it is beneficial to alleviate the data storage pressure on the block chain, that is, to alleviate the storage pressure of the second storage space for storing the block chain, and to ensure the normal operation of the block chain network to which the block chain belongs. By backing up the target block, the problem that the transaction data in the target block cannot be read when the transaction data in the target block is needed to be used in the future can be avoided, and the business related to the transaction data in the target block can be ensured to be normally processed. When the transaction data in the target block is needed to be used, the transaction data in the target block is recovered to the block chain through the target block backed up in the first storage space, and the transaction data is read from the target block recovered from the block chain; by reading the transaction data from the target block recovered from the block chain, it is beneficial to prevent the transaction data from being tampered with, improve the credibility and security of the transaction data. At the same time, the process of reading the transaction data from the block chain is witnessed by each node device in the block chain, which can effectively prevent illegal users from reading the transaction data from the block chain, and can prevent the transaction data from being leaked.

[0134] Further, please refer to Figure 6 is a flowchart of a data processing method based on a block chain provided by an embodiment of the present application. As Figure 6 indicated, the method can be executed by Figure 1 any node device, and the method can at least include the following S201-S209:

[0135] S201, attribute information of a block on a block chain is acquired.

[0136] S202, a target block in a redundant state is identified from the block chain according to the attribute information of the block.

[0137] S203, statistical characteristics of the target block and state information of a node device in a block chain network to which the block chain belongs are acquired.

[0138] In the present application, the state information includes one or more of the current remaining power of the node device of the block chain network, electronic resources in the device identifier, the number of installed application programs, and the number of times of being selected as a consensus node. The electronic resources can be virtual goods, virtual currencies, etc. The statistical characteristics include one or more of the number of transaction data in the target block belonging to a target institution, the total amount of data of the transaction data in the target block, and the transaction address associated with the transaction data in the target block. The target institution can be an institution with the most transaction data in the target block, or the target institution can be a designated institution.

[0139] S204, selecting a consensus node from the node devices in the block chain network according to the statistical characteristics of the target block and the state information.

[0140] In the present application, if the consensus nodes in the block network are fixed, the consensus nodes are easily invaded by illegal users, resulting in inaccurate consensus results output by the consensus nodes. Based on this, the node device can select a consensus node from the node devices in the block chain network according to the statistical characteristics of the target block and the state information of the node device. Since the statistical characteristics of different blocks are different, and the state information of the node device is dynamically changing, the consensus node selected according to the statistical characteristics of the target block and the state information of the node device is also dynamically changing, which can avoid the problem of inaccurate consensus results caused by fixed consensus nodes, and improve the accuracy and fairness of the consensus results.

[0141] It should be noted that the node device can select a consensus node from the node devices in the block chain network in any one of the following three ways: way one: the node device can select a consensus node from the node devices in the block chain network according to the statistical characteristics of the target block and the state information of the node devices in the block chain network. Way two: the node device can select a consensus node from the node devices in the block chain network according to the statistical characteristics of the target block. Way three: the node device can select a consensus node from the node devices in the block chain network according to the state information of the node devices in the block chain network.

[0142] Optionally, when the node device selects a consensus node in way one, the above step S204 can include the following steps s31-s33:

[0143] s31, generating a serial number of the node devices in the block chain network according to the state information.

[0144] s32, generating a consensus random number according to the statistical characteristics of the target block.

[0145] s33, determining the node devices in the block chain network whose serial numbers are integer multiples of the consensus random number as consensus nodes.

[0146] In steps s31-s33, the node device can sort the node devices in the block chain network according to the state information, and generate the serial numbers of the node devices in the block chain network according to the sorting order. Further, a consensus random number is generated according to the statistical characteristics of the target block, and the node devices in the block chain network whose serial numbers are integer multiples of the consensus random number are determined as consensus nodes. By dynamically selecting consensus nodes according to information in multiple dimensions (i.e., the statistical characteristics of the target block and the state information of the node device), the randomness of the consensus nodes is improved, and the accuracy and fairness of the consensus results are improved.

[0147] Optionally, when the node device selects the consensus node in the second mode, the node device can generate a consensus random number according to the statistical characteristics of the target block, obtain the serial number of the node device in the blockchain network, and the serial number of the node device in this case is different from the serial number of the node device in the first mode. The serial number of the node device in this mode is fixed and unchangeable, and the serial number of the node device in the first mode is determined according to the state information of the node device, i.e., the serial number of the node device is dynamically changed. Further, the node device with an integer multiple of the consensus random number in the blockchain network is taken as the consensus node. By dynamically selecting the consensus node according to the statistical characteristics of the target block, the randomness of the consensus node can be improved, and the accuracy and fairness of the consensus result can be improved.

[0148] Optionally, when the node device selects the consensus node in the third mode, the consensus weight of each node device is generated according to the state information of the node device in the blockchain network, the node devices in the blockchain network are sorted in descending order of the consensus weight, and the node device with a serial number less than a serial number threshold is taken as the consensus node. By dynamically selecting the consensus node according to the state information of the node device, the randomness of the consensus node can be improved, and the accuracy and fairness of the consensus result can be improved.

[0149] S205, a deletion verification request for the target block is sent to the consensus node; the deletion verification request is used to indicate the consensus node to verify the legality of the deletion operation for the target block.

[0150] S206, a consensus result of the deletion operation for the target block is obtained from the consensus node.

[0151] S207, if the consensus result indicates that the deletion operation for the target block is legal, the target block is backed up to the first storage space, and the transaction data in the target block on the blockchain is deleted.

[0152] In steps S205-S207, a node device may send a deletion verification request for the target block to a consensus node. This deletion verification request instructs the consensus node to verify the legality of the deletion operation for the target block. Each consensus node verifies the legality of the deletion operation for the target block and returns a verification result to the node device. If more than 50% of the node devices return a verification result indicating that the deletion operation for the target block is legal, a consensus result indicating that the deletion operation for the target block is legal is generated; if less than 50% of the node devices return a verification result indicating that the deletion operation for the target block is legal, a consensus result indicating that the deletion operation for the target block is not legal is generated. Further, if the consensus result indicates that the deletion operation for the target block is legal, the target block is backed up to the first storage space, and the transaction data in the target block on the blockchain is deleted. By deleting transaction data from a target block only after verifying the legitimacy of the deletion operation, we can prevent unauthorized users from deleting transaction data on the blockchain, thus avoiding the inability to process related business transactions and improving the security of deleting transaction data.

[0153] Optionally, the target block includes a block header and a block body, the block body including transaction data in the target block, and the block header including block information of the target block; step S207 may include the following steps s41 to s43:

[0154] s41. If the consensus result indicates that the deletion operation for the target block is legitimate, then the location information of the target block on the blockchain is determined based on the block header of the target block.

[0155] s42. Back up the block header and block body of the target block to the first storage space.

[0156] s43. Delete the block body of the target block on the blockchain, and retain the block header of the target block on the blockchain according to the position information of the target block on the blockchain.

[0157] In steps s41-s43, if the consensus result indicates that the deletion operation for the target block is legal, the location information of the target block on the block chain is determined according to the block header of the target block, the block header of the target block, i.e., the block body, is backed up to the first storage space, that is, the entire target block is backed up to the first storage space. The block body of the target block on the block chain is deleted, and the block header of the target block is retained on the block chain according to the location information of the target block on the block chain; that is, the transaction data in the target block is deleted, and the block header of the target block is retained at the original position on the block chain; the original position refers to the location of the target block on the block chain. Since the transaction data in the target block occupies a relatively large storage space of the second storage space, by deleting the transaction data in the target block, the storage pressure of the block chain can be reduced; by retaining the block header of the target block on the block chain, it is beneficial to store each block in the form of a block chain, thereby improving the security of data storage. In addition, by backing up the block header and the block body of the target block to the first storage space, it is beneficial to smoothly restore the transaction data in the target block to the block chain, and to ensure that the business related to the transaction data is normally processed.

[0158] It should be noted that when the block body corresponding to the block on the block chain includes the metadata (i.e., M) of the block, the node device can delete the metadata of the target block when deleting the transaction data in the block body of the target block, which is beneficial to alleviate the storage pressure of the storage space for storing the block chain. Alternatively, the node device can retain the metadata of the target block in the block body of the target block when deleting the transaction data in the block body of the target block, which is beneficial to subsequent inquiry of how the target block is generated, has traceability, and can improve the credibility of the target block.

[0159] S208, if the acquisition request for the transaction data in the target block is received, the transaction data in the target block is restored to the block chain according to the target block backed up in the first storage space.

[0160] Optionally, the node device can verify the validity of the backed-up block body of the target block in the first storage space, and when the verification is passed, the transaction data in the backed-up target block is restored to the block chain. Specifically, the above step S208 can include the following steps s51-s53:

[0161] s51, verify the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, and obtain a verification result.

[0162] s52, if the verification result indicates that the block body of the target block backed up in the first storage space is valid, determining, according to the block header of the target block backed up in the first storage space, position information of the target block on the block chain.

[0163] s53, restoring the block body of the target block backed up in the first storage space to the block chain according to the position information of the target block on the block chain.

[0164] In steps s51-s53, the node device can verify the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, and obtain a verification result; the verification result is used to indicate that the block body of the target block backed up in the first storage space is valid, or the verification result is used to indicate that the block body of the target block backed up in the first storage space is not valid. If the verification result indicates that the block body of the target block backed up in the first storage space is not valid, it indicates that the transaction data in the block body of the target block backed up in the first storage space is tampered with, and therefore the block body of the target block can be refused to be restored to the block chain. If the verification result indicates that the block body of the target block backed up in the first storage space is valid, it indicates that the transaction data in the block body of the target block backed up in the first storage space is not tampered with, and therefore the position information of the target block on the block chain can be determined according to the block header of the target block backed up in the first storage space, and the block body of the target block backed up in the first storage space can be restored to the block chain according to the position information of the target block on the block chain. By restoring the backed-up transaction data to the block chain when the backed-up transaction data is verified, it can be ensured that the business related to the transaction data is processed normally, i.e. without affecting the normal processing of the business.

[0165] Optionally, the block header of the target block on the block chain includes a first current block hash value; and the step s51 can include steps s61-s64 as follows:

[0166] s61, reading a second current block hash value included in the block header of the target block from the first storage space.

[0167] s62, comparing the first current block hash value with the second current block hash value to obtain a first comparison result.

[0168] s63, if the first comparison result indicates that the first current block hash value is the same as the second current block hash value, determining that the block body of the target block backed up in the first storage space is valid.

[0169] s64, generating a verification result for indicating that the block body of the target block backed up in the first storage space is valid.

[0170] In steps s61-s64, the node device can take the current block hash value in the target block on the block chain as a first current block hash value, take the current block hash value in the block header of the target block in the first storage space as a second current block hash value. Further, the first current block hash value is compared with the second current block hash value to obtain a first comparison result. If the first comparison result indicates that the first current block hash value is different from the second current block hash value, it is indicated that the transaction data in the block body of the target block backed up in the first storage space is tampered. Therefore, it is determined that the block body of the target block backed up in the first storage space is invalid. A verification result for indicating that the block body of the target block backed up in the first storage space is invalid is generated. If the first comparison result indicates that the first current block hash value is the same as the second current block hash value, it is indicated that the transaction data in the block body of the target block backed up in the first storage space is not tampered. Therefore, it is determined that the block body of the target block backed up in the first storage space is valid. A verification result for indicating that the block body of the target block backed up in the first storage space is valid is generated. By comparing the current block hash value backed up in the first storage space with the current block hash value on the block chain, the validity of the transaction data backed up in the first storage space is verified. The problem that the invalid transaction data tampered is restored to the block chain, resulting in business processing failure and wasting of storage resources of the disk for storing the block chain, etc. can be avoided. It is beneficial to ensure that the business is normally processed and improve the utilization rate of the storage resources of the disk.

[0171] For example, as Figure 7As shown, the disk 1 of the node device stores a blockchain, and the blockchain includes 101 blocks, wherein the blocks B1-B3 are in a redundant state, the transaction data in the blocks B1-B3 is deleted, and the disk 2 of the node device backs up the blocks B1-B3. When receiving an acquisition request for the block B2, the acquisition request can include a block identifier (such as a block height), and the node device can determine the block B2 as the block whose block identifier in the block header in the disk 2 is the same as the block identifier carried in the acquisition request. Further, the block B2 is queried from the blockchain according to the block identifier carried in the acquisition request, and the current block hash value 1 in the block B2 on the blockchain is compared with the current block hash value 2 in the block B2 backed up in the disk 2. If the current block hash value 1 is different from the current block hash value 2, the transaction data in the target block backed up in the disk 2 is refused to be restored into the target block on the blockchain. If the current block hash value 1 is the same as the current block hash value 2, the transaction data in the target block backed up in the disk 2 is restored into the target block on the blockchain.

[0172] It should be noted that each block usually includes one or more transaction data, and therefore, when receiving an acquisition request for part of the target transaction data (such as one target transaction data) in the target block, the node device can restore the target transaction data in the target block backed up in the disk into the target block on the blockchain. For example, as shown in FIG. 1B, the block B2 includes the transaction data T5, the transaction data T6, and the transaction data T7, when receiving an acquisition request for the transaction data T5, the node device can restore the transaction data T5 into the target block on the blockchain, and the transaction data T6 and the transaction data T7 are still backed up in the disk 2. Of course, when receiving an acquisition request for part of the target transaction data in the target block, the node device can restore all the transaction data in the target block backed up in the disk into the target block on the blockchain, which is not limited in the present application. Figure 7

[0173] Optionally, the block header of the target block on the blockchain includes a first current block hash value; and the step s51 can include the following steps s71-s74:

[0174] s71, generating a third current block hash value according to the block body of the target block backed up in the first storage space.

[0175] s72, comparing the first current block hash value with the third current block hash value to obtain a second comparison result.

[0176] s73, if the second comparison result indicates that the first current block hash value is the same as the third current block hash value, determining that the block body of the target block backed up in the first storage space is valid.​

[0177] s74, generating a verification result indicating that the block body of the target block backed up in the first storage space is valid.

[0178] In steps s71-s74, the node device can generate a third current block hash value according to the block body of the target block backed up in the first storage space, i.e., generate a current block hash value according to the transaction data in the block body of the backed-up target block, compare the first current block hash value with the third current block hash value, and obtain a second comparison result. If the second comparison result reflects that the first current hash value is different from the third current hash value, it indicates that the transaction data in the block body of the target block backed up in the first storage space is tampered with. Therefore, it is determined that the block body of the target block backed up in the first storage space is invalid; a verification result indicating that the block body of the target block backed up in the first storage space is invalid is generated. If the second comparison result indicates that the first current block hash value is the same as the third current block hash value, it indicates that the transaction data in the block body of the target block backed up in the first storage space is not tampered with. Therefore, it is determined that the block body of the target block backed up in the first storage space is valid; a verification result indicating that the block body of the target block backed up in the first storage space is valid is generated. By comparing the transaction data backed up in the first storage space with the current block hash value on the block chain, the validity of the transaction data backed up in the first storage space is verified, which can avoid restoring invalid transaction data that is tampered with to the block chain, resulting in business processing failure and wasting of storage resources of the disk used to store the block chain; it is beneficial to ensure that the business is normally processed and improve the utilization rate of the storage resources of the disk.

[0179] For example, as Figure 8As shown, the disk 1 of the node device stores a blockchain, and the blockchain includes 101 blocks, wherein the blocks B1-B3 are in a redundant state, the transaction data in the blocks B1-B3 is deleted, and the disk 2 of the node device backs up the blocks B1-B3. When receiving an acquisition request for the block B2, the acquisition request can include a block identifier (such as a block height), the node device can determine the block B2 as the block whose block identifier in the block header in the disk 2 is the same as the block identifier carried in the acquisition request, calculate the current block hash value of the block B2 according to the transaction data in the block B2, and obtain the current block hash value 3. Further, the block B2 is queried from the blockchain according to the block identifier carried in the acquisition request, the current block hash value 1 in the block B2 on the blockchain is compared with the current block hash value 3, if the current block hash value 1 is different from the current block hash value 3, the transaction data in the target block backed up in the disk 2 is refused to be restored into the target block on the blockchain. If the current block hash value 1 is the same as the current block hash value 3, the transaction data in the target block backed up in the disk 2 is restored into the target block on the blockchain.

[0180] Optionally, the node device can compare the first previous block hash value in the target block on the blockchain with the second previous block hash value in the target block backed up in the first storage space, if the first previous block hash value is the same as the second previous block hash value, it is indicated that the target block found from the blockchain is wrong, or the target block found from the first storage space is wrong, and the transaction data in the target block backed up in the first storage space is refused to be restored onto the blockchain. If the first previous block hash value is different from the second previous block hash value, it is indicated that the target block found from the blockchain is correct, and the target block found from the first storage space is correct, and the transaction data in the target block backed up in the first storage space is restored onto the blockchain.

[0181] For example, as shown in FIG. 6, the disk 1 of the node device stores a blockchain, and the blockchain includes 101 blocks, wherein the blocks B1-B3 are in a redundant state, the transaction data in the blocks B1-B3 is deleted, and the disk 2 of the node device backs up the blocks B1-B3. Figure 9As shown, the disk 1 of the node device stores a blockchain, and the blockchain includes 101 blocks, wherein the blocks B1-B3 are in a redundant state, the transaction data in the blocks B1-B3 is deleted, and the disk 2 of the node device backs up the blocks B1-B3. When receiving an acquisition request for the block B2, the node device can determine the block B2 as the block whose block identifier (such as block height) in the block header in the disk 2 is the same as the block identifier carried in the acquisition request. Further, the node device queries the block B2 from the blockchain according to the block identifier carried in the acquisition request, and compares the previous block hash value 1 in the block B2 in the blockchain with the previous block hash value 2 in the block B2 backed up by the disk 2. If the previous block hash value 1 is different from the previous block hash value 2, the node device refuses to restore the transaction data in the target block backed up by the disk 2 to the target block in the blockchain. If the previous block hash value 1 is the same as the previous block hash value 2, the node device restores the transaction data in the target block backed up by the disk 2 to the target block in the blockchain.

[0182] Optionally, the step s53 can include the following steps s81-s84.

[0183] s81, determining, from the blockchain, a neighboring block of the target block.

[0184] s82, backing up the neighboring block of the target block to the first storage space, and deleting the transaction data in the neighboring block of the target block in the blockchain.

[0185] s83, after the transaction data in the neighboring block is deleted, restoring the block body of the target block backed up in the first storage space to the blockchain according to the position information of the target block in the blockchain.

[0186] In the steps s81-s84, in order to avoid that the target block causes a large storage pressure to the blockchain after the transaction data in the target block is restored to the blockchain, the node device can delete the transaction data in the neighboring block of the target block to reduce the storage pressure of the blockchain. Specifically, the node device can determine, from the blockchain, a neighboring block of the target block, further back up the neighboring block of the target block to the first storage space, and delete the transaction data in the neighboring block of the target block in the blockchain. Then, after the transaction data in the neighboring block is deleted, the node device restores the block body of the target block backed up in the first storage space to the blockchain according to the position information of the target block in the blockchain. When the transaction data in the target block is restored to the blockchain, the storage pressure of the blockchain is reduced by deleting the transaction data in the neighboring block.

[0187] S209, reading transaction data from the target block recovered from the blockchain.

[0188] In the present application, the target block in the redundant state is identified according to the attribute information of the block, the consensus node is selected from the node devices of the blockchain network according to the statistical characteristics of the target block and the state information of the node devices in the blockchain network. The consensus node verifies the legality of the deletion operation of the target block, and when the consensus passes, the target block is backed up to the first storage space, and the transaction data in the target block on the blockchain is deleted; it is beneficial to alleviate the data storage pressure on the blockchain, that is, to alleviate the storage pressure of the second storage space for storing the blockchain, and to ensure the normal operation of the blockchain network to which the blockchain belongs. By dynamically determining the consensus node according to the statistical characteristics of the target block and the state information of the node device, the randomness of the consensus node is improved, and then the accuracy and fairness of the consensus result are improved. By backing up the target block when the consensus passes, the problem that the transaction data in the target block cannot be read when the transaction data in the target block is needed to be used in the future can be avoided, and it can be ensured that the business related to the transaction data in the target block is normally processed. When the transaction data in the target block is needed to be used, the transaction data in the target block is recovered to the blockchain through the target block backed up in the first storage space, and the transaction data is read from the target block recovered from the blockchain; by reading the transaction data from the target block recovered from the blockchain, it is beneficial to prevent the transaction data from being tampered with, and to improve the credibility and security of the transaction data. At the same time, the process of reading the transaction data from the blockchain is witnessed by each node device in the blockchain, which can effectively prevent non-legal users from reading the transaction data from the blockchain, and can prevent the transaction data from being leaked.

[0189] Please refer to Figure 10 is a structural schematic diagram of a data processing device 1 based on a blockchain provided by an embodiment of the present application. The above-mentioned data processing device 1 based on a blockchain can be a computer program (including program code) running in a computer device, for example, the data processing device 1 based on a blockchain is an application software; the device can be used to execute the corresponding steps in the method provided by the present application. As shown in the figure, the data processing device 1 based on a blockchain can include: an acquisition module 801, an identification module 802, a deletion module 803, a recovery module 804 and a reading module 805. Figure 10

[0190] The acquisition module is used to acquire attribute information of a block on a blockchain;

[0191] The identification module is used to identify a target block in a redundant state from the blockchain according to the attribute information of the block;

[0192] ​The deleting module is configured to backup the target block to a first storage space and delete transaction data in the target block on the blockchain, wherein the first storage space is different from a second storage space used to store the blockchain;

[0193] The recovering module is configured to, if an acquisition request for the transaction data in the target block is received, recover the transaction data in the target block to the blockchain according to the target block backed up in the first storage space;

[0194] The reading module is configured to read the transaction data in the recovered target block from the blockchain.

[0195] Optionally, the deleting, which includes:

[0196] acquiring statistical characteristics of the target block and state information of a node device in a blockchain network to which the blockchain belongs;

[0197] selecting a consensus node from the node device in the blockchain network according to the statistical characteristics of the target block and the state information;

[0198] sending a deletion verification request for the target block to the consensus node, wherein the deletion verification request is used to instruct the consensus node to verify the legality of a deletion operation on the target block;

[0199] acquiring a consensus result of the deletion operation on the target block from the consensus node;

[0200] if the consensus result indicates that the deletion operation on the target block is legal, backing up the target block to a first storage space and deleting the transaction data in the target block on the blockchain.

[0201] Optionally, the deleting module selects the consensus node from the node device in the blockchain network according to the statistical characteristics of the target block and the state information, and the selecting includes:

[0202] generating a serial number of the node device in the blockchain network according to the state information;

[0203] generating a consensus random number according to the statistical characteristics of the target block;

[0204] determining, as the consensus node, the node device in the blockchain network whose serial number is an integer multiple of the consensus random number.

[0205] Optionally, the target block comprises a block header and a block body, the block body comprising transaction data in the target block, and the block header comprising block information of the target block; the deleting module, if the consensus result indicates that the deleting operation on the target block is legal, backs up the target block into a first storage space and deletes the transaction data in the target block on the block chain, comprising:

[0206] If the consensus result indicates that the deleting operation on the target block is legal, determining location information of the target block on the block chain according to the block header of the target block;

[0207] Backing up the block header and the block body of the target block into the first storage space;

[0208] Deleting the block body of the target block on the block chain, and retaining the block header of the target block on the block chain according to the location information of the target block on the block chain.

[0209] Optionally, the restoring module restores the transaction data in the target block to the block chain according to the target block backed up in the first storage space, comprising:

[0210] Verifying validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, obtaining a verification result;

[0211] If the verification result indicates that the block body of the target block backed up in the first storage space is valid, determining location information of the target block on the block chain according to the block header of the target block backed up in the first storage space;

[0212] Restoring the block body of the target block backed up in the first storage space to the block chain according to the location information of the target block on the block chain.

[0213] Optionally, the block header of the target block on the block chain comprises a first current block hash value; the restoring module verifies validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, obtaining a verification result, comprising:

[0214] Reading a second current block hash value comprised in the block header of the target block from the first storage space;

[0215] Comparing the first current block hash value with the second current block hash value, obtaining a first comparison result;

[0216] If the first comparison result indicates that the first current block hash value is the same as the second current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid.

[0217] A verification result indicating that the block body of the target block backed up in the first storage space is valid is generated.

[0218] Optionally, the block header of the target block on the block chain includes a first current block hash value; the recovery module verifies the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the block chain, and obtains a verification result, including:

[0219] A third current block hash value is generated according to the block body of the target block backed up in the first storage space;

[0220] The first current block hash value is compared with the third current block hash value, and a second comparison result is obtained;

[0221] If the second comparison result indicates that the first current block hash value is the same as the third current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid.

[0222] A verification result indicating that the block body of the target block backed up in the first storage space is valid is generated.

[0223] Optionally, the recovery module recovers the block body of the target block backed up in the first storage space to the block chain according to the position information of the target block on the block chain, including:

[0224] The adjacent block of the target block is determined from the block chain;

[0225] The adjacent block of the target block is backed up in the first storage space, and the transaction data in the adjacent block of the target block on the block chain is deleted;

[0226] After the transaction data in the adjacent block is deleted, the block body of the target block backed up in the first storage space is recovered to the block chain according to the position information of the target block on the block chain.

[0227] Optionally, the attribute information includes the number of times that the transaction data in the block is read; the identification module identifies the target block in a redundant state from the block chain according to the attribute information of the block, including:

[0228] determining, from the blockchain, a candidate block whose read frequency is less than a frequency threshold;

[0229] determining a data amount of the transaction data stored in the candidate block;

[0230] determining, as the target block in the redundant state, the candidate block whose data amount of the stored transaction data is greater than a data amount threshold.

[0231] Optionally, the attribute information includes a block height of the block; and the identification module identifies, according to the attribute information of the block, the target block in the redundant state from the blockchain, including:

[0232] obtaining a maximum block height on the blockchain;

[0233] counting a difference value between the maximum block height and a block height corresponding to a block on the blockchain;

[0234] determining, as the target block in the redundant state, the block on the blockchain whose difference value is greater than a height threshold.

[0235] According to an embodiment of the present application, Figure 5 the steps involved in the data processing method based on the blockchain shown in the method can be executed by Figure 10 the modules in the data processing apparatus based on the blockchain shown in the apparatus. For example, Figure 5 the step S101 shown in the method can be executed by Figure 10 the obtaining module 801 in the apparatus, Figure 5 the step S102 shown in the method can be executed by Figure 10 the identification module 802 in the apparatus; Figure 5 the step S103 shown in the method can be executed by Figure 10 the deletion module 803 in the apparatus; Figure 5 the step S104 shown in the method can be executed by Figure 10 the recovery module 804 in the apparatus; Figure 5 the step S105 shown in the method can be executed by Figure 10 the reading module 805 in the apparatus.

[0236] Similarly, according to an embodiment of the present application, Figure 6 the steps involved in the data processing method based on the blockchain shown in the method can be executed by Figure 10 the modules in the data processing apparatus based on the blockchain shown in the apparatus. For example, Figure 6 the step S201 shown in the method can be executed by Figure 10 the obtaining module 801 in the apparatus, Figure 6 the step S202 shown in the method can be executed by Figure 10 the identification module 802 in the apparatus; Figure 6Steps S203 to S207 shown can be derived from Figure 10 The deletion module 803 in the middle is used for execution; Figure 6 Step S208 shown can be performed by Figure 10 The recovery module 804 in the middle is used to execute; Figure 6 Step S209 shown can be performed by Figure 10 The reading module 805 in the middle is used to execute it. According to one embodiment of this application, Figure 10 The various modules in the blockchain-based data processing device shown can be individually or entirely merged into one or more units, or one or more of these units can be further divided into multiple functionally smaller sub-units to achieve the same operation without affecting the technical effects of the embodiments of this application. The above modules are based on logical functional division; in practical applications, the function of one module can be implemented by multiple units, or the function of multiple modules can be implemented by one unit. In other embodiments of this application, the blockchain-based data processing device may also include other units; in practical applications, these functions can also be implemented with the assistance of other units, and can be implemented collaboratively by multiple units.

[0237] According to one embodiment of this application, a general-purpose computer device, such as a computer, which includes processing elements and storage elements such as a central processing unit (CPU), random access memory (RAM), and read-only memory (ROM), can perform operations such as... Figure 5 as well as Figure 6 The computer program (including program code) for each step involved in the corresponding method shown, to construct such... Figure 10The application further provides a computer program product and a computer device. The computer program product can be recorded on a computer readable recording medium, and loaded into the computer device through the computer readable recording medium, and run in the computer device. In the application, the target block in the redundant state is identified according to the attribute information of the block, the target block is backed up into the first storage space, and the transaction data in the target block on the block chain is deleted, which is beneficial to relieving the data storage pressure on the block chain, that is, relieving the storage pressure of the second storage space for storing the block chain, and ensuring the normal operation of the block chain network to which the block chain belongs. By backing up the target block, the problem that the transaction data in the target block cannot be read when the transaction data in the target block needs to be used in the future can be avoided, and the business related to the transaction data in the target block can be ensured to be normally processed. When the transaction data in the target block needs to be used, the transaction data in the target block is recovered to the block chain through the target block backed up in the first storage space, and the transaction data is read from the target block recovered from the block chain. By reading the transaction data from the target block recovered from the block chain, it is beneficial to preventing the transaction data from being tampered, improving the credibility and security of the transaction data. At the same time, the process of reading the transaction data from the block chain is witnessed by each node device in the block chain, which can effectively prevent illegal users from reading the transaction data from the block chain, and prevent the transaction data from being leaked.

[0238] Please refer to Figure 11 FIG. 1 is a structural schematic diagram of a computer device provided by an embodiment of the application. As shown in Figure 11 the computer device 1000 can include a processor 1001, a network interface 1004 and a memory 1005, and in addition, the computer device 1000 can further include a user interface 1003 and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between the components. The user interface 1003 can include a display, a keyboard, and the optional user interface 1003 can further include a standard wired interface and a wireless interface. The network interface 1004 can optionally include a standard wired interface and a wireless interface (such as a WI-FI interface). The memory 1005 can be a high-speed RAM memory or a non-volatile memory such as at least one disk memory. The memory 1005 can be optionally at least one storage device located away from the aforementioned processor 1001. As shown in Figure 11 the memory 1005 as a computer readable storage medium can include an operating system, a network communication module, a user interface module and a device control application program.

[0239] InFigure 11 In the computer device 1000 shown, the network interface 1004 can provide network communication functions; the user interface 1003 is mainly used to provide an interface for user input; and the processor 1001 can be used to invoke a device control application program stored in the memory 1005 to implement:

[0240] Obtaining attribute information of a block on a blockchain;

[0241] Identifying a target block in a redundant state from the blockchain according to the attribute information of the block;

[0242] Backing up the target block into a first storage space, and deleting transaction data in the target block on the blockchain; the first storage space is different from a second storage space used to store the blockchain;

[0243] If an acquisition request for the transaction data in the target block is received, restoring the transaction data in the target block to the blockchain according to the target block backed up in the first storage space;

[0244] Reading transaction data from the target block restored from the blockchain.

[0245] Optionally, the processor 1001 can be used to invoke a device control application program stored in the memory 1005 to implement backing up the target block into a first storage space, and deleting transaction data in the target block on the blockchain, including:

[0246] Obtaining statistical characteristics of the target block, and state information of a node device in a blockchain network to which the blockchain belongs;

[0247] Selecting a consensus node from the node devices in the blockchain network according to the statistical characteristics of the target block and the state information;

[0248] Sending a deletion verification request for the target block to the consensus node; the deletion verification request is used to instruct the consensus node to verify the legality of a deletion operation on the target block;

[0249] Obtaining a consensus result of the deletion operation on the target block from the consensus node;

[0250] If the consensus result indicates that the deletion operation on the target block is legal, backing up the target block into a first storage space, and deleting transaction data in the target block on the blockchain.

[0251] Optionally, the processor 1001 can be configured to invoke a device control application stored in the memory 1005 to implement selection of consensus nodes from the node devices of the blockchain network according to the statistical characteristics of the target block and the state information, including:

[0252] generating serial numbers of the node devices of the blockchain network according to the state information;

[0253] generating a consensus random number according to the statistical characteristics of the target block;

[0254] determining the node devices of the blockchain network whose serial numbers are integer multiples of the consensus random number as the consensus nodes.

[0255] Optionally, the target block includes a block header and a block body, and the block body includes transaction data in the target block, and the block header includes block information of the target block. The processor 1001 can be configured to invoke a device control application stored in the memory 1005 to implement, if the consensus result indicates that the deletion operation on the target block is legal, backing up the target block into a first storage space and deleting the transaction data in the target block on the blockchain, including:

[0256] if the consensus result indicates that the deletion operation on the target block is legal, determining location information of the target block on the blockchain according to the block header of the target block;

[0257] backing up the block header and the block body of the target block into the first storage space;

[0258] deleting the block body in the target block on the blockchain and retaining the block header of the target block on the blockchain according to the location information of the target block on the blockchain.

[0259] Optionally, the processor 1001 can be configured to invoke a device control application stored in the memory 1005 to implement recovery of the transaction data in the target block to the blockchain according to the target block backed up in the first storage space, including:

[0260] verifying validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the blockchain, to obtain a verification result;

[0261] if the verification result indicates that the block body of the target block backed up in the first storage space is valid, determining location information of the target block on the blockchain according to the block header of the target block backed up in the first storage space;

[0262] According to the position information of the target block on the blockchain, the block body of the target block backed up in the first storage space is restored to the blockchain.

[0263] Optionally, the block header of the target block on the blockchain includes a first current block hash value; optionally, the processor 1001 can be configured to invoke the device control application stored in the memory 1005 to verify the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the blockchain, and obtain a verification result, including:

[0264] reading a second current block hash value included in the block header of the target block from the first storage space;

[0265] comparing the first current block hash value with the second current block hash value to obtain a first comparison result;

[0266] if the first comparison result indicates that the first current block hash value is the same as the second current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid;

[0267] generating a verification result indicating that the block body of the target block backed up in the first storage space is valid.

[0268] Optionally, the block header of the target block on the blockchain includes a first current block hash value; the processor 1001 can be configured to invoke the device control application stored in the memory 1005 to verify the validity of the block body of the target block backed up in the first storage space according to the block header of the target block on the blockchain, and obtain a verification result, including:

[0269] generating a third current block hash value according to the block body of the target block backed up in the first storage space;

[0270] comparing the first current block hash value with the third current block hash value to obtain a second comparison result;

[0271] if the second comparison result indicates that the first current block hash value is the same as the third current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid;

[0272] generating a verification result indicating that the block body of the target block backed up in the first storage space is valid.

[0273] Optionally, the processor 1001 can be configured to invoke the device control application stored in the memory 1005 to implement restoring the block body of the target block backed up in the first storage space to the blockchain according to the position information of the target block on the blockchain, including:

[0274] determining the adjacent block of the target block from the blockchain;

[0275] backing up the adjacent block of the target block to the first storage space and deleting the transaction data in the adjacent block of the target block on the blockchain;

[0276] after the transaction data in the adjacent block is deleted, restoring the block body of the target block backed up in the first storage space to the blockchain according to the position information of the target block on the blockchain.

[0277] Optionally, the attribute information includes the number of times of reading the transaction data in the block; the processor 1001 can be configured to invoke the device control application stored in the memory 1005 to implement identifying the target block in the redundant state from the blockchain according to the attribute information of the block, including:

[0278] determining the candidate block with the number of times of reading less than the number threshold from the blockchain;

[0279] determining the data amount of the transaction data stored in the candidate block;

[0280] determining the candidate block with the data amount of the stored transaction data greater than the data amount threshold as the target block in the redundant state.

[0281] Optionally, the attribute information includes the block height of the block; the processor 1001 can be configured to invoke the device control application stored in the memory 1005 to implement identifying the target block in the redundant state from the blockchain according to the attribute information of the block, including:

[0282] obtaining the maximum block height on the blockchain;

[0283] counting the difference between the maximum block height and the block height corresponding to the block on the blockchain;

[0284] determining the block on the blockchain with the difference greater than the height threshold as the target block in the redundant state.

[0285] In the present application, the target block in the redundant state is identified according to the attribute information of the block, the target block is backed up to the first storage space, and the transaction data in the target block on the block chain is deleted; it is beneficial to alleviate the data storage pressure on the block chain, that is, to alleviate the storage pressure of the second storage space for storing the block chain, and to ensure the normal operation of the block chain network to which the block chain belongs. By backing up the target block, the problem that the transaction data in the target block cannot be read when the transaction data in the target block needs to be used in the future can be avoided, and the business related to the transaction data in the target block can be ensured to be normally processed. When the transaction data in the target block needs to be used, the transaction data in the target block is recovered to the block chain through the target block backed up in the first storage space, and the transaction data is read from the target block recovered from the block chain; by reading the transaction data from the target block recovered from the block chain, it is beneficial to prevent the transaction data from being tampered with, improve the credibility and security of the transaction data. At the same time, the process of reading the transaction data from the block chain is witnessed by each node device in the block chain, which can effectively prevent illegal users from reading the transaction data from the block chain, and can prevent the transaction data from being leaked.

[0286] It should be understood that the computer device 1000 described in the embodiments of the present application can execute the foregoing description of the block chain-based data processing method in the foregoing Figure 5 and the foregoing Figure 6 corresponding embodiments, and can also execute the foregoing description of the block chain-based data processing apparatus in the foregoing Figure 10 corresponding embodiments, which will not be described here. In addition, the beneficial effects of using the same method will not be described here.

[0287] In addition, it should be noted that the present application also provides a computer readable storage medium, and the foregoing computer readable storage medium stores the computer program executed by the foregoing block chain-based data processing apparatus mentioned in the foregoing, and the foregoing computer program includes program instructions, and when the foregoing processor executes the foregoing program instructions, the foregoing description of the block chain-based data processing method in the foregoing Figure 5 and Figure 6 corresponding embodiments can be executed, therefore, the foregoing will not be described here. In addition, the beneficial effects of using the same method will not be described here. For technical details not disclosed in the computer readable storage medium embodiments of the present application, please refer to the description of the method embodiments of the present application.

[0288] As an example, the aforementioned program instructions can be deployed on a computer device to execute, or be deployed on multiple computer devices located in one place to execute, or be deployed on multiple computer devices distributed in multiple places and interconnected through a communication network to execute, which can constitute a blockchain network.

[0289] The aforementioned computer readable storage medium can be an internal storage unit of the data processing apparatus provided by any of the foregoing embodiments or the aforementioned computer device, such as a hard disk or a 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 disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. Further, the computer readable storage medium can include both the internal storage unit and the external storage device 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.

[0290] The terms "first", "second", etc. in the specification and claims and drawings of the embodiments of the present application are used to distinguish different objects, and are not used to describe a specific order. In addition, the term "comprising" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, device, product or equipment including a series of steps or units is not limited to the listed steps or units, but can optionally include steps or units not listed, or can optionally include other steps or units inherent to the process, method, device, product or equipment.

[0291] Those of ordinary skill in the art can realize that the units and algorithm steps of the examples described in conjunction with the embodiments disclosed herein can be realized in electronic hardware, computer software or a combination of both. In order to clearly illustrate the interchangeability of hardware and software, the components and steps of the examples have been described in general terms in the foregoing description. Whether the functions are performed 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 implementation should not be considered beyond the scope of the present application.

[0292] The method and related apparatus provided by the embodiments of the present application are described with reference to the method flowchart and / or structural schematic diagram provided by the embodiments of the present application, and each flow and / or block of the method flowchart and / or structural schematic diagram and the combination of the flows and / or blocks in the flowchart and / or block diagram can be implemented by computer program instructions. The computer program instructions can be provided to the processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device that implements the functions specified in the flowchart Figure 1 of one or more flows and / or structural schematic Figure 1 of one or more blocks. The computer program instructions can also be stored in a computer readable memory capable of causing the computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including instruction devices that implement the functions specified in the flowchart Figure 1 of one or more flows and / or structural schematic Figure 1 of one or more blocks. The computer program instructions can also be loaded into a computer or other programmable data processing device to cause a series of operation steps to be performed on the computer or other programmable device to produce a computer implemented process, so that the instructions executed on the computer or other programmable device provide a process for implementing the functions specified in the flowchart Figure 1 of one or more flows and / or structural schematic of one or more blocks.

[0293] The above disclosure is only the preferred embodiments of the present application, and of course cannot limit the scope of the rights of the present application, so the equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A blockchain-based data processing method, characterized in that, The method comprises: acquiring attribute information of a block on a blockchain; the attribute information comprises a number of times that transaction data in the block is read; determining, from the blockchain, a candidate block for which the number of times read is less than a number threshold; determining a data amount of the transaction data stored in the candidate block; determining, as a target block in a redundant state, the candidate block for which the data amount of the stored transaction data is greater than a data amount threshold; backing up the target block in the first storage space and deleting the transaction data in the leaf node of the Merkle Patricia tree of the target block on the blockchain; the transaction data in the target block on the blockchain is stored based on a data storage structure of the Merkle Patricia tree, the transaction data in the target block is stored in the leaf node of the Merkle Patricia tree, the first current block hash of the target block is a hash value in an extension node of the Merkle Patricia tree, and the hash value in the extension node is generated according to the identifier of a branch node connected thereto; the first storage space is different from a second storage space used to store the blockchain; if an acquisition request for the transaction data in the target block is received, restoring the transaction data in the target block to the blockchain according to the target block backed up in the first storage space; reading the transaction data from the target block restored from the blockchain.

2. The method of claim 1, wherein, The method comprises: acquiring statistical characteristics of the target block and state information of a node device in a blockchain network to which the blockchain belongs; selecting a consensus node from the node devices in the blockchain network according to the statistical characteristics of the target block and the state information; sending a deletion verification request for the target block to the consensus node; the deletion verification request is used to instruct the consensus node to verify the legality of the deletion operation of the target block; acquiring a consensus result of the deletion operation of the target block from the consensus node; if the consensus result indicates that the deletion operation of the target block is legal, backing up the target block in the first storage space and deleting the transaction data in the leaf node of the Merkle Patricia tree of the target block on the blockchain.

3. The method of claim 2, wherein, The method comprises: generating a serial number of the node devices in the blockchain network according to the state information; generating a consensus random number according to the statistical characteristics of the target block; determining, as the consensus node, the node device in the blockchain network whose serial number is an integer multiple of the consensus random number.

4. The method of claim 2, wherein, The target block comprises a block header and a block body, the block body comprises the transaction data in the leaf node of the Merkle Patricia tree of the target block, and the block header comprises block information of the target block. If the consensus result indicates that the deletion operation on the target block is legal, the target block is backed up into a first storage space, and transaction data in leaf nodes of a Merkle Patricia tree of the target block on the blockchain is deleted, including: If the consensus result indicates that the deletion operation on the target block is legal, location information of the target block on the blockchain is determined according to a block header of the target block; The block header and a block body of the target block are backed up into the first storage space; The block body in the target block on the blockchain is deleted, and the block header of the target block is retained on the blockchain according to the location information of the target block on the blockchain.

5. The method of claim 4, wherein, The target block in the target area is restored to the blockchain according to the target block backed up in the first storage space, including: The validity of the block body of the target block backed up in the first storage space is verified according to the block header of the target block on the blockchain, and a verification result is obtained; If the verification result indicates that the block body of the target block backed up in the first storage space is valid, location information of the target block on the blockchain is determined according to the block header of the target block backed up in the first storage space; The block body of the target block backed up in the first storage space is restored to the blockchain according to the location information of the target block on the blockchain.

6. The method of claim 5, wherein, The block header of the target block on the blockchain includes a first current block hash value, and the block header is located in an extension node of a Merkle Patricia tree of the target block; The validity of the block body of the target block backed up in the first storage space is verified according to the block header of the target block on the blockchain, and a verification result is obtained, including: A second current block hash value included in the block header of the target block is read from the first storage space; The first current block hash value is compared with the second current block hash value, and a first comparison result is obtained; If the first comparison result indicates that the first current block hash value is the same as the second current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid; A verification result indicating that the block body of the target block backed up in the first storage space is valid is generated.

7. The method of claim 5, wherein, The block header of the target block on the blockchain includes a first current block hash value; The validity of the block body of the target block backed up in the first storage space is verified according to the block header of the target block on the blockchain, and a verification result is obtained, including: A third current block hash value is generated according to the block body of the target block backed up in the first storage space; The first current block hash value is compared with the third current block hash value, and a second comparison result is obtained; If the second comparison result indicates that the first current block hash value is the same as the third current block hash value, it is determined that the block body of the target block backed up in the first storage space is valid. A verification result is generated to indicate that the block body of the target block backed up in the first storage space is valid.

8. The method of claim 5, wherein, The block body of the target block backed up in the first storage space is restored to the blockchain according to the position information of the target block on the blockchain, including: The adjacent block of the target block is determined from the blockchain; The adjacent block of the target block is backed up in the first storage space, and the transaction data in the adjacent block of the target block on the blockchain is deleted; After the transaction data in the adjacent block is deleted, the block body of the target block backed up in the first storage space is restored to the blockchain according to the position information of the target block on the blockchain.

9. The method of claim 1, wherein, The attribute information further includes the block height of the block; the method further includes: Obtaining the maximum block height on the blockchain; Statistical difference between the maximum block height and the block height corresponding to the block on the blockchain; The block with a difference greater than the height threshold on the blockchain is determined as a target block in a redundant state. 10.A blockchain-based data processing apparatus, characterized by comprising: It includes: An acquisition module is configured to acquire attribute information of a block on a blockchain; The attribute information includes the number of times that the transaction data in the block is read; An identification module is configured to determine a candidate block from the blockchain, the candidate block having a read frequency less than a frequency threshold; and determine the data amount of the transaction data stored in the candidate block; The candidate block having a data amount of the stored transaction data greater than a data amount threshold is determined as a target block in a redundant state; A deletion module is configured to back up the target block in a first storage space and delete transaction data in a leaf node of a Merkle Patricia tree of the target block on the blockchain; the transaction data in the target block on the blockchain is stored based on a data storage structure of the Merkle Patricia tree, the transaction data in the target block is stored in the leaf node of the Merkle Patricia tree, the first current block hash of the target block is a hash value in an extension node of the Merkle Patricia tree, the hash value in the extension node is generated according to the identifier of a branch node connected thereto, and the first storage space is different from a second storage space used to store the blockchain; A recovery module is configured to, if an acquisition request for the transaction data in the target block is received, restore the transaction data in the target block to the blockchain according to the target block backed up in the first storage space; A reading module is configured to read the transaction data in the restored target block from the blockchain.

11. A computer device, characterized by It includes: A processor and a memory; The processor is connected with the memory, wherein the memory is used to store program code, and the processor is used to call the program code to execute the method of any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, The computer readable storage medium stores a computer program, the computer program comprising program instructions which, when executed by a processor, cause the processor to perform the method of any one of claims 1-9.

Citation Information

Patent Citations

  • Blockchain based data processing method, equipment and system

    CN108270836A

  • Data processing, block generation and synchronization method for block link networks

    CN109492049A

  • Data processing method and device based on block chain, storage medium and equipment

    CN111523890A

  • Block data storage method and device, electronic equipment and readable storage medium

    CN112069169A