Conflict detection method and device, equipment, storage medium and product

Through parallel execution and conflict detection methods, transaction invalidity caused by inter-transaction conflicts is solved, and transaction execution efficiency is improved.

CN120198216APending Publication Date: 2025-06-24TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311782273.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2025-06-24

AI Technical Summary

Technical Problem

In the process of executing multiple transactions to be executed in parallel, there is a situation where the transaction is invalid due to conflicts between transactions.

Method used

By obtaining multiple transactions to be executed from the channel, executing these transactions in parallel, and comparing the read and output items of each transaction, a conflicting transaction is determined, and distributing it into the channel for execution again.

Benefits of technology

By conducting conflict detection on parallel transactions and redistributing conflict transactions, adjusting the execution time of transactions, improving transaction invalidity due to conflicts between transactions, and improving transaction execution efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120198216A_ABST
    Figure CN120198216A_ABST
Patent Text Reader

Abstract

The embodiment of the invention discloses a conflict detection method and device, equipment, a storage medium and a product. The method comprises the steps of obtaining N to-be-executed transactions from a plurality of to-be-executed transactions in a channel, executing the N to-be-executed transactions in parallel to obtain execution information of the N to-be-executed transactions, and if a read item associated with a first to-be-executed transaction is included in output items of k to-be-executed transactions corresponding to the first to-be-executed transaction, executing the N to-be-executed transactions in parallel to obtain the execution information of the N to-be-executed transactions. If yes, it is judged that the first to-be-executed transaction is a conflict transaction, the first to-be-executed transaction is distributed to the channel to execute the first to-be-executed transaction again, and the k to-be-executed transactions are non-conflict transactions with the execution completion time before the first to-be-executed transaction in the N to-be-executed transactions. Visibly, the execution time of the conflicting transactions is adjusted by performing conflict detection on the parallel transactions and redistributing the conflicting transactions to the channels, so that the condition that the transactions are invalid due to conflicts among the transactions can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer technologies, and particularly to a conflict detection method, a conflict detection device, a computer device, a computer-readable storage medium, and a conflict detection product. Background Art

[0002] With the progress of scientific and technological research, more and more transactions have shifted from offline to online. As the number of online transactions continues to increase, in order to meet the data throughput, multiple pending transactions are usually executed in parallel to improve the transaction execution efficiency; for example, when nodes in a blockchain network package transactions that meet the conditions for being added to the blockchain into a block, in order to meet the throughput of the blockchain network, multiple pending transactions are usually executed in parallel to improve the (transaction) execution efficiency of the nodes in the blockchain network. It is found that during the parallel execution of multiple pending transactions, there are situations where transactions become invalid due to conflicts between transactions. Summary of the Invention

[0003] Embodiments of this application provide a conflict detection method, device, equipment, computer-readable storage medium, and product, which can improve the situation where transactions become invalid due to conflicts between transactions.

[0004] On the one hand, embodiments of this application provide a conflict detection method, including:

[0005] Obtaining N pending transactions from multiple pending transactions in a channel, where N is an integer greater than 1;

[0006] Executing the N pending transactions in parallel to obtain execution information of the N pending transactions. The execution information of any one of the pending transactions includes the read items and output items associated with the pending transaction;

[0007] If the read items associated with a first pending transaction are included in the output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a conflict transaction, and the first pending transaction is distributed to the channel to re-execute the first pending transaction; the k pending transactions are non-conflict transactions among the N pending transactions whose execution completion time is before the first pending transaction. The first pending transaction is any one of the N pending transactions, and k is a natural number less than N.

[0008] On the one hand, embodiments of this application provide a conflict detection device, and the conflict detection device includes:

[0009] An obtaining unit, configured to obtain N pending transactions from multiple pending transactions in a channel, where N is an integer greater than 1;

[0010] A processing unit for executing N pending transactions in parallel to obtain execution information of the N pending transactions. The execution information of any one of the pending transactions includes the read items and output items associated with the pending transaction;

[0011] And if the read items associated with the first pending transaction are included in the output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a conflicting transaction, and the first pending transaction is distributed to a channel to execute the first pending transaction again; the k pending transactions are non-conflicting transactions among the N pending transactions whose execution completion time is before the first pending transaction. The first pending transaction is any one of the N pending transactions, and k is a natural number less than N.

[0012] In one implementation, the processing unit is further configured to:

[0013] If the read items associated with the first pending transaction are not included in the output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a non-conflicting transaction.

[0014] In one implementation, the execution information of any one of the pending transactions further includes the serial number of the pending transaction. The serial number of any one of the pending transactions is used to indicate the execution order of the pending transaction; if the first pending transaction is a non-conflicting transaction, the processing unit is further configured to:

[0015] Add the first pending transaction to the target shard;

[0016] Wherein, the target shard belongs to a transaction queue. The transaction queue includes at least one shard. The serial numbers of the pending transactions belonging to the same shard are the same, and the k pending transactions are included in the target shard.

[0017] In one implementation, if the first pending transaction is a non-conflicting transaction, the processing unit is further configured to:

[0018] Update the write set based on the output items of the first pending transaction to obtain an updated write set;

[0019] Wherein, the write set before the update includes the output items of M non-conflicting transactions associated with the target block. The execution completion times of the M non-conflicting transactions associated with the target block are before the start of the N pending transactions, and M is a natural number.

[0020] In one implementation, the fact that the read items associated with the first pending transaction are included in the output items of k pending transactions corresponding to the first pending transaction means that: the output items of the k pending transactions include a first output item, and the identifier of the first output item matches the identifier of the read items associated with the first pending transaction.

[0021] In one embodiment, the processing unit is configured to execute N pending transactions in parallel to obtain execution information of the N pending transactions, specifically:

[0022] Obtain a write set, where the write set stores the values of the output items of non-conflicting transactions that have been executed before the execution of the N pending transactions;

[0023] If the write set includes a second output item that matches the read item associated with the first pending transaction, then read the value of the second output item as the value of the read item associated with the first pending transaction;

[0024] Based on the value of the read item associated with the first pending transaction, execute the first pending transaction to obtain the output item of the first pending transaction;

[0025] Generate execution information of the first pending transaction through the read item associated with the first pending transaction and the output item of the first pending transaction.

[0026] In one embodiment, the processing unit is further configured to:

[0027] If the write set does not include a second output item that matches the read item associated with the first pending transaction, then read the value of the read item associated with the first pending transaction from the database.

[0028] In one embodiment, there are multiple read items associated with the first pending transaction. That the read items associated with the first pending transaction are included in the output items of k pending transactions corresponding to the first pending transaction means that at least one read item associated with the first pending transaction is included in the output items of the k pending transactions.

[0029] Correspondingly, the present application provides a computer device, which includes:

[0030] A memory, in which a computer program is stored;

[0031] A processor, configured to load the computer program to implement the above conflict detection method.

[0032] Correspondingly, the present application provides a computer-readable storage medium, which stores a computer program, and the computer program is adapted to be loaded and executed by the processor to implement the above conflict detection method.

[0033] Correspondingly, the present application provides a computer program product or a computer program, which includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above conflict detection method.

[0034] In an embodiment of the present application, N to-be-executed transactions are obtained from multiple to-be-executed transactions in a channel, the N to-be-executed transactions are executed in parallel, and execution information of the N to-be-executed transactions is obtained. If a read item associated with a first to-be-executed transaction is included in output items of k to-be-executed transactions corresponding to the first to-be-executed transaction, it is determined that the first to-be-executed transaction is a conflicting transaction, and the first to-be-executed transaction is distributed to the channel to execute the first to-be-executed transaction again. The k to-be-executed transactions are non-conflicting transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction. It can be seen that by detecting conflicts in parallel transactions and redistributing the conflicting transactions to the channel to adjust the execution time of the conflicting transactions, the situation where transactions are invalid due to conflicts between transactions can be improved. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0036] Figure 1a It is a schematic diagram of the architecture of a data sharing system provided by an embodiment of the present application;

[0037] Figure 1b It is a schematic diagram of the structure of a blockchain provided by an embodiment of the present application;

[0038] Figure 1c It is a schematic diagram of the process of generating a block provided by an embodiment of the present application;

[0039] Figure 1d It is a schematic diagram of a conflict detection scenario provided by an embodiment of the present application;

[0040] Figure 2 It is a flowchart of a conflict detection method provided by an embodiment of the present application;

[0041] Figure 3 It is a flowchart of another conflict detection method provided by an embodiment of the present application;

[0042] Figure 4a It is a schematic diagram of a conflicting transaction provided by an embodiment of the present application;

[0043] Figure 4b It is a schematic diagram of a non-conflicting transaction provided by an embodiment of the present application;

[0044] Figure 4c It is a schematic diagram of another non-conflicting transaction provided by an embodiment of the present application;

[0045] Figure 4d A storage schematic diagram provided by an embodiment of the present application;

[0046] Figure 4e A schematic diagram of a transaction queue provided by an embodiment of the present application;

[0047] Figure 4f An architecture diagram of a scheduler provided by an embodiment of the present application;

[0048] Figure 5 A structural schematic diagram of a conflict detection device provided by an embodiment of the present application;

[0049] Figure 6 A structural schematic diagram of a computer device provided by an embodiment of the present application. Detailed implementation manners

[0050] Next, the technical solutions in the embodiments of the present application will be clearly and completely described in conjunction with the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only a part of the embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of the present application.

[0051] The embodiments of the present application relate to blockchain technology. The following briefly introduces the relevant terms and concepts of blockchain technology:

[0052] Blockchain is a new application mode of computer technologies such as distributed data storage, peer-to-peer transmission, consensus mechanism, and encryption algorithms. In essence, it 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, which is used to verify the validity (anti-counterfeiting) of the information and generate the next block. The blockchain can include the blockchain underlying platform, the platform product service layer, and the application service layer.

[0053] The blockchain network can be understood as a data sharing system 100. The data sharing system 100 refers to a system for data sharing between nodes. An exemplary structure of the data sharing system 100 can be seen in Figure 1a ; such as Figure 1aAs shown, the data sharing system may include multiple nodes 1001, and the multiple nodes 1001 may refer to each client in the data sharing system. Each node 1001 can receive input information during normal operation and maintain the shared data within the data sharing system based on the received input information. To ensure information interconnection within the data sharing system, there may be information connections between each node in the data sharing system, and information can be transmitted between nodes through the above-mentioned information connections. For example, when any node in the data sharing system receives input information, other nodes in the data sharing system obtain the input information according to the consensus algorithm and store the input information as data in the shared data, so that the data stored on all nodes in the data sharing system is consistent.

[0054] For each node in the data sharing system, there is a corresponding node identifier, and each node in the data sharing system can store the node identifiers of other nodes in the data sharing system, so as to broadcast the generated block to other nodes in the data sharing system according to the node identifiers of other nodes in the future. Each node can maintain a node identifier list as shown in the following table, and store the node name and node identifier in the node identifier list correspondingly. Among them, the node identifier can be an IP (Internet Protocol) address and any other information that can be used to identify the node; for example, the identifier of the node can also be a binary sequence code (such as 110001110), and only the IP address is used as an example in Table 1 for illustration:

[0055] Table 1

[0056] Node Name Node Identifier Node 1 xxx.xxx.xxx.xxx Node 2 yyy.yyy.yyy.yyy … … Node X (X is a positive integer) zzz.zzz.zzz.zzz

[0057] Each node in the data sharing system stores an identical blockchain. The blockchain consists of multiple blocks. Refer to Figure 1b , the blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information feature value, version number, timestamp, and difficulty value. The block body stores the input information; the next block of the genesis block uses the genesis block as the parent block. The next block also includes a block header and a block body. The block header stores the input information feature value of the current block, the block header feature value of the parent block, version number, timestamp, and difficulty value, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.

[0058] Nodes in the blockchain network include consensus nodes (including primary nodes and secondary nodes), and the consensus nodes are responsible for maintaining data consistency in the entire blockchain network. Each consensus node includes a consensus engine and a scheduling and execution module; among them, the consensus engine includes a consensus algorithm module and a peer-to-peer network module. The consensus algorithm module can include one or more consensus algorithms, and the consensus algorithms include but are not limited to: the Raft consensus algorithm of the fault tolerance type, and the Practical Byzantine Fault Tolerance (PBFT), Tendermint (blockchain protocol), HotStuff (distributed consensus protocol), etc. of the Byzantine fault tolerance type. Different consensus algorithms have different applicable scenarios. The peer-to-peer network module is also called peer-to-peer technology, and the core of the peer-to-peer network module is peer-to-peer network communication, that is, a communication technology that relies on the user group (peers) to exchange information without relying on a centralized server. The peer-to-peer network module is responsible for broadcasting and receiving proposal and voting messages. In this application, the peer-to-peer network module is used to broadcast blocks and proposals to other consensus nodes. The scheduling and execution module is the core module in the consensus node for scheduling and executing transactions, and this module is mainly used to execute transactions in parallel. When the consensus node is the primary node, the scheduling and execution module of the primary node constructs a block and executes the transaction, and finally provides the constructed block to the consensus engine module. Subsequently, the consensus engine module constructs a proposal based on the block and broadcasts the proposal to other secondary nodes. After the secondary nodes receive the proposal and verify its validity, they will use their own scheduling and execution module to verify the validity of the block corresponding to the proposal and execute the transaction in the transaction execution order (in parallel) indicated in the proposal. If the transaction execution result of the secondary node is the same as that of the primary node, the block is considered valid.

[0059] When generating each block in the blockchain, refer to Figure 1c , when the primary node in the blockchain network receives the input information, it verifies the input information. Specifically, the input information can include the transaction result of the transaction. The primary node executes the transaction corresponding to the execution result (i.e., the transaction to be executed), and then verifies the transaction result through the execution result to obtain the verification result. If the verification result indicates that the verification passes, the input information is stored in the memory pool, and its hash tree for recording the input information is updated; then, the update timestamp is updated to the time when the input information is received, and different random numbers are tried, and the eigenvalue calculation is performed multiple times so that the calculated eigenvalue can satisfy the following formula:

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

[0061] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time for updating the timestamp; nbits is the current difficulty, which is a fixed value within a certain period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, and this eigenvalue threshold can be determined according to nbits.

[0062] In this way, when a random number that satisfies the above formula is calculated, the information can be stored correspondingly, generating a block header and a block body to obtain the current block. Subsequently, the master node in the blockchain network broadcasts the newly generated block to the slave nodes in the data sharing system where it is located according to the node identifiers of the slave nodes in the data sharing system, and the slave nodes perform consensus verification on the newly generated block. Specifically, after receiving the block proposed by the master node, the slave node will verify the validity of the block and execute the transactions in the block to perform consistency verification on the transaction results in the block. If the slave node verifies that the block is invalid, or there is at least one transaction execution result in the block that is inconsistent with the corresponding transaction result in the block, the slave node will not vote or vote against the block; correspondingly, if the slave node verifies that the block is valid and all transaction execution results in the block are consistent with the corresponding transaction results in the block, the slave node will vote (in favor) for the block. Further, if the new block passes the consensus verification, the slave node will add the new block to the blockchain it stores (i.e., chain the new block).

[0063] Based on the above blockchain-related technologies, the embodiments of this application provide a conflict detection solution that can detect whether there are conflicting transactions among the to-be-executed transactions executed in parallel. Figure 1d This is a conflict detection scenario diagram provided by the embodiments of this application, as Figure 1dAs shown, the conflict detection scenario provided by this application includes a master node 101 and a slave node 102. The conflict detection solution provided by this application can be executed by the master node 101. Among them, the master node 101 and the slave node 102 can specifically be terminal devices or servers. Terminal devices can include, but are not limited to: smart phones (such as Android phones, IOS phones, etc.), tablet computers, portable personal computers, mobile Internet devices (abbreviated as MID), intelligent voice interaction devices, smart home appliances, vehicle-mounted terminals, aircraft, wearable devices, etc. This application embodiment does not make any limitations in this regard; the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network, content delivery network), and big data and artificial intelligence platforms. This application embodiment does not make any limitations in this regard.

[0064] It should be noted that Figure 1d the quantities of the master node 101 and the slave node 102 are only for illustration and do not constitute an actual limitation of this application. The master node 101 and the slave node 102 can be connected by wired or wireless means, and this application does not make any restrictions in this regard.

[0065] The general process of the conflict detection solution provided by this application is as follows:

[0066] (1) The master node 101 obtains N pending transactions from multiple pending transactions in the channel, where N is an integer greater than 1. Each pending transaction is associated with a read item. The pending transaction is a transaction that needs to be chained, and the master node 101 verifies the pending transaction by executing the pending transaction. The read item associated with any pending transaction is the parameter required to execute the pending transaction, that is, the data that needs to be read to execute the pending transaction. Each pending transaction in the set of transactions to be chained can be sent by one or more business nodes to the master node 101. In one implementation, the channel is used to cache the pending transactions that meet the chaining conditions, and the pending transactions that meet the chaining conditions in the channel can be packaged in the same block. The master node 101 can obtain the pending transactions from the channel according to the first-in, first-out rule.

[0067] (2) The master node 101 executes N to-be-executed transactions in parallel to obtain the execution information of the N to-be-executed transactions. Among them, the execution information of any to-be-executed transaction includes the read items and output items associated with this to-be-executed transaction. The so-called parallel execution can be understood as: there is an intersection (i.e., an overlapping part) between the first time period from the start to the end of execution of any one of the N to-be-executed transactions and the second time period from the start to the end of execution of another to-be-executed transaction among the N to-be-executed transactions.

[0068] In one implementation, the master node 101 executes the N to-be-executed transactions in the transaction set in parallel through N coroutines. Among them, the process of the master node 101 executing the first to-be-executed transaction (any one of the N to-be-executed transactions) through one coroutine is as follows: The master node 101 obtains the write set, and the write set stores the values of the output items of the non-conflicting transactions that have been executed before the N to-be-executed transactions are executed. A non-conflicting transaction is a transaction that has been executed and passed the conflict detection. If the write set includes a second output item that matches the read item associated with the first to-be-executed transaction (for example, the identifier of the read item associated with the first to-be-executed transaction is the same as the identifier of the second output item in the write set), then the master node 101 reads the value of the second output item as the value of the read item associated with the first to-be-executed transaction. After obtaining the value of the read item associated with the first to-be-executed transaction, the master node 101 executes the first to-be-executed transaction based on the value of the read item associated with the first to-be-executed transaction to obtain the output item of the first to-be-executed transaction. Then, through the read item associated with the first to-be-executed transaction and the output item of the first to-be-executed transaction, the execution information of the first to-be-executed transaction is generated.

[0069] (3) The master node 101 determines whether the first to-be-executed transaction is a conflicting transaction based on the read item associated with the first to-be-executed transaction and the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction. The k to-be-executed transactions corresponding to the first to-be-executed transaction are non-conflicting transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction. The first to-be-executed transaction is any one of the N to-be-executed transactions, and k is a natural number less than N. In one implementation, if the read item associated with the first to-be-executed transaction is included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, then the master node 101 determines that the first to-be-executed transaction is a conflicting transaction and distributes the first to-be-executed transaction to the channel to re-execute the first to-be-executed transaction. In another implementation, if the read item associated with the first to-be-executed transaction is not included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, then the master node 101 determines that the first to-be-executed transaction is a non-conflicting transaction.

[0070] In the embodiments of the present application, N pending transactions are obtained from multiple pending transactions in the channel, the N pending transactions are executed in parallel, and execution information of the N pending transactions is obtained. If a read item associated with a first pending transaction is included in output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a conflicting transaction, and the first pending transaction is distributed to the channel to execute the first pending transaction again. The k pending transactions are non-conflicting transactions among the N pending transactions whose execution completion time is before the first pending transaction. It can be seen that by detecting conflicts in parallel transactions and redistributing the conflicting transactions to the channel to adjust the execution time of the conflicting transactions, the situation where transactions become invalid due to conflicts between transactions can be improved.

[0071] Based on the above conflict detection solution, the embodiments of the present application propose a more detailed conflict detection method. The conflict detection method proposed in the embodiments of the present application will be introduced in detail below with reference to the accompanying drawings.

[0072] Please refer to Figure 2 , Figure 2 which is a flowchart of a conflict detection method provided by the embodiments of the present application. The conflict detection method can be executed by a computer device; for example, it is executed by the master node 101 shown in Figure 1d . As shown in Figure 2 , the conflict detection method may include the following steps S201 - step S203:

[0073] S201. Obtain N pending transactions from multiple pending transactions in the channel.

[0074] N is an integer greater than 1, and each pending transaction is associated with a read item. The pending transaction can be a transaction that needs to be chained. The computer device verifies the pending transaction by executing the pending transaction. A read item associated with any pending transaction is a parameter required to execute the pending transaction; for example, pending transaction 1 is associated with read item 1 and read item 2. The computer device needs to read the values of read item 1 and read item 2 associated with pending transaction 1 during the execution of pending transaction 1 to completely execute pending transaction 1. The channel is used to cache pending transactions that meet the chaining conditions. The pending transactions that meet the chaining conditions in the channel can be packed in the same block. That is to say, the pending transactions in the set of transactions to be chained are transactions in the same round of consensus.

[0075] In one implementation, the computer device obtains pending transactions sent by one or more business nodes (or proxy nodes) in the blockchain network and adds the pending transactions to the channel until the current moment matches the preset moment or the number of pending transactions in the channel reaches the preset number.

[0076] S202. Execute N to-be-executed transactions in parallel to obtain execution information of the N to-be-executed transactions.

[0077] The execution information of any to-be-executed transaction includes the read items and output items associated with the to-be-executed transaction. The so-called parallel execution can be understood as follows: There is an intersection (i.e., an overlapping part) between the first time period from the start of execution to the end of execution of any one of the N to-be-executed transactions and the second time period from the start of execution to the end of execution of another to-be-executed transaction among the N to-be-executed transactions. In one embodiment, the output time of the output item of any to-be-executed transaction is the execution completion time of the to-be-executed transaction. There can be multiple output items for each to-be-executed transaction. When there are multiple output items for a to-be-executed transaction, the output times of these output items are the same. For a transaction with multiple output items and at least two output items having different output times, the transaction can be split into multiple to-be-executed transactions based on the output times of the output items. Similarly, the read time of the read items associated with any to-be-executed transaction is the start time of execution of the to-be-executed transaction. There can be multiple read items for each to-be-executed transaction. When there are multiple read items for a to-be-executed transaction, the read times of these read items are the same. For a transaction with multiple read items and at least two read items having different read times, the transaction can be split into multiple to-be-executed transactions based on the read times of the read items.

[0078] In one implementation, the computer device executes the N to-be-executed transactions in the transaction set in parallel through N coroutines; among them, the process of the computer device executing the first to-be-executed transaction (any one of the N to-be-executed transactions) through one coroutine is as follows:

[0079] The computer device obtains a write set, which stores the values of the output items of non-conflicting transactions that have been executed before the N to-be-executed transactions. A non-conflicting transaction is a transaction that has been executed and passed the conflict detection. If the write set includes a second output item that matches the read item associated with the first to-be-executed transaction (e.g., the identifier of the read item associated with the first to-be-executed transaction is the same as the identifier of the second output item in the write set), the computer device reads the value of the second output item as the value of the read item associated with the first to-be-executed transaction. Correspondingly, if there is no second output item in the write set that matches the read item associated with the first to-be-executed transaction, the computer device reads the value of the read item associated with the first to-be-executed transaction from the database. Simply put, when the computer device reads the value of the read item associated with the first to-be-executed transaction, it reads the latest value. For example, assume that the identifier of the read item associated with the first to-be-executed transaction is k1, and in the database, k1 = v1; if k1 = v2 is stored in the write set, the computer device takes v2 as the value of the read item associated with the first to-be-executed transaction; if there is no update of k1 in the write set (i.e., there is no second output item that matches the read item associated with the first to-be-executed transaction), the computer device takes v1 as the value of the read item associated with the first to-be-executed transaction.

[0080] After obtaining the value of the read item associated with the first to-be-executed transaction, the computer device executes the first to-be-executed transaction based on the value of the read item associated with the first to-be-executed transaction, and obtains the output item of the first to-be-executed transaction. Then, based on the read item associated with the first to-be-executed transaction and the output item of the first to-be-executed transaction, the execution information of the first to-be-executed transaction is generated.

[0081] S203. If the read item associated with the first to-be-executed transaction is included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, it is determined that the first to-be-executed transaction is a conflicting transaction, and the first to-be-executed transaction is distributed to the channel.

[0082] The k to-be-executed transactions corresponding to the first to-be-executed transaction are non-conflicting transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction. The first to-be-executed transaction is any one of the N to-be-executed transactions, and k is a natural number less than N.

[0083] In one implementation, the read item associated with the first transaction to be executed being included in the output items of the k transactions to be executed corresponding to the first transaction to be executed means that: among the k transactions to be executed, there is a first output item, and the identifier of the first output item matches the identifier of the read item associated with the first transaction to be executed. That is to say, during the parallel execution of N transactions to be executed, the prerequisite sufficient condition for the correct execution of the first transaction to be executed is destroyed (by the first output item). For example, let the identifier of the output item of Transaction 1 be k2, and the identifier of the read item associated with Transaction 2 also be k2. Transaction 1 and Transaction 2 are executed in parallel, and the execution completion time of Transaction 1 is before that of Transaction 2. In this case, among the k transactions to be executed corresponding to Transaction 2 (including Transaction 1), there is the read item associated with Transaction 2, and the computer device determines that Transaction 2 is a conflicting transaction and distributes Transaction 2 to the channel (to wait for re - execution).

[0084] In another implementation, there are multiple read items associated with the first transaction to be executed. The read item associated with the first transaction to be executed being included in the output items of the k transactions to be executed corresponding to the first transaction to be executed means that: at least one of the read items associated with the first transaction to be executed is included in the output items of the k transactions to be executed. For example, let the identifier of the output item of Transaction 1 be k2, the identifier of the first read item associated with Transaction 2 be k1, and the identifier of the second read item associated with Transaction 2 be k2. Transaction 1 and Transaction 2 are executed in parallel, and the execution completion time of Transaction 1 is before that of Transaction 2. Then, the read items associated with Transaction 2 are included in the k transactions to be executed corresponding to Transaction 2 (including Transaction 1), and the computer device determines that Transaction 2 is a conflicting transaction and distributes Transaction 2 to the channel (to wait for re - execution).

[0085] Correspondingly, if the read item associated with the first transaction to be executed is not included in the output items of the k transactions to be executed corresponding to the first transaction to be executed (that is, during the parallel execution of N transactions to be executed, the prerequisite sufficient condition for the correct execution of the first transaction to be executed is not destroyed), then the computer device determines that the first transaction to be executed is a non - conflicting transaction.

[0086] In the embodiments of the present application, N transactions to be executed are obtained from multiple transactions to be executed in the channel, and the N transactions to be executed are executed in parallel to obtain the execution information of the N transactions to be executed. If the read item associated with the first transaction to be executed is included in the output items of the k transactions to be executed corresponding to the first transaction to be executed, then it is determined that the first transaction to be executed is a conflicting transaction, and the first transaction to be executed is distributed to the channel to re - execute the first transaction to be executed. The k transactions to be executed are non - conflicting transactions among the N transactions to be executed whose execution completion time is before the first transaction to be executed. It can be seen that by performing conflict detection on parallel transactions and redistributing the conflicting transactions to the channel to adjust the execution time of the conflicting transactions, the situation where transactions become invalid due to conflicts between transactions can be improved.

[0087] Please refer to Figure 3 , Figure 3 , which is a flowchart of another conflict detection method provided by an embodiment of the present application. This conflict detection method can be executed by a computer device; for example, it is executed by the master node 101 shown in Figure 1d .

[0088] As Figure 3 shown, this conflict detection method may include the following steps S301 - step S306:

[0089] S301. Obtain N to - be - executed transactions from multiple to - be - executed transactions in the channel.

[0090] S302. Execute the N to - be - executed transactions in parallel to obtain the execution information of the N to - be - executed transactions.

[0091] For the specific implementation manners of step S301 and step S302, reference can be made to the implementation manners of step S201 and step S202 in Figure 2 , which will not be elaborated here.

[0092] S303. Based on the read items associated with the first to - be - executed transaction and the output items of k to - be - executed transactions corresponding to the first to - be - executed transaction, determine whether the first to - be - executed transaction is a conflict transaction.

[0093] In one implementation manner, if the read items associated with the first to - be - executed transaction are included in the output items of k to - be - executed transactions corresponding to the first to - be - executed transaction, the computer device determines that the first to - be - executed transaction is a conflict transaction and continues to execute step S304. In one embodiment, that the read items associated with the first to - be - executed transaction are included in the output items of k to - be - executed transactions corresponding to the first to - be - executed transaction means that: among the k to - be - executed transactions corresponding to the first to - be - executed transaction, there is a first output item, and the identifier of the first output item matches the identifier of the read items associated with the first to - be - executed transaction. In another embodiment, if there are multiple read items associated with the first to - be - executed transaction, that the read items associated with the first to - be - executed transaction are included in the output items of k to - be - executed transactions corresponding to the first to - be - executed transaction means that: at least one of the read items associated with the first to - be - executed transaction is included in the output items of k to - be - executed transactions corresponding to the first to - be - executed transaction.

[0094] Figure 4a is a schematic diagram of a conflict transaction provided by an embodiment of the present application. As Figure 4aAs shown, the read item k2 associated with the to-be-executed transaction 1 in 401 and 402 matches the output item k2 of the to-be-executed transaction 2, and the execution completion time of the to-be-executed transaction 2 is before the execution completion time of the to-be-executed transaction 1 (that is, the output item k2 of the to-be-executed transaction 2 is among the output items of the k to-be-executed transactions corresponding to the to-be-executed transaction 1), and the computer determines that the to-be-executed transaction 1 is a conflicting transaction. It can be understood that since the determination result of the to-be-executed transaction 1 is related to the to-be-executed transaction 2, in addition to determining the to-be-executed transaction 1 as a conflicting transaction and the to-be-executed transaction 2 as a non-conflicting transaction; it can also be the other way around, determining the to-be-executed transaction 2 as a conflicting transaction and the to-be-executed transaction 1 as a non-conflicting transaction.

[0095] In another embodiment, if the read item associated with the first to-be-executed transaction is not included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, the computer device determines that the first to-be-executed transaction is a non-conflicting transaction and executes step S305. That the read item associated with the first to-be-executed transaction is not included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction can be understood as: among the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, the first output item whose identifier matches the identifier of the read item associated with the first to-be-executed transaction is not included.

[0096] Figure 4b This is a schematic diagram of a non-conflicting transaction provided by an embodiment of the present application. As Figure 4b shown, in 403 and 404, the read item k2 associated with the to-be-executed transaction 1 matches the output item k2 of the to-be-executed transaction 2, and the execution completion time of the to-be-executed transaction 2 is after the execution completion time of the to-be-executed transaction 1 (that is, the output item k2 of the to-be-executed transaction 2 is not among the output items of the k to-be-executed transactions corresponding to the to-be-executed transaction 1), and the computer determines that the to-be-executed transaction 1 is a non-conflicting transaction.

[0097] Figure 4c This is another schematic diagram of a non-conflicting transaction provided by an embodiment of the present application. As Figure 4c shown, in 405 - 408, the read item k2 associated with the to-be-executed transaction 1 does not match the output item k4 of the to-be-executed transaction 2, and the computer determines that the to-be-executed transaction 1 is a non-conflicting transaction.

[0098] S304. Distribute the first to-be-executed transaction to the channel.

[0099] The computer device distributes the first to-be-executed transaction to the channel to execute the first to-be-executed transaction again.

[0100] S305. Update the write set based on the output item of the first to-be-executed transaction to obtain the updated write set.

[0101] In one embodiment, N to-be-executed transactions are associated with a target block (e.g., all N to-be-executed transactions are transactions to be packaged into the target block). After determining that the first to-be-executed transaction is a non-conflicting transaction, the computer device may update the write set based on the output items of the first to-be-executed transaction to obtain an updated write set; wherein, the write set before the update includes the output items of M non-conflicting transactions associated with the target block, the execution completion times of the M non-conflicting transactions associated with the target block are before the start of the execution of the N to-be-executed transactions, and M is a natural number.

[0102] The write set stores the values of the output items of non-conflicting transactions, and the sequence number of each non-conflicting transaction. The sequence number is determined based on the shard where the non-conflicting transaction is located, and the shard belongs to the transaction queue. The content of the shard and the transaction queue can be referred to Figure 4e . In one embodiment, the computer device uses the identifier of the output item of each non-conflicting transaction as the "key", and the value of the output item and the sequence number of the non-conflicting transaction as the "value"; assume the identifier of the output item of non-conflicting transaction 1 is k1, the value of this output item is v1, and the sequence number of non-conflicting transaction 1 is x, then the computer device can store the output item of non-conflicting transaction 1 and the output time of this output item in an associated manner as "k1 = v1, x".

[0103] Figure 4d This is a storage schematic diagram provided by an embodiment of the present application. As Figure 4d shown, when the to-be-executed transaction 1 is executed and completed, an output item with the identifier k3 is output, the value (Value) of this output item is v3, and the sequence number (txSeq) is x. The computer device can add the value of the output item of the to-be-executed transaction 1 and the sequence number of the to-be-executed transaction 1 to the write set in the form shown in 409 in an associated manner.

[0104] Similarly, the computer device may also update the read set based on the read items of the first to-be-executed transaction to obtain an updated read set; wherein, the read set before the update includes the read items associated with M non-conflicting transactions associated with the target block, the execution completion times of the M non-conflicting transactions associated with the target block are before the start of the execution of the N to-be-executed transactions, and M is a natural number.

[0105] S306. Add the first to-be-executed transaction to the target shard.

[0106] In one embodiment, the execution information of any to-be-executed transaction further includes the serial number of the to-be-executed transaction, and the serial number of any to-be-executed transaction is used to indicate the execution order of the to-be-executed transaction. It should be noted that for H to-be-executed transactions belonging to the same parallel execution, the serial numbers of these H to-be-executed transactions are the same (that is, the to-be-executed transactions of parallel execution are indicated by the same serial number), and H is an integer greater than 1. For example, assume that to-be-executed transaction 1 to to-be-executed transaction 8 are executed in parallel, and to-be-executed transaction 1 to to-be-executed transaction 8 are not conflicting transactions with each other, then the serial numbers of to-be-executed transaction 1 to to-be-executed transaction 8 are the same. After determining that the first to-be-executed transaction is a non-conflicting transaction, the computer device can add the first to-be-executed transaction to the target shard in the transaction queue; wherein, the target shard belongs to the transaction queue, the transaction queue includes at least one shard, the serial numbers of the to-be-executed transactions belonging to the same shard are the same (that is, the to-be-executed transactions belonging to the same shard can be executed in parallel), the serial numbers corresponding to different shards are different, and the earlier the shard is in the transaction queue (the higher the execution priority of the to-be-executed transactions in the shard), the smaller the serial number corresponding to the shard. It can be understood that the k to-be-executed transactions corresponding to the first to-be-executed transaction are also included in the target shard.

[0107] Figure 4e FIG. is a schematic diagram of a transaction queue provided by an embodiment of the present application. As Figure 4e shown, the transaction queue may include several shards, and one shard may include one or more to-be-executed transactions. If a shard includes multiple to-be-executed transactions, the serial numbers of the to-be-executed transactions in the same shard are the same (the serial numbers of the to-be-executed transactions in different shards are not the same), and there are no non-conflicting transactions when the to-be-executed transactions in the shard including multiple to-be-executed transactions are executed in parallel. The serial number is used to indicate the execution order of the to-be-executed transaction.

[0108] The transaction queue can indicate the execution order of each to-be-executed transaction and the parallel / serial execution mode. In one embodiment, if there are no conflicting transactions after the to-be-executed transaction is executed in the order indicated by the transaction queue, the computer device can send the transaction queue to the slave nodes in the blockchain network so that each slave node executes the to-be-executed transactions in the transaction set in the order (and execution mode) indicated by the transaction queue.

[0109] The conflict detection method provided by this application will be described below in conjunction with a scenario. The scenario is as follows: When a subsidiary of a company needs to apply for resources from a resource management party, it requires the certification information (such as asset certification) of the subsidiary's parent company or the head office to provide a guarantee, and the resource application amount cannot be higher than the target amount indicated by the certification information. When the above conditions are met, the resource management party approves the subsidiary's resource application. Assume that k1 is the certification information of the head office, k2 is the certification information of a first-level subsidiary, and k3 is the certification information of a second-level subsidiary. The current "world state" is k1 = v1, k2 = v2, k3 = v3. When a subsidiary successfully applies for resources, it will update its own certification information; for example, if the amount of resources successfully applied for by a first-level subsidiary is v4, then the certification information of the first-level subsidiary is updated from k2 = v2 to k2 = v2 + v4. Suppose there are the following three transactions:

[0110] Tx0: A first-level subsidiary applies for resources from the resource management party using the certification information of the head office as a guarantee.

[0111] Tx1: A second-level subsidiary applies for resources from the resource management party using the certification information of the first-level subsidiary as a guarantee.

[0112] Tx2: A second-level subsidiary applies for resources from the resource management party using the certification information of the head office as a guarantee.

[0113] When Tx0 - Tx2 are executed in parallel, when the execution completion time of Tx0 is earlier than that of Tx1, there is a read-write conflict between Tx0 and Tx1 (the computer device can determine one of the transactions as a conflict transaction). In addition, there is a write-write conflict between Tx1 and Tx2.

[0114] In one embodiment, the conflict detection method provided by this application is to avoid the following situation: The read items (contents on which the execution depends) associated with a transaction to be executed are modified by another transaction to be executed during the execution of this transaction to be executed, so that the precondition for the correct execution of this transaction to be executed is destroyed. (When the above situation occurs, the transaction to be executed is determined as a conflict transaction and added to the set of transactions to be executed to wait for re-execution).

[0115] When there is a write-write conflict in the to-be-executed transactions being executed in parallel, the computer device can directly use the written value as the final result. For example, assume that after Tx1 is executed, the proof information of the secondary subsidiary is updated to v3'; after Tx2 is executed, the proof information of the secondary subsidiary is updated to v3''; if there is a write-write conflict between Tx1 and Tx2, and Tx1 finishes execution earlier than Tx2, then the update order of the proof information of the secondary subsidiary is: v3 → v3' → v3''; if there is a write-write conflict between Tx1 and Tx2, and Tx1 finishes execution later than Tx2, then the update order of the proof information of the secondary subsidiary is: v3 → v3'' → v3'. Both of the above cases conform to the actual execution logic.

[0116] In one implementation, the conflict detection method provided in this application can be implemented by a scheduler installed in the computer device. Figure 4f This is an architecture diagram of a scheduler provided for an embodiment of this application. As Figure 4f shown, the scheduler (Scheduler) is responsible for the scheduling execution of the to-be-executed transactions in the block. During the process of scheduling and executing the to-be-executed transactions in each block, the scheduler constructs a state recorder (Snapshot) for the block. The state recorder includes the following four modules: (1) Transaction queue (ExecutedTxs): The transaction queue can adopt a sharding (Slice) structure. After the computer device executes N to-be-executed transactions in parallel, it adds the non-conflicting transactions (already completed execution) to the (current last) shard of the transaction queue. The queue index (such as the shard number) can start from 0. In addition, when processing each transaction to construct a simulation context (simContext), the sequence number (txSeq) of the current transaction can be calculated through len(ExecutedTxs). (2) Write set (WriteTable): The write set can be a map set. The key is the identifier of the output item output during the execution of the non-conflicting transaction, and the value includes the value (value) and sequence number (txSeq) of the output item. (3) Read set (ReadTable): The read set can be a map set. The key is the identifier of the read item associated with the non-conflicting transaction, and the value includes the value (value) and sequence number (txSeq) of the read item. (4) Read-write lock (Lock): Used to ensure the correctness of the variables in the Snapshot under concurrent operations. WriteTable and ReadTable can be understood as the data to be modified and read in the sandbox environment of the execution of this block, which together with the data not updated in the database constitutes the latest "world state".

[0117] In one embodiment, the process for the scheduler to detect conflicts is as follows: (1) The scheduling module (for dispatching transactions) distributes the to-be-executed transactions in the transaction set to a channel. (2) Multiple coroutines concurrently retrieve the to-be-executed transactions from the channel, and the multiple coroutines execute the retrieved to-be-executed transactions in parallel. (3) Before each to-be-executed transaction calls the Virtual Machine (VM) for execution, it needs to obtain a sequence number (txSeq) through Snapshot for constructing a SimContext. (4) Multiple coroutines call the virtual machine in parallel to execute the to-be-executed transactions, obtaining the execution information of the to-be-executed transactions. The execution information includes the read time of the read items associated with the to-be-executed transactions and the output time of the output items output during the execution of the to-be-executed transactions. (5) The execution information of each to-be-executed transaction is returned to the scheduling module. (6) The scheduling module detects whether the to-be-executed transaction is a conflicting transaction according to the conflict detection method as in Figure 2 or Figure 3 . (7) If it is determined that the to-be-executed transaction is a non-conflicting transaction, the to-be-executed transaction is placed in the transaction queue (ExecutedTxs), and the write set and read set are updated based on the execution information of the to-be-executed transaction. Correspondingly, if it is determined that the to-be-executed transaction is a conflicting transaction, the transaction is rescheduled and distributed into the channel for re-execution later until all transactions pass the transaction conflict detection during execution.

[0118] In the embodiment of the present application, N to-be-executed transactions are obtained from multiple to-be-executed transactions in the channel, and the N to-be-executed transactions are executed in parallel to obtain the execution information of the N to-be-executed transactions. If the read items associated with the first to-be-executed transaction are included in the output items of the k to-be-executed transactions corresponding to the first to-be-executed transaction, it is determined that the first to-be-executed transaction is a conflicting transaction, and the first to-be-executed transaction is distributed to the channel for re-executing the first to-be-executed transaction. The k to-be-executed transactions are non-conflicting transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction. It can be seen that by detecting conflicts in parallel transactions and redistributing the conflicting transactions to the channel to adjust the execution time of the conflicting transactions, the execution efficiency of transactions can be improved while improving the situation where transactions are invalid due to conflicts between transactions. In addition, through the conflict transaction detection method provided by the present application, conflicting transactions can be detected more efficiently and quickly, ensuring that all transactions obtain correct results that meet expectations.

[0119] The method of the embodiment of the present application is elaborated in detail above. To facilitate better implementation of the above solution of the embodiment of the present application, correspondingly, the device of the embodiment of the present application is provided below.

[0120] Please refer to Figure 5 , Figure 5Schematic structural diagram of a conflict detection device provided by an embodiment of the present application Figure 5 The illustrated conflict detection device can be installed in a computer device, which can specifically be a terminal device or a server Figure 5 The illustrated conflict detection device can be used to execute some or all of the functions in the method embodiments described above Figure 2 and Figure 3 Please refer to Figure 5 , the conflict detection device includes:

[0121] An obtaining unit 501, configured to obtain N pending transactions from multiple pending transactions in a channel, where N is an integer greater than 1

[0122] A processing unit 502, configured to execute the N pending transactions in parallel to obtain execution information of the N pending transactions. The execution information of any one of the pending transactions includes a read item and an output item associated with the pending transaction

[0123] And if the read item associated with the first pending transaction is included in the output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a conflict transaction, and the first pending transaction is distributed to the channel to execute the first pending transaction again; the k pending transactions are non-conflict transactions among the N pending transactions whose execution completion time is before the first pending transaction, the first pending transaction is any one of the N pending transactions, and k is a natural number less than N

[0124] In an implementation manner, the processing unit 502 is further configured to:

[0125] If the read item associated with the first pending transaction is not included in the output items of k pending transactions corresponding to the first pending transaction, it is determined that the first pending transaction is a non-conflict transaction

[0126] In an implementation manner, the execution information of any one of the pending transactions further includes a sequence number of the pending transaction, and the sequence number of any one of the pending transactions is used to indicate the execution order of the pending transaction; if the first pending transaction is a non-conflict transaction, the processing unit 502 is further configured to:

[0127] Add the first pending transaction to the target shard

[0128] Wherein, the target shard belongs to a transaction queue, the transaction queue includes at least one shard, the sequence numbers of the pending transactions belonging to the same shard are the same, and the k pending transactions are included in the target shard

[0129] In an implementation manner, the N pending transactions are associated with a target block. If the first pending transaction is a non-conflict transaction, the processing unit 502 is further configured to:

[0130] Update the write set based on the output item of the first transaction to be executed to obtain the updated write set;

[0131] Among them, the write set before update includes the output items of M non-conflicting transactions associated with the target block, and the execution completion times of M non-conflicting transactions associated with the target block. Before the N transactions to be executed start to be executed, M is a natural number.

[0132] In one implementation manner, that the read item associated with the first transaction to be executed is included in the output items of k transactions to be executed corresponding to the first transaction to be executed means that: the k transactions to be executed include the first output item, and the identifier of the first output item matches the identifier of the read item associated with the first transaction to be executed.

[0133] In one implementation manner, the processing unit 502 is configured to execute N transactions to be executed in parallel to obtain the execution information of the N transactions to be executed. Specifically, it is configured to:

[0134] Obtain the write set, and the write set stores the values of the output items of the non-conflicting transactions that have been executed before the N transactions to be executed are executed;

[0135] If the write set includes a second output item that matches the read item associated with the first transaction to be executed, then read the value of the second output item as the value of the read item associated with the first transaction to be executed;

[0136] Execute the first transaction to be executed based on the value of the read item associated with the first transaction to be executed to obtain the output item of the first transaction to be executed;

[0137] Generate the execution information of the first transaction to be executed through the read item associated with the first transaction to be executed and the output item of the first transaction to be executed.

[0138] In one implementation manner, the processing unit 502 is further configured to:

[0139] If there is no second output item that matches the read item associated with the first transaction to be executed in the write set, then read the value of the read item associated with the first transaction to be executed from the database.

[0140] In one implementation manner, there are multiple read items associated with the first transaction to be executed. That the read items associated with the first transaction to be executed are included in the output items of k transactions to be executed corresponding to the first transaction to be executed means that at least one of the read items associated with the first transaction to be executed is included in the output items of the k transactions to be executed.

[0141] According to an embodiment of the present application, Figure 2 and Figure 3 Some steps involved in the conflict detection method shown can be performed by Figure 5Each unit in the conflict detection device shown is executed. For example, Figure 2 Step S201 shown in Figure 5 can be executed by the acquisition unit 501 shown in Figure 5 , and steps S202 and S203 can be executed by the processing unit 502 shown in Figure 3 Step S301 shown in Figure 5 can be executed by the acquisition unit 501 shown in Figure 5 , and steps S302 - S306 can be executed by the processing unit 502 shown in Figure 5 Each unit in the conflict detection device shown can be respectively or all combined into one or several other units to form, or a certain (some) unit can also be further split into multiple smaller units in terms of function to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above units are divided based on logical functions. In practical applications, the function of one unit can also be realized by multiple units, or the functions of multiple units can be realized by one unit. In other embodiments of the present application, the conflict detection device may also include other units. In practical applications, these functions can also be assisted by other units and can be realized by the cooperation of multiple units.

[0142] According to another embodiment of the present application, it can be achieved by running a computer program (including program code) capable of executing the respective steps involved in the corresponding methods shown in Figure 2 and Figure 3 on a general computing device such as a computer device including processing elements and storage elements such as a central processing unit (CPU), a random access storage medium (RAM), and a read-only storage medium (ROM), to construct the conflict detection device shown in Figure 5 , and to implement the conflict detection method of the embodiments of the present application. The computer program can be recorded on, for example, a computer-readable recording medium, and be loaded into the above computing device through the computer-readable recording medium and run therein.

[0143] Based on the same inventive concept, the principle of solving problems and the beneficial effects of the conflict detection device provided in the embodiments of the present application are similar to those of the conflict detection method in the method embodiments of the present application. The principle and beneficial effects of the method implementation can be referred to. For the sake of brevity, they will not be elaborated here.

[0144] Please refer to Figure 6 , Figure 6 which is a schematic structural diagram of a computer device provided by an embodiment of the present application. The computer device can be a terminal device or a server. As shown in Figure 6As shown in the figure, the computer device at least includes a processor 601, a communication interface 602, and a memory 603. Among them, the processor 601, the communication interface 602, and the memory 603 can be connected through a bus or other means. Among them, the processor 601 (or the Central Processing Unit (CPU)) is the computing core and control core of the computer device. It can parse various instructions in the computer device and process various data of the computer device. For example, the CPU can be used to parse the power-on and power-off instructions sent by an object to the computer device and control the computer device to perform power-on and power-off operations; Another example is that the CPU can transfer various types of interaction data between the internal structures of the computer device, and so on. The communication interface 602 may optionally include a standard wired interface, a wireless interface (such as WI-FI, a mobile communication interface, etc.), and under the control of the processor 601, it can be used to send and receive data; The communication interface 602 can also be used for the transmission and interaction of internal data of the computer device. The memory 603 (Memory) is the memory device in the computer device and is used to store programs and data. It can be understood that the memory 603 here can include both the built-in memory of the computer device and, of course, the extended memory supported by the computer device. The memory 603 provides a storage space, and this storage space stores the operating system of the computer device, which may include but is not limited to: Android system, iOS system, Windows Phone system, etc., and this application does not make any limitations in this regard.

[0145] The embodiment of this application also provides a computer-readable storage medium (Memory). The computer-readable storage medium is the memory device in the computer device and is used to store programs and data. It can be understood that the computer-readable storage medium here can include both the built-in storage medium in the computer device and, of course, the extended storage medium supported by the computer device. The computer-readable storage medium provides a storage space, and this storage space stores the processing system of the computer device. And, a computer program suitable for being loaded and executed by the processor 601 is also stored in this storage space. It should be noted that the computer-readable storage medium here can be a high-speed RAM memory, or a non-volatile memory, such as at least one disk memory; Optionally, it can also be at least one computer-readable storage medium located far from the aforementioned processor.

[0146] In one embodiment, the processor 601 performs the following operations by running the computer program in the memory 603:

[0147] Obtain N pending transactions from multiple pending transactions in the channel, where N is an integer greater than 1;

[0148] Execute N transactions to be executed in parallel to obtain the execution information of the N transactions to be executed. The execution information of any transaction to be executed includes the read items and output items associated with the transaction to be executed;

[0149] If the read items associated with the first transaction to be executed are included in the output items of k transactions to be executed corresponding to the first transaction to be executed, then determine that the first transaction to be executed is a conflicting transaction, and distribute the first transaction to be executed to the channel to execute the first transaction to be executed again; the k transactions to be executed are non-conflicting transactions among the N transactions to be executed whose execution completion time is before the first transaction to be executed. The first transaction to be executed is any one of the N transactions to be executed, and k is a natural number less than N.

[0150] As an alternative embodiment, the processor 601 further performs the following operations by running the computer program in the memory 603:

[0151] If the read items associated with the first transaction to be executed are not included in the output items of k transactions to be executed corresponding to the first transaction to be executed, then determine that the first transaction to be executed is a non-conflicting transaction.

[0152] As an alternative embodiment, the execution information of any transaction to be executed further includes the serial number of the transaction to be executed. The serial number of any transaction to be executed is used to indicate the execution order of the transaction to be executed; if the first transaction to be executed is a non-conflicting transaction, then the processor 601 further performs the following operations by running the computer program in the memory 603:

[0153] Add the first transaction to be executed to the target shard;

[0154] Wherein, the target shard belongs to the transaction queue. The transaction queue includes at least one shard. The serial numbers of the transactions to be executed belonging to the same shard are the same, and the k transactions to be executed are included in the target shard.

[0155] As an alternative embodiment, the N transactions to be executed are associated with the target block. If the first transaction to be executed is a non-conflicting transaction, then the processor 601 further performs the following operations by running the computer program in the memory 603:

[0156] Update the write set based on the output items of the first transaction to be executed to obtain the updated write set;

[0157] Wherein, the write set before the update includes the output items of M non-conflicting transactions associated with the target block. The execution completion times of the M non-conflicting transactions associated with the target block are before the start of the execution of the N transactions to be executed, and M is a natural number.

[0158] As an alternative embodiment, that the read item associated with the first transaction to be executed is included in the output items of the k transactions to be executed corresponding to the first transaction to be executed means that: among the k transactions to be executed, there is a first output item, and the identifier of the first output item matches the identifier of the read item associated with the first transaction to be executed.

[0159] As an alternative embodiment, a specific embodiment in which the processor 601 executes N transactions to be executed in parallel and obtains the execution information of the N transactions to be executed is as follows:

[0160] Obtain a write set, where the write set stores the values of the output items of non-conflicting transactions that have been executed before the N transactions to be executed;

[0161] If the write set includes a second output item that matches the read item associated with the first transaction to be executed, then read the value of the second output item as the value of the read item associated with the first transaction to be executed;

[0162] Based on the value of the read item associated with the first transaction to be executed, execute the first transaction to be executed to obtain the output item of the first transaction to be executed;

[0163] Generate the execution information of the first transaction to be executed through the read item associated with the first transaction to be executed and the output item of the first transaction to be executed.

[0164] As an alternative embodiment, the processor 601 further performs the following operations by running the computer program in the memory 603:

[0165] If the write set does not include a second output item that matches the read item associated with the first transaction to be executed, then read the value of the read item associated with the first transaction to be executed from the database.

[0166] As an alternative embodiment, if there are multiple read items associated with the first transaction to be executed, that the read items associated with the first transaction to be executed are included in the output items of the k transactions to be executed corresponding to the first transaction to be executed means that at least one of the read items associated with the first transaction to be executed is included in the output items of the k transactions to be executed.

[0167] Based on the same inventive concept, the principle of problem-solving and the beneficial effects of the computer device provided in the embodiments of the present application are similar to the principle of problem-solving and the beneficial effects of the conflict detection method in the method embodiments of the present application. The principle and beneficial effects of the method implementation can be referred to. For the sake of brevity of description, they will not be elaborated here.

[0168] The embodiments of the present application further provide a computer-readable storage medium, in which a computer program is stored, and the computer program is suitable for being loaded and executed by a processor to execute the conflict detection method in the above method embodiments.

[0169] The embodiments of the present application also provide a computer program product or a computer program. The computer program product or the computer program includes computer instructions, and the computer instructions are stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the above-mentioned conflict detection method.

[0170] The steps in the method of the embodiments of the present application can be adjusted, combined, and deleted according to actual needs.

[0171] The modules in the device of the embodiments of the present application can be combined, divided, and deleted according to actual needs.

[0172] In the embodiments of the present application, the "module" or "unit" involved refers to a computer program with a predetermined function or a part of a computer program, which works with other related parts to achieve a predetermined goal, and can be fully or partially implemented by using software, hardware (such as a processing circuit or a memory), or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a part of the overall module or unit that includes the function of the module or unit.

[0173] 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. The program can be stored in a computer-readable storage medium, and the computer-readable storage medium can include: a flash drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disc, etc.

[0174] The above-disclosed is only a preferred embodiment of the present application. Of course, the scope of rights of the present application cannot be limited thereby. Those of ordinary skill in the art can understand the entire or partial processes of implementing the above embodiments, and the equivalent changes made according to the claims of the present application still fall within the scope covered by the application.

Claims

1. A conflict detection method, characterized in that, The method includes: Obtaining N to-be-executed transactions from multiple to-be-executed transactions in a channel, where N is an integer greater than 1; Executing the N to-be-executed transactions in parallel to obtain execution information of the N to-be-executed transactions. The execution information of any to-be-executed transaction includes read items and output items associated with the to-be-executed transaction; If the read items associated with a first to-be-executed transaction are included in the output items of k to-be-executed transactions corresponding to the first to-be-executed transaction, it is determined that the first to-be-executed transaction is a conflicting transaction, and the first to-be-executed transaction is distributed to the channel to re-execute the first to-be-executed transaction; the k to-be-executed transactions are non-conflicting transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction. The first to-be-executed transaction is any one of the N to-be-executed transactions, and k is a natural number less than N.

2. The method according to claim 1, wherein The method further includes: If the read items associated with the first to-be-executed transaction are not included in the output items of the k to-be-executed transactions, it is determined that the first to-be-executed transaction is a non-conflicting transaction.

3. The method according to claim 2, wherein The execution information of any to-be-executed transaction further includes the sequence number of the to-be-executed transaction, and the sequence number of any to-be-executed transaction is used to indicate the execution order of the to-be-executed transaction; If the first to-be-executed transaction is a non-conflicting transaction, the method further includes: Adding the first to-be-executed transaction to a target shard; Wherein, the target shard belongs to a transaction queue. The transaction queue includes at least one shard, and the sequence numbers of the to-be-executed transactions belonging to the same shard are the same, and the k to-be-executed transactions are included in the target shard.

4. The method according to claim 2, wherein The N to-be-executed transactions are associated with a target block. If the first to-be-executed transaction is a non-conflicting transaction, the method further includes: Updating a write set based on the output items of the first to-be-executed transaction to obtain an updated write set; Wherein, the write set before update includes output items of M non-conflicting transactions associated with the target block. The execution completion time of the M non-conflicting transactions associated with the target block is before the N to-be-executed transactions start to be executed, and M is a natural number.

5. The method according to claim 1, characterized in that, That the read items associated with the first to-be-executed transaction are included in the output items of k to-be-executed transactions corresponding to the first to-be-executed transaction means that the output items of the k to-be-executed transactions include a first output item, and the identifier of the first output item matches the identifier of the read items associated with the first to-be-executed transaction.

6. The method according to claim 1, characterized in that, The parallel execution of the N to-be-executed transactions to obtain the execution information of the N to-be-executed transactions includes: Obtaining a write set, where the write set stores the values of the output items of non-conflicting transactions that have been executed before the N to-be-executed transactions are executed; If the write set includes a second output item that matches the read items associated with the first to-be-executed transaction, reading the value of the second output item as the value of the read items associated with the first to-be-executed transaction; Executing the first to-be-executed transaction based on the value of the read items associated with the first to-be-executed transaction to obtain the output items of the first to-be-executed transaction; Generate the execution information of the first to-be-executed transaction through the read items associated with the first to-be-executed transaction and the output items of the first to-be-executed transaction.

7. The method according to claim 6, wherein The method further includes: If there is no second output item in the write set that matches the read item associated with the first to-be-executed transaction, read the value of the read item associated with the first to-be-executed transaction from the database.

8. The method according to claim 1, wherein There are multiple read items associated with the first to-be-executed transaction. That the read items associated with the first to-be-executed transaction are included in the output items of k to-be-executed transactions corresponding to the first to-be-executed transaction means that at least one read item associated with the first to-be-executed transaction is included in the output items of the k to-be-executed transactions.

9. A conflict detection device, characterized in that, The conflict detection device includes: An acquisition unit, configured to acquire N to-be-executed transactions from multiple to-be-executed transactions in a channel, where N is an integer greater than 1; A processing unit, configured to execute the N to-be-executed transactions in parallel to obtain the execution information of the N to-be-executed transactions. The execution information of any to-be-executed transaction includes the read items and output items associated with the to-be-executed transaction; And if the read items associated with the first to-be-executed transaction are included in the output items of k to-be-executed transactions corresponding to the first to-be-executed transaction, determine that the first to-be-executed transaction is a conflict transaction and distribute the first to-be-executed transaction to the channel to re-execute the first to-be-executed transaction; the k to-be-executed transactions are non-conflict transactions among the N to-be-executed transactions whose execution completion time is before the first to-be-executed transaction, the first to-be-executed transaction is any one of the N to-be-executed transactions, and k is a natural number less than N.

10. A computer device, characterized in that, Includes: A memory, in which a computer program is stored; A processor, configured to load the computer program to implement the conflict detection method according to any one of claims 1-8.

11. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded and executed by a processor to implement the conflict detection method according to any one of claims 1-8.

12. A computer program product, characterized in that, The computer program product includes a computer program, and the computer program is suitable for being loaded and executed by a processor to implement the conflict detection method according to any one of claims 1-8.