Data verification method, device and storage medium

By introducing a multi-threaded processing mechanism into the blockchain server, and using parallel processing of the first thread and the second thread, the problem of low data verification efficiency in the blockchain is solved, and efficient MVCC verification of multiple blocks is achieved.

CN112015558BActive Publication Date: 2025-06-17ONE CONNECT SMART TECH CO LTD SHENZHEN
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202010914376.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-09-03
Publication Date
2025-06-17
Estimated Expiration
2040-09-03

AI Technical Summary

Technical Problem

Data verification in blockchain is inefficient, and the existing technology mainly uses single threads to verify transactions one by one, resulting in low efficiency.

Method used

By introducing multi-threading processing in the server, the first thread acquires the target block from the database and places it in the pre-sequential queue and cache, and the second thread reads the block set from the queue and performs multi-version concurrency control (MVCC) verification.

Benefits of technology

Multi-threaded MVCC verification of multiple blocks is realized, which improves data verification efficiency and reduces access pressure to the database.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112015558B_ABST
    Figure CN112015558B_ABST
Patent Text Reader

Abstract

This application relates to the field of blockchain technology, and in particular, to a data verification method, apparatus, and storage medium, which are applied to a server. The method includes: sending first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache; while sending the first indication information to the first thread, sending second indication information to a second thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set; after the MVCC verification of the first block set is completed, writing the write set corresponding to the first block set into the preset cache. Using the embodiments of this application is beneficial to improving the data verification efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and particularly to a data verification method, apparatus, and storage medium. Background Art

[0002] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. A node in the blockchain can provide endorsement services to a client, including services such as repeated checking of transaction IDs, generation of transaction read-write sets, and final signature, etc. When verifying and storing each transaction in the blockchain, it generally includes processes such as identity authentication, signature authentication, and multi-version concurrency control verification. Among them, multi-version concurrency control (MVCC) verification can verify whether the data version in the transaction is correct. Currently, most use a single thread to verify all transactions one by one, resulting in low data verification efficiency in the blockchain. Summary of the Invention

[0003] Embodiments of this application provide a data verification method, apparatus, and storage medium, which are beneficial to improving data verification efficiency.

[0004] In a first aspect of the embodiments of this application, a data verification method is provided, which is applied to a server and includes:

[0005] Sending first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache;

[0006] While sending the first indication information to the first thread, sending second indication information to a second thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set.

[0007] In a second aspect of the embodiments of this application, a data verification apparatus is provided, which is applied to a server. The apparatus includes: a first sending unit, a second sending unit, and a writing unit, where

[0008] The first sending unit is used to send first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache;

[0009] The second sending unit is configured to send second indication information to a second thread while sending first indication information to the first thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set;

[0010] The writing unit is configured to write a write set corresponding to the first block set into the preset cache after the MVCC verification on the first block set is completed.

[0011] A third aspect of the embodiments of the present application provides a server, which includes a processor, a communication interface, a memory, and one or more programs. The processor, the communication interface, and the memory are interconnected. Among them, the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method described in the first aspect of the embodiments of the present application.

[0012] A fourth aspect of the embodiments of the present application provides a computer-readable storage medium. The computer-readable storage medium stores a computer program for electronic data exchange. The computer program causes a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application.

[0013] A fifth aspect of the embodiments of the present application provides a computer program product. The computer program product includes a non-transitory computer-readable storage medium storing a computer program. The computer program is operable to cause a computer to execute some or all of the steps described in the first aspect of the embodiments of the present application. The computer program product can be a software installation package.

[0014] Implementing the embodiments of the present application has at least the following beneficial effects: The first indication information can be sent to the first thread. The first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write a write set of the target block into a preset cache; while sending the first indication information to the first thread, the second indication information is sent to the second thread. The second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set; after the MVCC verification on the first block set is completed, the write set corresponding to the first block set is written into the preset cache. In this way, multi-threaded MVCC verification of multiple blocks can be achieved through the parallel processing of the first thread and the second thread, which is beneficial to improving the efficiency of MVCC verification; and is beneficial to improving the data verification efficiency. Description of the Drawings

[0015] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other accompanying drawings can be obtained based on these drawings.

[0016] Figure 1A This is a schematic diagram of a network architecture for data verification provided by an embodiment of the present application;

[0017] Figure 1B This is a schematic flowchart of a data verification method provided by an embodiment of the present application;

[0018] Figure 2 This is a schematic flowchart of a data verification method provided by an embodiment of the present application;

[0019] Figure 3 This is a schematic flowchart of a data verification method provided by an embodiment of the present application;

[0020] Figure 4 This is a schematic diagram of the structure of a server provided by an embodiment of the present application;

[0021] Figure 5 This is a schematic diagram of the structure of a data verification device provided by an embodiment of the present application. Detailed implementation manners

[0022] The following will clearly and completely describe the technical solutions in the embodiments of the present application with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some embodiments of the present application, rather than all embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of protection of the present application.

[0023] The terms "first", "second", etc. in the specification and claims of the present application and the above accompanying drawings are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or device that includes a series of steps or units is not limited to the listed steps or units, but optionally further includes steps or units not listed, or optionally further includes other steps or units inherent to these processes, methods, products, or devices.

[0024] References to "embodiments" in this application mean that specific features, structures, or characteristics described in connection with the embodiments can be included in at least one embodiment of this application. The phrase appears in various places in the specification and does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment mutually exclusive with other embodiments. Those skilled in the art will explicitly and implicitly understand that the embodiments described in this application can be combined with other embodiments.

[0025] To better understand the embodiments of this application, the methods applying the embodiments of this application will be introduced below.

[0026] The server mentioned in the embodiments of this application can include, but is not limited to, a background server, a component server, a cloud server, a data verification system server, or a data verification software server, etc. The above are only examples, not an exhaustive list, and include but are not limited to the above devices.

[0027] Please refer to Figure 1A , Figure 1A which is a schematic diagram of a network architecture for data verification provided by the embodiments of this application.

[0028] Among them, the embodiments of this application are applied to a server, in which a blockchain network can be deployed. Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithm. Blockchain, in essence, is a decentralized database, a string of data blocks generated by using cryptographic methods. Each data block contains information about a batch of network transactions, used to verify the validity (anti-counterfeiting) of the information and generate the next block. Blockchain can include a blockchain underlying platform, a platform product service layer, and an application service layer.

[0029] Among them, the embodiments of this application can be specifically applied to the FiMax blockchain platform. The FiMax blockchain platform is a blockchain network composed based on the S3C framework. The S3C is a framework system composed of a blockchain solution module, a blockchain kernel module, a blockchain privacy protection module, and a blockchain network management module.

[0030] Among them, as Figure 1A shown, the network architecture can include a read set database, a write set database, a first queue, a second queue, a write set cache, and a Multi-Version Concurrency Control (MVCC) module.

[0031] Among them, the above MVCC module is used for verifying the version of the transaction data corresponding to each transaction information in the block. The above block can be the basic unit structure in the blockchain network, and each block consists of a block header and a block body. Among them, the block header stores structured data, and the block body is generally a tree structure for recording the transaction information of the block. And the above MVCC module is mainly used to verify whether the data version corresponding to the above transaction information is correct. If the read set version used in the current transaction is not equal to the read set version in the current database, the transaction is considered outdated and marked as an incorrect transaction.

[0032] In addition, as Figure 1A shown, it may further include a first thread and a second thread. Among them, the first thread can be used to read data (such as: blocks) from the database. Multiple transactions can be packaged in the block, and each transaction corresponds to transaction data. The second thread can be used to perform MVCC verification on the transaction data included in the block.

[0033] Among them, the above first queue can be used to store the blocks processed by the first thread, and the second queue can be used to store the blocks after MVCC verification.

[0034] In the embodiment of the present application, the read set database and the write set database in the database can be partially separated, and the database can be accessed through multiple threads (2 or more threads). The write set data in the database is stored in the cache. When implementing the above MVCC version verification, the write set in the cache can be directly accessed without waiting for the database write cache, which is beneficial to improving the writing performance of the database and avoiding data blocking during writing.

[0035] Please refer to Figure 1B , Figure 1B which is a schematic flowchart of a data verification method provided by the embodiment of the present application and is applied to a server. The above method includes the following steps:

[0036] 101. Send a first indication message to the first thread. The first indication message is used to instruct the first thread to obtain a target block from the database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache.

[0037] Among them, the above preset ordered queue can be set by the user or defaulted by the system, which is not limited here. The preset ordered queue can correspond to the first queue as Figure 1A shown, and the above database can be the read set database as Figure 1A shown.

[0038] Among them, the above target block can be any block that needs transaction verification and storage. The above preset cache can be set by the user or defaulted by the system, which is not limited here. The preset cache can correspond to such asFigure 1A The cache shown.

[0039] Among them, the above first indication information can be set by the user himself or be the system default, which is not limited here; it can be used to indicate the above second thread to obtain new blocks from the database.

[0040] Among them, the above first thread can correspond to the first thread as Figure 1A shown. This first thread can be used to obtain target blocks from the read set database corresponding to the database. After processing the target blocks, write sets corresponding to them are written into the above preset cache. When performing MVCC verification later, relevant information in the write sets of the target blocks can be directly obtained from this preset cache. For example, at least one transaction packaged in the block. Generally, tens of thousands of transaction data can be packaged in each block; thus, there is no need to frequently access the above database to reduce the access pressure on the database; at the same time, directly obtaining data from the preset cache is beneficial to improving the efficiency of data verification.

[0041] In a possible example, after indicating the first thread to obtain target blocks from the database, the following steps may further be included: determining whether there is a conflict between the read set of the target block and multiple write sets in the preset cache, where the preset cache includes multiple blocks, and each block corresponds to a write set.

[0042] Among them, in the embodiments of the present application, only the target block is used as an example for illustration, which is not limited here, and the acquisition of blocks and related processes thereof may be the same as those of the target block.

[0043] Among them, multiple write sets corresponding to multiple blocks obtained before the target block can be stored in the above preset cache, and each block can correspond to a write set, so that when performing MVCC verification later, the second thread can directly obtain blocks from this preset ordered queue.

[0044] Among them, after obtaining the above target block through the first thread, the transaction data in the target block may be associated with the transaction data packaged in the write set database or other stored blocks in the preset cache. If they are associated, it will have an impact on its MVCC verification; for example, when performing MVCC verification on a transaction data in the target block, the transaction data in other blocks in the preset ordered queue may be used as reference data to verify the transaction situation of the target block, etc.; thus, when performing MVCC verification, since the blocks associated with the target block may cause conflicts or impacts on the MVCC verification process of it; therefore, before performing MVCC verification, conflict judgment can be performed on the target block and the remaining multiple blocks.

[0045] In a possible example, the steps of putting the target block into a preset ordered queue and writing the write set of the target block into a preset cache may include the following steps: If there is no conflict between the read set and any one of the write sets in the preset cache, then add the write set corresponding to the target block to the write set in the preset cache and put the target block into the preset ordered queue; if there is a conflict between the read set and any one of the write sets in the preset cache, then clear all the write sets in the preset cache, add the write set corresponding to the target block to the preset cache, and put the target block into the preset ordered queue.

[0046] Wherein, when there is no conflict between the target block and all the multiple blocks in the above-mentioned preset ordered queue, the write set of the target block can be added to the write set corresponding to the above-mentioned preset cache. In addition, the multiple blocks included in the write set corresponding to this cache are all non-conflicting.

[0047] Further, if the target block conflicts with any one of the blocks in the write set corresponding to the preset cache, then all the write sets in the cache can be deleted, and the write set data corresponding to the target block can be written into the write set in the preset cache; after completing the above steps, the target block can be placed in the preset ordered queue; the preset ordered queue may include multiple blocks.

[0048] In a possible example, after judging whether there is a conflict between the read set and the write set in the preset cache, the following steps may further be included: If there is no conflict between the read set and any one of the write sets in the preset cache, then obtain the current BundleNum and write the current BundleNum into the target block; if there is a conflict between the read set and any one of the write sets in the preset cache, then increment the current BundleNum by 1 to obtain the target BundleNum and write the target BundleNum into the target block.

[0049] Wherein, the above-mentioned BundleNum can be understood as a block code and can be used to mark blocks. When the BundleNums corresponding to two blocks are the same, it means that these two blocks are in the same bundle, or it can also be understood that they are in the same block set. That is to say, blocks with the same BundleNum are in the same block set.

[0050] Among them, after the read set corresponding to the target block is conflict-compared with the write sets corresponding to multiple blocks in the preset cache, the BundleNum can be written to the target block to distinguish the target block and achieve the classification of multiple blocks. In this way, when there is a conflict between the target block and the above-mentioned multiple blocks, even if the write sets of the above-mentioned multiple blocks are deleted from the write set in the preset cache, each block still retains its corresponding BundleNum. During the subsequent MVCC verification, each block can still be distinguished. Blocks with the same BundleNum indicate that they exist in the same block set.

[0051] Among them, the above current BundleNum is the BundleNum of the write set stored in the cache or the previous obtained block; if there is no conflict between the above target block and the previous block, the BundleNum of the previous block can be written into the target block, that is to say, the above two blocks exist in the same Bundle (set).

[0052] Among them, if there is a conflict between the target block and the previous block, a new bundle can be created, and 1 is added to the current BundleNum corresponding to the previous block to obtain the target BundleNum; and the target BundleNum is written into the target block, indicating that the target block and the previous block exist in different Bundles; in this way, the above steps 101 can be cyclically operated in the first thread to distinguish different blocks and place non-conflicting blocks in the same Bundle, which is beneficial to improving the efficiency of subsequent MVCC verification.

[0053] In a possible example, the judgment of whether there is a conflict between the read set of the target block and multiple write sets in the preset cache may include the following steps: obtaining at least one target transaction corresponding to the target block; determining at least one first key-value pair in the read set, each first key-value pair corresponding to one of the target transactions; determining multiple second key-value pairs included in the multiple write sets in the preset cache, each key-value pair corresponding to a transaction; if there is at least one first key-value pair equal to any one of the second key-value pairs, it is determined that there is a conflict between the read set and the multiple write sets in the preset cache; if any one of the first key-value pairs is not equal to any one of the second key-value pairs, it is determined that there is no conflict between the read set corresponding to the target block and the multiple write sets in the preset cache.

[0054] Among them, the above key-value pair is a mapping set of a key and a value, and the above key-value pair can also be a hash value, which is not specifically limited here.

[0055] Among them, the above key-value pairs can all carry data version numbers. The version of the key-value pair can be recorded in the read set of the block; the latest value of the key-value pair can be stored in the write set. In the database of the blockchain network, the current values of all key-value pairs can be recorded in the ledger, which is equivalent to indexing the transaction log of the current ledger. Whenever a transaction changes, the corresponding key-value pair will be updated accordingly, and the data in the corresponding database will also be updated. Therefore, the server can determine whether there is a conflict between blocks by comparing the first key-value pair in the read set of the target block with the latest values of the second key-value pairs stored in the write sets of each block in the preset cache.

[0056] In a specific implementation, the read set of the target block can be read from the database. The read set includes at least one target transaction, and each target transaction can correspond to a first key-value pair. Similarly, the second key-value pairs corresponding to each block in the preset cache can be obtained. If there is an association between the data of a certain target transaction in the target block and the transaction data corresponding to any one of the above-mentioned multiple blocks, then the key-value pairs corresponding to these two transactions will be updated, and the two key-value pairs are equal. Therefore, if any one of the first key-value pairs is equal to at least one of the second key-value pairs, it indicates that there is a conflict between the transaction data between the target block and the block corresponding to at least one second value pair, that is, there is a data association between the two transactions; conversely, if there is no case where any one of the first key-value pairs is equal to the second key-value pair, it indicates that there is no conflict between the target block and the above-mentioned multiple blocks, that is, there is no association.

[0057] 102. While sending the first indication information to the first thread, send the second indication information to the second thread. The second indication information is used to instruct the second thread to read the first block set from the preset ordered queue and perform MVCC verification on the first block set.

[0058] Among them, the above first thread and the second thread can be synchronized. While the first thread obtains a new block and processes the new block, the second thread can take out a batch of blocks that have been processed by the first thread in the previous period from the preset ordered queue and perform MVCC verification on the batch of blocks.

[0059] Among them, the above second indication information can be set by the user himself or be the system default, which is not limited here; it can be used to instruct the above second thread to complete MVCC verification.

[0060] Among them, the above first block set can include multiple first blocks. If the multiple first blocks exist in the same set, then the first BundleNum corresponding to the multiple first blocks is the same, and it indicates that there is no conflict between the multiple first blocks.

[0061] After the above MVCC verification is completed, the verification result data corresponding to each block can be written into the write set database, so as to record the verification results of the above transactions or view them again to inform the database that the MVCC verification of the above block has been completed, etc.

[0062] In a possible example, the MVCC verification of the first block set may include the following steps: determining a first BundleNum corresponding to the first block set, where the first block set includes a plurality of first blocks, and each first block corresponds to the same first BundleNum; obtaining a second BundleNum corresponding to a second block set currently undergoing the MVCC verification, where the second block set includes a plurality of second blocks, and each second block corresponds to the second BundleNum; if the first BundleNum is equal to the second BundleNum, then perform the MVCC verification on the second block set and the first block set in parallel; if the first BundleNum is not equal to the second BundleNum, then wait until the MVCC verification of the second block set is completed, and then perform the MVCC verification on the first block set.

[0063] In the embodiment of the present application, only two block sets are taken as examples for illustration. For example, Figure 1A the MVCC module shown can currently verify multiple block sets in parallel or serially.

[0064] In a specific implementation, each first block in the first block set corresponds to the same first BundleNum; when a second thread obtains a plurality of first blocks corresponding to the first block set from a preset ordered queue, the MVCC module corresponding to the current second thread may be performing MVCC verification on the above second block set, and each second block in the second block set may correspond to the same BundleNum; furthermore, by comparing the first BundleNum with the second BundleNum, if they are equal, it indicates that the first blocks in the first block set and the second blocks in the second block set do not conflict, that is, there is no data association between them, so the MVCC verification can be performed in parallel on the plurality of first blocks corresponding to the first block set and the plurality of second blocks corresponding to the second block set.

[0065] Furthermore, on the contrary, it indicates that the transaction data corresponding to the first block set is associated with the transaction data corresponding to the second block set, so the above MVCC verification cannot be performed in parallel, and the MVCC verification can be performed serially on the above plurality of first blocks and second blocks, that is, wait until the verification of the plurality of second blocks in the second block set is completed, and then perform the MVCC verification on the plurality of first blocks.

[0066] Among them, the above Bundle is used to store multiple non - conflicting blocks. Further, when performing MVCC verification, the blocks in the same Bundle can be verified for MVCC simultaneously, which is beneficial to improving the efficiency of subsequent MVCC verification and alleviating the database pressure caused by high - concurrency verification.

[0067] In a possible example, the performing the MVCC verification on the first block set may include the following steps: determining at least one transaction data included in each of the first blocks; and performing the MVCC verification on at least one transaction data corresponding to each first block in parallel according to the multiple first blocks.

[0068] Among them, when the MVCC module in the above - mentioned second thread verifies a block, the basic unit may be the transaction data corresponding to each transaction.

[0069] In a specific implementation, at least one transaction data corresponding to each target transaction in at least one target transaction corresponding to each block can be determined to obtain at least one transaction data; the data version number corresponding to each transaction data is obtained to obtain at least one data version number; each data version number is compared with a preset version number. If each data version number is the same as the preset version number, it is determined that the MVCC verification of the target block is successful; if there is one data version number different from the preset version number, it is determined that the MVCC verification of the target block fails.

[0070] Among them, the above - mentioned preset version number can be set by the user himself or be the system default, which is not limited here. The preset version number can be set by the background staff. For example, it can be 100 or 200, etc. If the MVCC verification of a transaction is successful, it indicates that the transaction is valid. Then the block corresponding to the transaction can be stored in the local chain, and the corresponding result data of the successful verification can be stored in the database.

[0071] It can be seen that in the embodiment of the present application, since when the first thread obtains blocks and classifies the blocks, the multiple blocks in the block set corresponding to the same BundleNum do not conflict with each other. Therefore, parallel MVCC verification can be performed on the multiple first blocks in the first block set, which is beneficial to improving the data verification efficiency.

[0072] 103. After completing the MVCC verification on the first block set, write the write set corresponding to the first block set into the preset cache.

[0073] After the verification of the first block set is completed, the write sets corresponding to the multiple first blocks in the first block set can be written into the preset cache, so that after obtaining the next new block, before performing the MVCC verification, the new block is compared with the first blocks in the preset cache for conflicts to determine whether there are conflicts between the new block and the multiple first blocks, which is beneficial to improving the verification efficiency.

[0074] It can be seen that the data verification method described in the embodiments of the present application is applied to a server, and can send a first indication message to a first thread. The first indication message is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into the preset cache; while sending the first indication message to the first thread, send a second indication message to a second thread. The second indication message is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set. After the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into the preset cache. In this way, through the parallel processing of the first thread and the second thread, multi-threaded MVCC verification of multiple blocks can be realized, which is beneficial to improving the efficiency of MVCC verification; and is beneficial to improving the data verification efficiency.

[0075] Consistent with the above, please refer to Figure 2 , Figure 2 is a flowchart example of a data verification method disclosed in the embodiments of the present application, which is applied to a server. The data verification method may include the following steps:

[0076] 201. Send a third indication message to a third thread, where the third indication message is used to instruct the third thread to perform identity authentication and signature authentication on each target transaction respectively.

[0077] Among them, the above-mentioned third indication message can be set by the user himself or be the system default, which is not limited herein; the third indication message can be used to implement identity verification and signature authentication of each target transaction in the target block through the third thread before the MVCC verification.

[0078] Among them, each of the above-mentioned target transactions may include transaction data, and the transaction data may include at least one of the following: version number, block ID, data key-value pair, certificate information, signature information, public key, private key, etc., which is not limited herein.

[0079] Among them, the above-mentioned identity (Verify Authority Chain Code, VACC) authentication is to verify whether the initiator of this transaction has the permission to initiate this transaction through the certificate information corresponding to the transaction data in the target block.

[0080] Among them, the above-mentioned signature (Verify Signature Chain Code, VSCC) authentication is to verify whether the number of executors of this transaction meets the requirements and whether the signatures of the transaction executors included in the transaction data are correct.

[0081] Among them, the above-mentioned Multi-Version Concurrency Control (MVCC) verification is a concurrency control method used to verify whether the data version of the transaction data included in the above block is correct; that is, to check whether the read set of the transaction in the block is consistent with the version in the current database ledger (that is, there is no change). If there is no change, it means that the modification of the data in the write set of the transaction is valid, mark the transaction as valid, and update the write set of the transaction to the specific database (such as the write set database of the state database).

[0082] 202. If any one of the target transaction identity authentication fails or the signature authentication fails, terminate the data verification step for the target transaction. The data verification includes: signature authentication or MVCC verification.

[0083] Among them, generally, identity authentication, signature authentication, and MVCC verification can be performed on each transaction respectively to verify whether the transaction data is correct and whether the initiating trader has the permission, etc. Furthermore, the verified data can be stored in the corresponding database to ensure the security of the transaction data.

[0084] In specific implementation, the transaction data included in any one of the above target transactions can be verified respectively. If any one of the above signature authentication, identity authentication, or MVCC verification fails, terminate the subsequent authentication.

[0085] 203. Send a first indication message to the first thread. The first indication message is used to instruct the first thread to obtain a target block from the database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache.

[0086] 204. While sending the first indication message to the first thread, send a second indication message to the second thread. The second indication message is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set.

[0087] 205. After completing the MVCC verification of the first block set, write the write set corresponding to the first block set into the preset cache.

[0088] Among them, the specific description of the above steps 203-204 can refer to Figure 1BThe corresponding description of the data verification method is not elaborated here.

[0089] It can be seen that the data verification method described in the embodiments of the present application is applied to a server, and sends third indication information to a third thread, where the third indication information is used to instruct the third thread to perform identity authentication and signature authentication on each target transaction respectively; if any one of the target transaction identity authentications fails or the signature authentication fails, the data verification step for the target transaction is terminated, and the data verification includes: signature authentication or MVCC verification; sending first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache; while sending the first indication information to the first thread, sending second indication information to a second thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set, and after the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into the preset cache. In this way, identity authentication, signature authentication, and MVCC verification can be performed on each transaction in the block respectively. If any one of the authentications or verifications fails, the above verification steps are aborted; if the above identity authentication and signature authentication are successful, the MVCC verification of the block is continued, which is beneficial to reducing the pressure in the database to avoid performing invalid verifications, and thus is beneficial to improving the performance of the blockchain network.

[0090] Consistent with the above, please refer to Figure 3 , Figure 3 is a flowchart example of a data verification method disclosed in the embodiments of the present application, which is applied to a server. The data verification method may include the following steps:

[0091] 301. Send first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, and determine whether there is a conflict between the read set of the target block and multiple write sets in a preset cache, where the preset cache includes multiple blocks, and each block corresponds to a write set.

[0092] 302. If there is no conflict between the read set and any one of the write sets in the preset cache, then execute adding the write set corresponding to the target block to the write sets in the preset cache, and putting the target block into a preset ordered queue.

[0093] 303. If there is a conflict between the read set and any one of the write sets in the preset cache, then execute clearing the multiple write sets in the preset cache, adding the write set corresponding to the target block to the preset cache, and putting the target block into the preset ordered queue.

[0094] 304. While sending the first indication information to the first thread, send second indication information to a second thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and determine a first BundleNum corresponding to the first block set, and the first block set includes a plurality of first blocks, and each first block corresponds to the same first BundleNum.

[0095] 305. Obtain a second BundleNum corresponding to a second block set for which the MVCC verification is currently being performed, where the second block set includes a plurality of second blocks, and each second block corresponds to the second BundleNum.

[0096] 306. If the first BundleNum is equal to the second BundleNum, perform the MVCC verification on the second block set and the first block set in parallel.

[0097] 307. If the first BundleNum is not equal to the second BundleNum, perform the MVCC verification on the first block set after waiting for the MVCC verification of the second block set to be completed.

[0098] 308. After the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into a preset cache.

[0099] The specific descriptions of the above steps 301-308 may refer to Figure 1B the corresponding descriptions of the data verification method, which will not be elaborated here.

[0100] It can be seen that the data verification method described in the embodiments of this application is applied to a server, which sends first indication information to a first thread. The first indication information is used to instruct the first thread to obtain a target block from a database, and determine whether there is a conflict between the read set of the target block and multiple write sets in a preset cache. The preset cache includes multiple blocks, and each block corresponds to a write set. If there is no conflict between the read set and any one of the write sets in the preset cache, then perform the operation of adding the write set corresponding to the target block to the write sets in the preset cache, and putting the target block into a preset ordered queue. If there is a conflict between the read set and any one of the write sets in the preset cache, then perform the operation of clearing the multiple write sets in the preset cache, adding the write set corresponding to the target block to the preset cache, and putting the target block into the preset ordered queue. While sending the first indication information to the first thread, send second indication information to a second thread. The second indication information is used to instruct the second thread to read a first block set from the preset ordered queue, and determine a first BundleNum corresponding to the first block set. The first block set includes multiple first blocks, and each first block corresponds to the same first BundleNum. Obtain a second BundleNum corresponding to a second block set currently undergoing MVCC verification. The second block set includes multiple second blocks, and each second block corresponds to a second BundleNum. If the first BundleNum is equal to the second BundleNum, then perform the MVCC verification on the second block set and the first block set in parallel. If the first BundleNum is not equal to the second BundleNum, then perform the operation of waiting until the MVCC verification of the second block set is completed, and then perform the MVCC verification on the first block set. After the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into the preset cache. In this way, blocks without conflict can be placed in the same set, and blocks with conflict can be placed in different sets, which is beneficial to realizing the classification of blocks. And when performing MVCC verification subsequently, two block sets without conflict can be verified in parallel, and conversely, two block sets with conflict can be verified serially, which is beneficial to improving the efficiency of data verification.

[0101] Consistently with the above, please refer to Figure 4 , Figure 4 which is a schematic structural diagram of a server provided by an embodiment of this application, as Figure 4As shown, it includes a processor, a communication interface, a memory, and one or more programs. The processor, communication interface, and memory are interconnected. Among them, the memory is used to store computer programs, and the computer programs include program instructions. The processor is configured to call the program instructions. The above one or more programs include instructions for performing the following steps:

[0102] Send first indication information to a first thread. The first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache.

[0103] While sending the first indication information to the first thread, send second indication information to a second thread. The second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set.

[0104] It can be seen that the server described in the embodiment of the present application can send first indication information to the first thread. The first indication information is used to instruct the first thread to obtain a target block from the database, put the target block into the preset ordered queue, and write the write set of the target block into the preset cache. While sending the first indication information to the first thread, send second indication information to the second thread. The second indication information is used to instruct the second thread to read the first block set from the preset ordered queue and perform MVCC verification on the first block set. After the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into the preset cache. In this way, multi-threaded MVCC verification of multiple blocks can be realized through the parallel processing of the first thread and the second thread, which is beneficial to improving the efficiency of MVCC verification and beneficial to improving the data verification efficiency.

[0105] In a possible example, after instructing the first thread to obtain a target block from the database, the program includes instructions for performing the following steps:

[0106] Judge whether there is a conflict between the read set of the target block and multiple write sets in the preset cache, where the preset cache includes multiple blocks, and each block corresponds to a write set.

[0107] In a possible example, in terms of putting the target block into the preset ordered queue and writing the write set of the target block into the preset cache, the program includes instructions for performing the following steps:

[0108] If there is no conflict between the read set and any one of the write sets in the preset cache, then execute adding the write set corresponding to the target block to the write sets in the preset cache and putting the target block into the preset ordered queue.

[0109] If there is a conflict between the read set and any one of the write sets in the preset cache, clear the multiple write sets in the preset cache, add the write set corresponding to the target block to the preset cache, and put the target block into the preset ordered queue.

[0110] In a possible example, after determining whether there is a conflict between the read set and the write sets in the preset cache, the program executes instructions for the following steps:

[0111] If there is no conflict between the read set and any one of the write sets in the preset cache, obtain the current BundleNum and write the current BundleNum into the target block;

[0112] If there is a conflict between the read set and any one of the write sets in the preset cache, increment the current BundleNum by 1 to obtain the target BundleNum, and write the target BundleNum into the target block.

[0113] In a possible example, in determining whether there is a conflict between the read set of the target block and multiple write sets in the preset cache, the program executes instructions for the following steps:

[0114] Obtain at least one target transaction corresponding to the target block;

[0115] Determine at least one first key-value pair in the read set, with each first key-value pair corresponding to one of the target transactions;

[0116] Determine multiple second key-value pairs included in the multiple write sets in the preset cache, with each key-value pair corresponding to a transaction;

[0117] If there is at least one first key-value pair equal to any one of the second key-value pairs, determine that there is a conflict between the read set and the multiple write sets in the preset cache;

[0118] If none of the first key-value pairs is equal to any of the second key-value pairs, determine that there is no conflict between the read set corresponding to the target block and the multiple write sets in the preset cache.

[0119] In a possible example, before instructing the first thread to obtain the target block from the database, the program executes instructions for the following steps:

[0120] Send third indication information to a third thread, where the third indication information is used to instruct the third thread to perform identity authentication and signature authentication on each target transaction respectively;

[0121] If any target transaction identity authentication fails or signature authentication fails, the data verification step for the target transaction is terminated, and the data verification includes: signature authentication or MVCC verification.

[0122] In a possible example, in terms of performing MVCC verification on the first block set, the program is used to execute instructions for the following steps:

[0123] Determine the first BundleNum corresponding to the first block set, where the first block set includes multiple first blocks, and each first block corresponds to the same first BundleNum;

[0124] Obtain the second BundleNum corresponding to the second block set currently undergoing the MVCC verification, where the second block set includes multiple second blocks, and each second block corresponds to the second BundleNum;

[0125] If the first BundleNum is equal to the second BundleNum, perform the MVCC verification on the second block set and the first block set in parallel;

[0126] If the first BundleNum is not equal to the second BundleNum, perform the MVCC verification on the first block set after waiting for the MVCC verification of the second block set to complete.

[0127] In a possible example, in terms of performing the MVCC verification on the first block set, the program is used to execute instructions for the following steps:

[0128] Determine at least one transaction data included in each of the first blocks;

[0129] According to the multiple first blocks, perform the MVCC verification on at least one transaction data corresponding to each first block in parallel.

[0130] The above mainly introduces the solution of the embodiment of the present application from the perspective of the execution process on the method side. It can be understood that in order for the server to implement the above functions, it includes the corresponding hardware structure and / or software module for executing each function. Those skilled in the art should easily realize that, combined with the units and algorithm steps of each example described in the embodiments provided in this article, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed in the way of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered to exceed the scope of the present application.

[0131] In the embodiments of the present application, the server can be divided into functional units according to the above method examples. For example, each functional unit can be divided corresponding to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of a software functional unit. It should be noted that the division of units in the embodiments of the present application is illustrative, only a logical function division, and there can be other division methods in actual implementation.

[0132] Consistently with the above, please refer to Figure 5 , Figure 5 which is a schematic structural diagram of a data verification device disclosed in the embodiments of the present application and is applied to a server. The device includes: a first sending unit 501, a second sending unit 502, and a writing unit 503, where

[0133] The first sending unit 501 is configured to send first indication information to a first thread. The first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache.

[0134] The second sending unit 502 is configured to send second indication information to a second thread while sending the first indication information to the first thread. The second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set.

[0135] The writing unit 503 is configured to write the write set corresponding to the first block set into the preset cache after the MVCC verification of the first block set is completed.

[0136] It can be seen that the data verification device described in the embodiments of the present application, which is applied to a server, can send first indication information to a first thread. The first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache. While sending the first indication information to the first thread, send second indication information to a second thread. The second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set. After the MVCC verification of the first block set is completed, write the write set corresponding to the first block set into the preset cache. In this way, multi-threaded MVCC verification of multiple blocks can be realized through the parallel processing of the first thread and the second thread, which is beneficial to improving the efficiency of MVCC verification and beneficial to improving the data verification efficiency.

[0137] In a possible example, in the aspect of putting the target block into a preset ordered queue and writing the write set of the target block into a preset cache, the first sending unit 501 is specifically configured to:

[0138] If there is no conflict between the read set and any one of the write sets in the preset cache, add the write set corresponding to the target block to the write sets in the preset cache and put the target block into the preset ordered queue;

[0139] If there is a conflict between the read set and any one of the write sets in the preset cache, clear the multiple write sets in the preset cache, add the write set corresponding to the target block to the preset cache, and put the target block into the preset ordered queue.

[0140] In a possible example, in the aspect of performing MVCC verification on the first block set, the second sending unit 502 is specifically configured to:

[0141] Determine the first BundleNum corresponding to the first block set, where the first block set includes multiple first blocks, and each first block corresponds to the same first BundleNum;

[0142] Obtain the second BundleNum corresponding to the second block set currently undergoing the MVCC verification, where the second block set includes multiple second blocks, and each second block corresponds to the second BundleNum;

[0143] If the first BundleNum is equal to the second BundleNum, perform the MVCC verification on the second block set and the first block set in parallel;

[0144] If the first BundleNum is not equal to the second BundleNum, wait until the MVCC verification of the second block set is completed, and then perform the MVCC verification on the first block set.

[0145] In a possible example, in the aspect of performing the MVCC verification on the first block set, the second sending unit 502 is specifically further configured to:

[0146] Determine at least one piece of transaction data included in each of the first blocks;

[0147] According to the multiple first blocks, perform the MVCC verification on at least one piece of transaction data corresponding to each first block in parallel.

[0148] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer storage medium stores a computer program for electronic data exchange, and the computer program causes the computer to execute some or all of the steps of any one of the data verification methods described in the foregoing method embodiments.

[0149] An embodiment of the present application further provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause the computer to execute some or all of the steps of any one of the data verification methods described in the foregoing method embodiments.

[0150] It should be noted that, for the foregoing method embodiments, for the sake of simple description, they are all expressed as a series of action combinations. However, those skilled in the art should know that the present application is not limited by the described action sequence, because according to the present application, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the present application.

[0151] In the above embodiments, the descriptions of the various embodiments have their own emphases. For the parts not detailed in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0152] In several embodiments provided by the present application, it should be understood that the disclosed device can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the displayed or discussed mutual coupling or direct coupling or communication connection can be through some interfaces, and the indirect coupling or communication connection of the device or unit can be in an electrical or other form.

[0153] The units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they can be located in one place, or can be distributed to multiple network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0154] In addition, in each embodiment of the present application, the functional units can be integrated in one processing unit, or each unit can exist physically alone, or two or more units can be integrated in one unit. The above integrated units can be implemented in the form of hardware or in the form of software program modules.

[0155] When the integrated unit is implemented in the form of a software program module and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or all or part of this technical solution, can be embodied in the form of a software product. This computer software product is stored in a memory and includes several instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application. And the aforementioned memory includes: USB flash drives, read-only memory (ROM), random access memory (RAM), mobile hard disks, magnetic disks, or optical discs, etc., which are various media that can store program codes.

[0156] Those of ordinary skill in the art can understand that all or part of the steps in the various methods of the above embodiments can be completed by instructing relevant hardware through a program. This program can be stored in a computer-readable memory, and the memory can include: flash drives, ROM, RAM, magnetic disks, or optical discs, etc.

[0157] The above has introduced the embodiments of the present application in detail. Specific examples are used in this article to elaborate on the principles and implementation manners of the present application. The description of the above embodiments is only used to help understand the method and its core idea of the present application; at the same time, for those of ordinary skill in the art, according to the idea of the present application, there will be changes in the specific implementation manners and application scopes. In summary, the content of this specification should not be construed as a limitation to the present application.

Claims

1. A data verification method, characterized in that, Applied to a server, including: Sending first indication information to a first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache; While sending the first indication information to the first thread, sending second indication information to a second thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set, and an MVCC module is used to verify the version of the transaction data corresponding to each transaction information in the block; After the MVCC verification of the first block set is completed, writing the write set corresponding to the first block set into the preset cache; Among them, the performing MVCC verification on the first block set includes: determining a first BundleNum corresponding to the first block set, where the first block set includes multiple first blocks, and each first block corresponds to the same first BundleNum; obtaining a second BundleNum corresponding to a second block set currently undergoing the MVCC verification, where the second block set includes multiple second blocks, and each second block corresponds to the second BundleNum; if the first BundleNum is equal to the second BundleNum, then performing the MVCC verification on the second block set and the first block set in parallel; if the first BundleNum is not equal to the second BundleNum, then performing the MVCC verification on the first block set after waiting for the MVCC verification of the second block set to be completed, where the first BundleNum and the second BundleNum are both block codes used to mark blocks.

2. The method according to claim 1, characterized in that, After the instructing the first thread to obtain a target block from the database, the method further includes: Judging whether there is a conflict between the read set of the target block and multiple write sets in the preset cache, where the preset cache includes multiple blocks, and each block corresponds to a write set; The putting the target block into the preset ordered queue and writing the write set of the target block into the preset cache includes: If there is no conflict between the read set and any one of the write sets in the preset cache, then adding the write set corresponding to the target block to the write sets in the preset cache and putting the target block into the preset ordered queue; If there is a conflict between the read set and any one of the write sets in the preset cache, then clearing the multiple write sets in the preset cache, adding the write set corresponding to the target block to the preset cache, and putting the target block into the preset ordered queue.

3. The method according to claim 2, characterized in that, After the judging whether there is a conflict between the read set of the target block and multiple write sets in the preset cache, the method further includes: If there is no conflict between the read set and any of the write sets in the preset cache, then execute to obtain the current BundleNum and write the current BundleNum into the target block; If there is a conflict between the read set and any of the write sets in the preset cache, then execute to increment the current BundleNum by 1 to obtain the target BundleNum and write the target BundleNum into the target block.

4. The method according to claim 2 or 3, characterized in that, The determination of whether there is a conflict between the read set of the target block and multiple write sets in the preset cache includes: Obtain at least one target transaction corresponding to the target block; Determine at least one first key-value pair in the read set, with each first key-value pair corresponding to one of the target transactions; Determine multiple second key-value pairs included in multiple write sets in the preset cache, with each key-value pair corresponding to a transaction; If there is at least one first key-value pair that is equal to any one of the second key-value pairs, then determine that there is a conflict between the read set and multiple write sets in the preset cache; If any one of the first key-value pairs is not equal to any one of the second key-value pairs, then determine that there is no conflict between the read set corresponding to the target block and multiple write sets in the preset cache.

5. The method according to claim 1, characterized in that, Before sending the first indication information to the first thread, the method further includes: Send third indication information to the third thread, where the third indication information is used to instruct the third thread to perform identity authentication and signature authentication on each target transaction respectively; If there is any target transaction with failed identity authentication or failed signature authentication, then terminate the data verification step for the target transaction, and the data verification includes: signature authentication or MVCC verification.

6. The method according to claim 5, characterized in that, The performing of the MVCC verification on the first block set includes: Determine at least one transaction data included in each of the first blocks; According to the multiple first blocks, perform the MVCC verification on at least one transaction data corresponding to each first block in parallel.

7. A data verification device for performing the method according to any one of claims 1-6, characterized in that, Applied to a server, the device includes: a first sending unit, a second sending unit, and a writing unit, where, The first sending unit is used to send first indication information to the first thread, where the first indication information is used to instruct the first thread to obtain a target block from a database, put the target block into a preset ordered queue, and write the write set of the target block into a preset cache; The second sending unit is used to send second indication information to the second thread while sending the first indication information to the first thread, where the second indication information is used to instruct the second thread to read a first block set from the preset ordered queue and perform MVCC verification on the first block set, and the MVCC module is used to perform version verification on the transaction data corresponding to each transaction information in the block; The writing unit is used to write the write set corresponding to the first block set into the preset cache after the MVCC verification on the first block set is completed.

8. A server, characterized in that, Comprising a processor, a communication interface, a memory, and one or more programs, the processor, the communication interface, and the memory are interconnected, wherein the memory is used to store computer programs, the computer programs include program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1-6.

9. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, the computer program includes program instructions, and the program instructions, when executed by the processor, cause the processor to execute the method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Conflict detection method for transactional memory, transactional memory system and microprocessor

    CN105389161A

  • Contract conflict detection method and device, readable storage medium and computer device

    CN110443712A

  • Block chain transaction processing method, device, computer equipment and storage medium

    CN110781196A

  • Asynchronous processing of blockchain blocks

    CN111418183A