Database data processing method based on block chain and computer device

By utilizing a trusted execution environment and erasure coding algorithm on the blockchain to divide operation requests into data slices and perform consensus algorithm backups, the problem of low efficiency in integrity checks in blockchain data management is solved, achieving efficient and secure database backup and integrity checks.

CN121901332APending Publication Date: 2026-04-21TSINGHUA UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
TSINGHUA UNIVERSITY
Filing Date
2024-10-15
Publication Date
2026-04-21

AI Technical Summary

Technical Problem

In existing technologies for data management on blockchain, relational databases have low efficiency in integrity checks, and the loss of database data is huge, lacking efficient integrity proofs.

Method used

The operation request is divided into multiple data slices using a trusted execution environment. The data is backed up by the master and slave nodes of the blockchain according to the target erasure coding algorithm and consensus algorithm. The trusted execution environment is then used for integrity verification and database operations.

Benefits of technology

It enables efficient and accurate database backup and integrity checks, ensuring data security and reliability and preventing data loss.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121901332A_ABST
    Figure CN121901332A_ABST
Patent Text Reader

Abstract

The invention discloses a database data processing method based on a block chain and a computer device.In the method, an operation request for a target database is sent to the block chain through a trusted execution environment, the operation request is divided into a plurality of data slices through a main node in the block chain according to a target erasure code algorithm, and the data slices are stored in the block chain; after each node in the block chain completes consensus according to the target consensus algorithm, each data slice is stored in the corresponding node in the block chain in a distributed manner to back up the operation request, and the data of the database can be recovered according to the backed-up operation request subsequently, so that the database can be backed up efficiently and accurately, and the database backup efficiency is improved. Meanwhile, integrity checking and database operation are conducted on the target database through the trusted execution environment, and integrity checking and operation are conducted on the database more safely and reliably.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technology, and in particular to a blockchain-based database data processing method and computer device. Background Technology

[0002] Data management on blockchains typically utilizes key-value databases for data retrieval and storage. Merkle trees and other verification tools are also deployed on the blockchain to provide fast database integrity checks. Currently, some industries still primarily use relational databases. In practical deployments, integrity protection is usually achieved by storing relational data in the database and saving data hashes and other information on the blockchain. However, this approach cannot effectively perform data integrity checks, lacks efficient integrity proofs, and the loss of database data can result in significant losses. Summary of the Invention

[0003] This application provides a blockchain-based database data processing method and computer device. It utilizes a trusted execution environment to send operation requests to the master node of the blockchain, divides the operation requests into multiple data slices according to the target erasure coding algorithm, and backs them up in the blockchain, so as to achieve efficient and accurate database backup.

[0004] Firstly, a blockchain-based database data processing method is provided. The blockchain includes a master node and multiple slave nodes. The method includes: responding to a client's operation request for a target database, sending the operation request to the master node using a trusted execution environment; dividing the operation request into multiple data slices by the master node according to a target erasure coding algorithm; achieving consensus between the master node and each of the slave nodes according to a target consensus algorithm; if the consensus is successful, storing each data slice to each target node by the master node to back up the operation request, wherein some or all nodes in the blockchain are target nodes, and each data slice corresponds to one target node; performing database operations on the target database corresponding to the operation request using the trusted execution environment; if the target database returns a database operation result and an integrity verification certificate, performing an integrity verification on the target database using the trusted execution environment based on the database operation result and the integrity verification certificate; if the target database passes the integrity verification, forwarding the database operation result to the client.

[0005] In some embodiments, after performing database operations corresponding to the operation request on the target database using the trusted execution environment, the method further includes: if the target database returns error information to the trusted execution environment or fails the integrity verification, and a backup operation request exists in the blockchain, sending a database recovery request to the master node using the trusted execution environment; restoring the backup operation request in the blockchain using the target erasure coding algorithm through the master node to obtain operation request data; and restoring the target database based on the operation request data and the full backup data to obtain a new target database, wherein the full backup data is generated after a full backup of the target database is performed in advance.

[0006] In some embodiments, the full backup data is stored in the target proxy node. Data recovery of the target database based on the operation request data and the full backup data to obtain a new target database includes: sending a data acquisition request to the master node through the target proxy node; sending the operation request data to the target proxy node through the master node; and performing database operations corresponding to the operation request data on the full backup data through the target proxy node to obtain the new target database.

[0007] In some embodiments, after restoring the target database to a new target database based on the operation request data and the full backup data, the method further includes: using the trusted execution environment to perform database operations on the new target database corresponding to the operation request; if the new target database returns a database operation result and an integrity verification certificate, using the trusted execution environment to perform an integrity verification on the new target database based on the database operation result and integrity verification certificate returned by the new target database; if the new target database passes the integrity verification, forwarding the database operation result returned by the new target database to the client.

[0008] In some embodiments, after storing each of the data slices to each of the target nodes through the master node, the method further includes: returning the backup result of the operation request to the trusted execution environment through the master node.

[0009] In some embodiments, the target consensus algorithm is a practical Byzantine consensus algorithm. Achieving consensus between the master node and each of the slave nodes according to the target consensus algorithm includes: the master node performing hash operations on each data slice according to the target hash algorithm to obtain slice hash values ​​corresponding to each data slice; the master node merging the slice hash values ​​and performing hash operations again on the merged slice hash values ​​according to the target hash algorithm to obtain a merged hash value; the master node sending each slice hash value and the merged hash value to each of the slave nodes, with each slave node corresponding to one slice hash value and one merged hash value; each node in the blockchain sending a preparation message including the merged hash value to all nodes in the blockchain except itself; if the number of preparation messages received by the current node in the blockchain reaches the target number, and the merged hash values ​​in the received preparation messages are the same, the current node sends a confirmation message including the merged hash value to all nodes in the blockchain except itself; if any node in the blockchain receives the target number of confirmation messages, and the merged hash values ​​in the received confirmation messages are the same, consensus is determined to be successful.

[0010] In some embodiments, the target number is 2f+1, the number of data slices is 3f+1, and f represents the number of faulty nodes in the blockchain.

[0011] In a second aspect, a computer device is provided, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the blockchain-based database data processing method as described in the first aspect.

[0012] Thirdly, a computer-readable storage medium is provided having a computer program / instructions stored thereon, which, when executed by a processor, implements the blockchain-based database data processing method as described in the first aspect.

[0013] Fourthly, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the blockchain-based database data processing method as described in the first aspect.

[0014] By applying the above data scheme, the blockchain includes one master node and multiple slave nodes. A trusted execution environment is used to send operation requests to the target database to the blockchain. The master node in the blockchain divides the operation request into multiple data slices according to the target erasure coding algorithm. After the nodes in the blockchain reach consensus according to the target consensus algorithm, each data slice is distributed and stored on the corresponding node in the blockchain to back up the operation request. Since the database data can be restored based on the backed-up operation request, efficient and accurate database backup is achieved. Simultaneously, the trusted execution environment is used to perform integrity verification and database operations on the target database, enabling more secure and reliable integrity checks and operations on the database. Attached Figure Description

[0015] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments recorded in this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0016] Figure 1 This is a flowchart illustrating a blockchain-based database data processing method according to an embodiment of this application.

[0017] Figure 2 A flowchart illustrating another embodiment of a blockchain-based database data processing method of this application;

[0018] Figure 3 This is a flowchart illustrating the process of obtaining the new target database in this application embodiment;

[0019] Figure 4 This is a flowchart illustrating the consensus process between the master node and each slave node using the target consensus algorithm in an embodiment of this application.

[0020] Figure 5 This is a schematic diagram of the system architecture corresponding to the blockchain-based database data processing method in this application embodiment;

[0021] Figure 6 This is a schematic diagram illustrating the principle of consensus between the master node and each slave node according to the practical Byzantine consensus algorithm in an embodiment of this application.

[0022] Figure 7 This is a structural block diagram of a computer device according to an embodiment of this application. Detailed Implementation

[0023] Various embodiments and features of this application are described herein with reference to the accompanying drawings.

[0024] It should be understood that various modifications can be made to the embodiments described herein. Therefore, the above description should not be considered as limiting, but merely as an example of embodiments. Other modifications within the scope and spirit of this application will be apparent to those skilled in the art.

[0025] The accompanying drawings, which are included in and form part of this specification, illustrate embodiments of the present application and, together with the general description of the present application given above and the detailed description of the embodiments given below, serve to explain the principles of the present application.

[0026] These and other features of this application will become apparent from the following description of preferred forms of embodiments given as non-limiting examples, with reference to the accompanying drawings.

[0027] It should also be understood that although this application has been described with reference to some specific examples, those skilled in the art can certainly implement many other equivalent forms of this application.

[0028] The above and other aspects, features and advantages of this application will become more apparent when taken in conjunction with the accompanying drawings and in view of the following detailed description.

[0029] Specific embodiments of this application are described thereafter with reference to the accompanying drawings; however, it should be understood that the claimed embodiments are merely examples of this application, which can be implemented in various ways. Well-known and / or repeated functions and structures are not described in detail to avoid unnecessary or redundant details that could obscure the application. Therefore, the specific structural and functional details claimed herein are not intended to be limiting, but merely serve as the basis and representative basis for the claims to teach those skilled in the art to use this application in a variety of substantially any suitable detailed structures.

[0030] This specification may use the phrases “in one embodiment,” “in another embodiment,” “in yet another embodiment,” or “in other embodiments,” all of which may refer to one or more of the same or different embodiments according to this application.

[0031] Before providing a detailed description of the embodiments of this application, the technical names and terms involved in the embodiments of this application will be explained first.

[0032] 1) Trusted Execution Environment.

[0033] A Trusted Execution Environment (TEE) is a secure computing environment that provides a trusted and secure environment to ensure the security and privacy of sensitive data and code. A TEE typically consists of hardware and software and can run on top of a regular operating system, providing a secure runtime environment that prevents malware from accessing or tampering with the data and code within the TEE. TEE security is achieved through hardware isolation and encryption protection, and is typically composed of a secure processor and TEE software. The secure processor is a specialized piece of hardware that is independent of the main processor and has its own memory and processing power. The TEE software runs on the secure processor, providing a protected execution environment that can run trusted applications.

[0034] 2) Blockchain.

[0035] Blockchain is a distributed database that combines data blocks into a chain-like data structure in chronological order, and uses cryptographic methods to ensure the immutability and unforgeability of the data. Blockchain technology uses a chain-like data structure to verify and store data, generates and updates data through a distributed node consensus algorithm, and uses cryptographic methods to ensure the security of data transmission and access.

[0036] 3) Blockchain consensus.

[0037] Blockchain consensus is a set of rules or protocols that enable nodes in a blockchain network to agree on the shared state of the network. These consensus algorithms ensure that all nodes in the network reach a consensus on the validity of transactions and the order in which they are added to the blockchain, thereby maintaining the integrity of the blockchain. Consensus algorithms provide security by preventing malicious actors from controlling the network, ensuring valid transactions and smooth network operation, and improve efficiency by allowing nodes to quickly agree on the validity of transactions and add new blocks to the blockchain in a timely manner. They increase transparency by making all transactions visible on the blockchain, facilitating tracking and preventing fraudulent activities.

[0038] 4) Erasure codes.

[0039] Erasure coding (EC) is a data protection method that divides data into segments and generates redundant data blocks using coding algorithms. These blocks are stored in different locations, such as disks, storage nodes, or other geographical locations, to improve data reliability and availability. The working principle of erasure coding mainly involves dividing the original data into multiple data blocks (or data slices) and generating redundant data blocks using specific coding algorithms. These blocks are then stored in different physical locations to increase data fault tolerance. When some data blocks are corrupted, the original data can be recovered using the remaining blocks through decoding algorithms. The advantage of erasure coding is that it can achieve high storage efficiency while ensuring data reliability because it improves data fault tolerance by generating redundant data blocks, rather than simply copying data.

[0040] 5) Practical Byzantine consensus algorithm.

[0041] Practical Byzantine Fault Tolerance (PBFT) is a state machine-based algorithm used to solve the consensus problem among nodes in a distributed system. PBFT consists of a consensus protocol, a checkpointing protocol, and a view switching protocol. Node roles are categorized into three types: client, master, and slave. Clients send requests, and master nodes receive requests and reach consensus with slave nodes. PBFT assumes that the number of faulty nodes does not exceed (n-1) / 3, i.e., f <= (n-1) / 3, where n is the total number of nodes and f is the number of faulty nodes.

[0042] This application provides a blockchain-based database data processing method that utilizes a trusted execution environment to send operation requests for a target database to the blockchain. The master node in the blockchain divides the operation request into multiple data slices according to a target erasure coding algorithm. After each node in the blockchain reaches consensus according to a target consensus algorithm, the data slices are distributed and stored on the corresponding nodes in the blockchain to back up the operation request. Since the database data can be restored based on the backed-up operation request, efficient and accurate database backup is achieved. Simultaneously, the trusted execution environment is used to perform integrity verification and database operations on the target database, enabling more secure and reliable integrity checks and operations on the database.

[0043] The blockchain consists of one master node and multiple slave nodes, such as Figure 1 As shown, the method includes the following steps:

[0044] Step S101: In response to the client's operation request to the target database, the operation request is sent to the master node using a trusted execution environment, and the master node divides the operation request into multiple data slices according to the target erasure coding algorithm.

[0045] In this embodiment, the client can be any terminal device capable of providing a user interface. For example, the client can be a mobile smartphone, a portable computer, a tablet computer, or a smart wearable device. Of course, the client can also be software that can run on any of the devices listed above. For example, the client can be application software installed on a mobile smartphone or a tablet computer.

[0046] The target database can be a relational database or other types of database. The operation request specifically refers to a read / write operation on the target database, which can include operations such as data insertion, querying, updating, and deleting. Figure 5 The diagram illustrates the system architecture of the blockchain-based database data processing method according to an embodiment of this application, including a client, a trusted execution environment, a target database, and a blockchain. A trusted execution environment is established between the client and the target database. The consensus nodes in the blockchain include one master node and multiple slave nodes. When the client needs to operate on the target database, it sends the operation request to the trusted execution environment, which then forwards the request to the master node in the blockchain. Upon receiving the operation request, the master node divides it into multiple data slices according to the target erasure coding algorithm. After the blockchain achieves consensus, these data slices are distributed and stored on the corresponding nodes within the blockchain.

[0047] Optionally, the target erasure coding algorithm may include any one of array erasure coding (such as RAID5, RAID6, etc.), RS (Reed-Solomon) type erasure coding, and LDPC (Low Density Parity Check Code) low-density parity check erasure coding.

[0048] Understandably, the number of data slices should not exceed the number of nodes in the blockchain to ensure reliable backup operation requests.

[0049] Step S102: The master node and each of the slave nodes reach a consensus according to the target consensus algorithm.

[0050] In this embodiment, the master node and each slave node reach a consensus according to the target consensus algorithm, and the subsequent backup process can only be carried out after the consensus is successful.

[0051] Optionally, the target consensus algorithm includes, but is not limited to, any one of the following: Practical Byzantine Fault Tolerance (PBFT), Federated Byzantine Agreement (FBA), and Delegated Byzantine Fault Tolerance (dBFT).

[0052] Step S103: If the consensus is successful, the master node stores each data slice to each target node to back up the operation request. Here, some or all of the nodes in the blockchain are the target nodes, and each data slice corresponds to one target node.

[0053] In this embodiment, some or all nodes in the blockchain can be used as target nodes for storing data slices. For example, all or some slave nodes can be used as target nodes, or the master node can be used as a target node, making the master node and slave nodes target nodes. If consensus is successful, it means that the blockchain can reliably store data. The master node stores each data slice to its respective target node, with each data slice corresponding to one target node, thus completing the backup of the operation request. For example, if there are 5 data slices, and the blockchain includes 1 master node and 4 slave nodes, then the 1 master node and 4 slave nodes in the blockchain can form 5 target nodes, and the data slices can be distributed and stored on each target node.

[0054] Step S104: Use the trusted execution environment to perform database operations on the target database corresponding to the operation request.

[0055] In this embodiment, a trusted execution environment (TEU) is used to perform database operations on the target database corresponding to the operation request. For example, if the operation request is a data insertion request, the TEU is used to insert data into the target database. If the operation request is a data update request, the TEU is used to replace the corresponding data in the target database with the new data in the operation request.

[0056] Step S105: If the target database returns a database operation result and an integrity verification certificate, the trusted execution environment is used to perform an integrity verification on the target database based on the database operation result and the integrity verification certificate. If the target database passes the integrity verification, the database operation result is forwarded to the client.

[0057] In this embodiment, if the target database returns the database operation result and integrity verification certificate, the trusted execution environment is used to perform integrity verification on the target database based on the database operation result and integrity verification certificate. If the target database passes the integrity verification, it means that the data in the target database is complete. Then, the trusted execution environment forwards the database operation result returned by the target database to the client to complete the database operation.

[0058] It should be noted that steps S101-S103 can be executed first, followed by steps S104-S105. Alternatively, steps S104-S105 can be executed first, followed by steps S101-S103. Furthermore, steps S104-S105 can be executed simultaneously with the backup performed in steps S101-S103, while also performing database operations.

[0059] This application's embodiment of the blockchain-based database data processing method includes a blockchain comprising a master node and multiple slave nodes. A trusted execution environment (TEA) is used to send operation requests to the target database to the blockchain. The master node in the blockchain divides the operation request into multiple data slices according to the target erasure coding algorithm. After the nodes in the blockchain reach consensus according to the target consensus algorithm, each data slice is distributed and stored in the corresponding node in the blockchain to back up the operation request. Since the database data can be restored based on the backed-up operation request, efficient and accurate database backup is achieved. Simultaneously, the TEA is used to perform integrity verification and database operations on the target database, enabling more secure and reliable integrity checks and operations on the database.

[0060] In some embodiments of this application, after performing database operations corresponding to the operation request on the target database using the trusted execution environment, such as Figure 2 As shown, it also includes the following steps:

[0061] Step S106: If the target database returns error information to the trusted execution environment or fails the integrity verification, and there is a backup operation request in the blockchain, a database recovery request is sent to the master node using the trusted execution environment.

[0062] In this embodiment, if the target database returns an error message to the trusted execution environment or fails the integrity check, it indicates that the target database is abnormal or its data is incomplete, making database operations impossible. In this case, data recovery of the target database is required. If a backed-up operation request exists in the blockchain, the trusted execution environment sends a database recovery request to the master node in the blockchain to recover the corresponding operation request from the blockchain. It is understood that the backed-up operation request is also backed up to the blockchain by the master node using the target erasure coding algorithm. The existence of a backed-up operation request in the blockchain specifically refers to the existence of a data slice in the blockchain corresponding to the backed-up operation request.

[0063] Step S107: The master node restores the backed-up operation request in the blockchain according to the target erasure coding algorithm to obtain the operation request data.

[0064] In this embodiment, the backed-up operation request refers to one or more operation requests that were backed up according to steps S101-S103 after the most recent full backup of the target database. The master node restores the backed-up operation requests in the blockchain using the target erasure coding algorithm to obtain operation request data. This operation request data can represent the database operations performed on the target database after the most recent full backup of the target database.

[0065] Step S108: Perform data recovery on the target database according to the operation request data and the full backup data to obtain a new target database. The full backup data is generated after a full backup of the target database is performed in advance.

[0066] In this embodiment, a full backup of the target database is generated beforehand. This full backup can be performed periodically, with the frequency being lower than the frequency of backing up operation requests via blockchain. Since the amount of data in an operation request is much smaller than the entire target database, this allows for more efficient backups. After obtaining the operation request data, the target database is restored based on the operation request data and the full backup data, resulting in a new target database.

[0067] When it is necessary to restore the target database, the master node in the blockchain restores the operation request data corresponding to the backed-up operation request according to the target erasure coding algorithm. Then, the new target database is restored based on the operation request data and the full backup data, thereby achieving efficient data recovery of the database.

[0068] It is understandable that if there is no backup operation request in the blockchain, it means that no operation has been performed on the target database since the most recent full backup, that is, the data in the target database has not changed, and the new target database can be directly restored based on the full backup data.

[0069] In some embodiments of this application, the full backup data is stored in the target proxy node, and the target database is restored based on the operation request data and the full backup data to obtain a new target database, such as... Figure 3 As shown, it includes the following steps:

[0070] Step S1081: Send a data acquisition request to the master node through the target proxy node.

[0071] In this embodiment, the full backup data of the target database is stored in the target proxy node. The target proxy node can be a node in the blockchain or a separately set node outside the blockchain. The number of target proxy nodes can be one or more. When there are multiple target proxy nodes, the full backup data can be distributed and stored in each target proxy node. For example, the full backup data can be sliced ​​using the target erasure coding algorithm, and the corresponding data slices can be distributed and stored in each target proxy node.

[0072] The target proxy node sends a data retrieval request to the master node, so that the master node returns the operation request data.

[0073] Step S1082: The operation request data is sent to the target proxy node through the master node.

[0074] The master node responds to the data retrieval request by sending the recovered operation request data to the target proxy node.

[0075] In some embodiments, after receiving a data acquisition request, the master node verifies the data acquisition request according to the target verification rules. After the verification is passed, the operation request data is sent to the target proxy node, thereby further improving data security.

[0076] Step S1083: Through the target proxy node, perform database operations corresponding to the operation request data on the full backup data to obtain the new target database.

[0077] In this embodiment, the operation request data can correspond to one or more database operations on the target database. For example, if the operation request data corresponds to a data deletion operation, the target proxy node will delete the corresponding data in the full backup data to obtain a new target database. If the operation request data corresponds to one data deletion operation and two data insertion operations performed sequentially, the target proxy node will first delete the corresponding data in the full backup data, and then insert the data corresponding to the two data insertion operations in sequence to obtain a new target database.

[0078] Understandably, when there is no backup operation request in the blockchain, a trusted execution environment can be used to send a data recovery request to the target proxy node, enabling the target proxy node to restore the new target database through the full backup data.

[0079] By performing database operations corresponding to the requested data on the full backup data through the target proxy node, a new target database is obtained, thus achieving more efficient data recovery of the database.

[0080] In some embodiments of this application, after performing data recovery on the target database based on the operation request data and the full backup data to obtain a new target database, the method further includes:

[0081] The trusted execution environment is used to perform database operations on the new target database corresponding to the operation request.

[0082] If the new target database returns a database operation result and an integrity verification certificate, the trusted execution environment is used to perform an integrity verification on the new target database based on the database operation result and integrity verification certificate returned by the new target database. If the new target database passes the integrity verification, the database operation result returned by the new target database is forwarded to the client.

[0083] In this embodiment, after obtaining the recovered new target database, the trusted execution environment is used to perform database operations corresponding to the operation request on the new target database. If the new target database returns the database operation results and integrity verification certificate, it indicates that the data in the new target database is complete. The trusted execution environment then forwards the database operation results returned by the new target database to the client, thereby completing the corresponding database operation using the new target database and ensuring reliable execution of the corresponding database operation.

[0084] In some embodiments of this application, after storing each data slice to each target node through the master node, the method further includes:

[0085] The master node returns the backup result of the operation request to the trusted execution environment.

[0086] In this embodiment, after storing each data slice to each target node, the master node returns the backup result of the operation request to the trusted execution environment, so that the trusted execution environment can determine that the operation request has been backed up. Subsequently, when database recovery is required, data recovery can be performed through the backed-up operation request.

[0087] In some embodiments of this application, the target consensus algorithm is a practical Byzantine consensus algorithm, and the master node and each of the slave nodes reach consensus according to the target consensus algorithm, such as... Figure 4 As shown, it includes the following steps:

[0088] Step S1021: The master node performs hash operations on each of the data slices according to the target hash algorithm to obtain the hash value of each slice corresponding to each of the data slices.

[0089] In this embodiment, the target consensus algorithm is the Practical Byzantine consensus algorithm. The consensus process includes a pre-preparation phase (steps S1021-S1023), a preparation phase (step S1024), and a confirmation phase (steps S1025-S1026). In step S1021, the master node performs hash operations on each data slice according to the target hash algorithm to obtain the hash value of each slice. Optionally, the target hash algorithm can be any of the existing hash algorithms, such as MD5, SHA-1, SHA-256, SHA-512, SHA-3, SM3, CRC32, etc.

[0090] Step S1022: The master node merges the hash values ​​of each slice, and performs hash operation on the merged hash values ​​of each slice again according to the target hash algorithm to obtain the merged hash value.

[0091] In this embodiment, after obtaining the hash values ​​of each slice, the hash values ​​of each slice are merged into a single string, and then hashed again according to the target hash value algorithm to obtain a merged hash value.

[0092] Step S1023: The master node sends each slice hash value and the merge hash value to each slave node, with each slave node corresponding to one slice hash value and one merge hash value.

[0093] In this embodiment, the master node sends the hash values ​​of each slice and the merge hash value to each slave node, thereby completing the pre-preparation phase.

[0094] Step S1024: Each node in the blockchain sends a preparation message, including the merged hash value, to nodes in the blockchain other than itself.

[0095] In this embodiment, after receiving the slice hash value and merge hash value sent by the master node, each node (including the master node) sends a preparation message including the merge hash value to nodes in the blockchain other than itself, thereby completing the preparation phase.

[0096] Step S1025: If the number of preparation messages received by the current node in the blockchain reaches the target number, and the merge hash value in each of the received preparation messages is the same, the current node sends a confirmation message including the merge hash value to all nodes in the blockchain except itself.

[0097] In this embodiment, the preparation messages received by each node in the blockchain are confirmed. If the number of preparation messages received by the current node reaches the target number and the merge hash value in each preparation message is the same, it indicates that the current node's storage is correct, and the current node sends a confirmation message including the merge hash value to nodes in the blockchain other than itself.

[0098] Step S1026: If any node in the blockchain receives a certain number of confirmation messages, and the merged hash value in each confirmation message is the same, then consensus is considered successful.

[0099] In this embodiment, if any node in the blockchain receives a target number of confirmation messages, and the merged hash value in each confirmation message is the same, it indicates that a sufficient number of nodes have stored the correct information, and consensus is confirmed to be successful.

[0100] By using the Byzantine consensus algorithm, Byzantine attacks can be effectively resisted. At the same time, by generating a merge hash value and adding the merge hash value to the preparation and confirmation messages, more reliable backup of operation requests can be achieved.

[0101] In some embodiments of this application, the target number is 2f+1, the number of data slices is 3f+1, and f represents the number of faulty nodes in the blockchain.

[0102] In this embodiment, by determining the number of data slices to be 3f+1 and the target number to be 2f+1, a more reliable implementation of the practical Byzantine consensus is ensured.

[0103] For example, such as Figure 6 As shown, the blockchain includes one master node P0 and three slave nodes, namely P1, P2 and P3.

[0104] In the pre-preparation phase, P0 performs hash operations on each data slice according to the target hash algorithm to obtain the slice hash value Fi corresponding to each data slice. P0 merges the slice hash values ​​Fi and performs hash operations on the merged slice hash values ​​again according to the target hash algorithm to obtain the merged hash value Fd. Then P0 sends the slice hash values ​​Fi and the merged hash value Fd to P1, P2 and P3.

[0105] During the preparation phase, each node in the blockchain sends a preparation message, including the merged hash value, to nodes other than itself in the blockchain. Specifically, P0 sends to P1, P2, and P3; P1 sends to P0, P2, and P3; P2 sends to P0, P1, and P3; and P3 sends to P0, P1, and P2.

[0106] During the confirmation phase, if the current node in the blockchain receives 2f+1 preparation messages, and the merge hash value Fd in each of these preparation messages is the same, the current node sends a confirmation message, including the merge hash value Fd, to all nodes in the blockchain except itself. Specifically, P0 sends to P1, P2, and P3; P1 sends to P0, P2, and P3; P2 sends to P0, P1, and P3; and P3 sends to P0, P1, and P2. If any node in the blockchain receives 2f+1 confirmation messages, and the merge hash value Fd in each of these confirmation messages is the same, then consensus is considered successful.

[0107] In some embodiments of this application, if no node in the blockchain receives a target number of confirmation messages and the merged hash value in each received confirmation message is the same, consensus is determined to have failed. In this case, the blockchain view is switched to determine a new master node and consensus is re-established.

[0108] Based on the same concept, embodiments of this application also provide a computer device, such as... Figure 7 As shown, it includes a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the blockchain-based database data processing method described in any embodiment of this application.

[0109] The computer device in this application embodiment can be a terminal or other devices besides a terminal. For example, the computer device can be a mobile phone, tablet computer, laptop computer, handheld computer, in-vehicle electronic device, mobile internet device (MID), augmented reality (AR) / virtual reality (VR) device, robot, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA), etc. It can also be a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine, etc. The embodiments disclosed in this disclosure do not impose specific limitations.

[0110] The memory may include RAM (Random Access Memory) or non-volatile memory, such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0111] The processors mentioned above can be general-purpose processors, including CPUs, NPs (Network Processors), etc.; they can also be DSPs (Digital Signal Processors), ASICs (Application Specific Integrated Circuits), FPGAs (Field Programmable Gate Arrays), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0112] In another embodiment provided in this application, a computer-readable storage medium is also provided, on which a computer program / instruction is stored, which, when executed by a processor, implements the blockchain-based database data processing method described in any embodiment of this application.

[0113] In another embodiment provided in this application, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, implement the blockchain-based database data processing method described in any embodiment of this application.

[0114] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0115] The above embodiments are merely exemplary embodiments of this application and are not intended to limit this application. The scope of protection of this application is defined by the claims. Those skilled in the art can make various modifications or equivalent substitutions to this application within its substance and scope of protection, and such modifications or equivalent substitutions should also be considered to fall within the scope of protection of this application.

Claims

1. A blockchain-based database data processing method, wherein the blockchain includes a master node and multiple slave nodes, characterized in that, The method includes: In response to a client's operation request to the target database, the operation request is sent to the master node using a trusted execution environment, and the master node divides the operation request into multiple data slices according to the target erasure coding algorithm; The master node and each of the slave nodes reach a consensus according to the target consensus algorithm; If the consensus is successful, the master node stores each data slice to each target node to back up the operation request. Here, some or all of the nodes in the blockchain are the target nodes, and each data slice corresponds to one target node. The trusted execution environment is used to perform database operations on the target database corresponding to the operation request. If the target database returns a database operation result and an integrity verification certificate, the trusted execution environment is used to perform an integrity verification on the target database based on the database operation result and the integrity verification certificate. If the target database passes the integrity verification, the database operation result is forwarded to the client.

2. The blockchain-based database data processing method as described in claim 1, characterized in that, After performing the database operation corresponding to the operation request on the target database using the trusted execution environment, the method further includes: If the target database returns an error message to the trusted execution environment or fails the integrity verification, and there is a backup operation request in the blockchain, the trusted execution environment is used to send a database recovery request to the master node. The master node restores the backed-up operation request data in the blockchain according to the target erasure coding algorithm to obtain the operation request data. Data recovery is performed on the target database based on the operation request data and the full backup data to obtain a new target database. The full backup data is generated after a full backup of the target database is performed in advance.

3. The blockchain-based database data processing method as described in claim 2, characterized in that, The full backup data is stored in the target proxy node. Based on the operation request data and the full backup data, the target database is restored to obtain a new target database, including: The target proxy node sends a data acquisition request to the master node. The operation request data is sent to the target proxy node through the master node; The target proxy node performs database operations on the full backup data, corresponding to the operation request data, to obtain the new target database.

4. The blockchain-based database data processing method as described in claim 2, characterized in that, After restoring the target database based on the operation request data and the full backup data to obtain a new target database, the process further includes: The trusted execution environment is used to perform database operations on the new target database corresponding to the operation request. If the new target database returns a database operation result and an integrity verification certificate, the trusted execution environment is used to perform an integrity verification on the new target database based on the database operation result and integrity verification certificate returned by the new target database. If the new target database passes the integrity verification, the database operation result returned by the new target database is forwarded to the client.

5. The blockchain-based database data processing method as described in claim 1, characterized in that, After storing each data slice to its respective target node via the master node, the process further includes: The master node returns the backup result of the operation request to the trusted execution environment.

6. The blockchain-based database data processing method as described in claim 1, characterized in that, The target consensus algorithm is the Practical Byzantine consensus algorithm. The process of achieving consensus between the master node and each of the slave nodes according to the target consensus algorithm includes: The master node performs hash operations on each of the data slices according to the target hash algorithm to obtain the hash value of each slice corresponding to each of the data slices. The master node merges the hash values ​​of each slice, and then performs a hash operation on the merged hash values ​​of each slice again according to the target hash algorithm to obtain the merged hash value. The master node sends each slice hash value and the merge hash value to each slave node, with each slave node corresponding to one slice hash value and one merge hash value. Each node in the blockchain sends a preparation message, including the merged hash value, to nodes in the blockchain other than itself. If the number of preparation messages received by the current node in the blockchain reaches the target number, and the merge hash value in each of the received preparation messages is the same, the current node will send a confirmation message including the merge hash value to all nodes in the blockchain except itself. If any node in the blockchain receives the target number of confirmation messages, and the merged hash value of each confirmation message is the same, then consensus is considered successful.

7. The blockchain-based database data processing method as described in claim 6, characterized in that, The target number is 2f+1, the number of data slices is 3f+1, and f represents the number of faulty nodes in the blockchain.

8. A computer device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the blockchain-based database data processing method as described in any one of claims 1-7.

9. A computer-readable storage medium having a computer program / instructions stored thereon, characterized in that, When the computer program / instructions are executed by the processor, they implement the blockchain-based database data processing method as described in any one of claims 1-7.

10. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, they implement the blockchain-based database data processing method as described in any one of claims 1-7.