Parallel control method and device based on alliance chain transaction conflict and related equipment

CN119473545AActive Publication Date: 2025-02-18WEBANK (CHINA)
View PDF 8 Cites 0 Cited by

Patent Information

Application Number
CN202411537161.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-31
Publication Date
2025-02-18
Estimated Expiration
2044-10-31

Smart Images

  • Figure CN119473545A_ABST
    Figure CN119473545A_ABST
Patent Text Reader

Abstract

The invention provides a concurrency control method and device based on alliance chain transaction conflicts and related equipment. The method comprises the steps of obtaining t transactions of a target consensus node on a target alliance chain; packaging the t transactions through a consensus algorithm to obtain a first block, and broadcasting the first block to other consensus nodes; performing static analysis on the first block, and performing conflict rate calculation on the transaction based on a static analysis result; when the transaction conflict rate is greater than a preset threshold value, executing t transactions in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result; filling the first block with the first execution result to obtain a target first block, and broadcasting the target first block to other consensus nodes; and when a consensus requirement is met, submitting the target first block to the target alliance chain, otherwise, discarding the target first block. By adopting the method provided by the embodiment of the invention, the performance of the concurrency control algorithm can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a parallel control method, device and related equipment based on alliance chain transaction conflicts. Background Art

[0002] In the field of blockchain, performance has always been a challenge that restricts its application in more scenarios, especially in the field of consortium chain. The number of transactions processed per second and transaction latency of the consortium chain have attracted widespread attention. The blockchain is composed of a chain data structure consisting of continuously appended blocks, and blocks are composed of transactions. In the consortium chain, the performance of the blockchain can be improved by optimizing the consensus algorithm, parallel execution of transactions, network and storage, among which parallel execution of transactions is a very important aspect. Existing technologies improve the performance of consortium chains by increasing the parallelism of transaction execution. However, in the scenario where the conflict rate of transactions on the consortium chain is high, the performance of the existing concurrency control algorithm on the consortium chain is poor.

[0003] Therefore, how to improve the performance of the concurrency control algorithm in scenarios with high transaction conflict rates on the alliance chain needs to be solved urgently. Summary of the invention

[0004] The embodiments of the present application provide a parallel control method, apparatus and related equipment based on alliance chain transaction conflicts. On the alliance chain, based on the transaction conflict rate in the block, a consistent concurrent scheduling algorithm can be used to concurrently execute transactions in a high-conflict transaction rate scenario, thereby improving the performance of the concurrency control algorithm.

[0005] In a first aspect, an embodiment of the present application provides a parallel control method based on alliance chain transaction conflicts, the method comprising:

[0006] Obtain t transactions of a target consensus node on a target alliance chain, where the target alliance chain includes f consensus nodes, t and f are both integers greater than 1; the target consensus node is any consensus node among the f consensus nodes;

[0007] The t transactions are packaged by a consensus algorithm to obtain a first block, and the first block is broadcast to f-1 consensus nodes among the f consensus nodes except the target consensus node;

[0008] Performing static analysis on the first block to obtain a static analysis result;

[0009] Calculating the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate;

[0010] When the transaction conflict rate is greater than a preset threshold, the t transactions are executed in parallel on the target consensus node by using a consistency concurrency control algorithm to obtain a first execution result;

[0011] Filling the first block with the first execution result based on the consensus algorithm to obtain a target first block, and broadcasting the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, executing the transaction in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result;

[0012] Collect the second execution results corresponding to the f-1 consensus nodes to obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package;

[0013] Detecting whether the first execution result message packet meets a first preset condition by using the consensus algorithm;

[0014] When the first execution result message packet meets the first preset condition, the target first block is submitted to the target alliance chain; when the first execution result message packet does not meet the first preset condition, the target first block is discarded.

[0015] In a second aspect, an embodiment of the present application provides a parallel control device based on alliance chain transaction conflicts, the device comprising:

[0016] An acquisition module, used to acquire t transactions of a target consensus node on a target alliance chain, wherein the target alliance chain includes f consensus nodes, t and f are both integers greater than 1; and the target consensus node is any consensus node among the f consensus nodes;

[0017] A determination module is used to package the t transactions through a consensus algorithm to obtain a first block, and broadcast the first block to f-1 consensus nodes among the f consensus nodes except the target consensus node; perform static analysis on the first block to obtain a static analysis result; calculate the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate;

[0018] A judgment module, configured to execute the t transactions in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result when the transaction conflict rate is greater than a preset threshold;

[0019] The determination module is further configured to fill the first block with the first execution result based on the consensus algorithm to obtain a target first block, and broadcast the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, the transaction is executed in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result;

[0020] The acquisition module is further used to collect the second execution results corresponding to the f-1 consensus nodes, obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package;

[0021] The judgment module is further used to detect whether the first execution result message packet meets the first preset condition through the consensus algorithm;

[0022] The determination module is also used to submit the target first block to the target alliance chain when the first execution result message packet meets the first preset condition; and discard the target first block when the first execution result message packet does not meet the first preset condition.

[0023] In a third aspect, an embodiment of the present application provides an electronic device, comprising a processor, a memory, a communication interface, and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the processor, and the program includes instructions for executing the steps of any method in the first aspect of the embodiment of the present application.

[0024] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps described in any method of the first aspect of the embodiment of the present application.

[0025] In a fifth aspect, an embodiment of the present application provides a computer program product, wherein the computer program product includes a non-transitory computer-readable storage medium storing a computer program, and the computer program is operable to cause a computer to execute some or all of the steps described in any method of the first aspect of the embodiment of the present application. The computer program product may be a software installation package.

[0026] By implementing the embodiments of the present application, in a scenario where the block transaction conflict rate on the alliance chain is high, a consistent concurrent scheduling algorithm is adopted to improve the performance of the concurrency control algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0028] Figure 1 It is a flowchart of a parallel control method based on alliance chain transaction conflicts provided in an embodiment of the present application;

[0029] Figure 2 A flowchart of the execution of the consistency concurrency control algorithm provided in the embodiment of the present application;

[0030] Figure 3 A flowchart of a directed acyclic graph construction provided in an embodiment of the application;

[0031] Figure 4 A flowchart of a scheduling algorithm for executing a transaction conflict scenario on a consortium chain provided in an embodiment of the application;

[0032] Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;

[0033] Figure 6 An application embodiment provides a functional module composition block diagram of a parallel control device based on alliance chain transaction conflicts. DETAILED DESCRIPTION

[0034] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

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

[0036] It should be understood that the term "and / or" in this article is only a description of the association relationship of associated objects, indicating that there can be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the character " / " in this article indicates that the associated objects before and after are in an "or" relationship. The "plurality" appearing in the embodiments of the present application refers to two or more.

[0037] In the embodiments of the present application, "at least one item" or similar expressions refer to any combination of these items, including any combination of single items or plural items, and refer to one or more, and multiple refers to two or more. For example, at least one item of a, b, or c can represent the following seven situations: a, b, c, a and b, a and c, b and c, a, b, and c. Among them, each of a, b, and c can be an element or a set containing one or more elements.

[0038] The "connection" that appears in the embodiments of the present application refers to various connection methods such as direct connection or indirect connection to achieve communication between devices, and the embodiments of the present application do not impose any limitations on this.

[0039] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0040] The following is an explanation of the relevant terms involved in this application, as follows:

[0041] Consortium chain: Consortium chain is a blockchain network that allows data and transactions to be public and private to a certain extent. Consortium chain is jointly maintained and managed by multiple pre-selected organizations or institutions, and only these members can join the network. In the consortium chain, the generation of each block is jointly decided by all pre-selected nodes, and other nodes connected to the network can participate in transactions, but are not involved in the accounting process.

[0042] Consensus node: A node is a computer that has installed the software and hardware required by the blockchain system and joined the blockchain network. The node participates in network communication, logical operations and data verification, and is responsible for verifying and saving data such as blocks, transactions and status, while providing transaction processing and data query interfaces for clients. Nodes can be divided into consensus nodes and observation nodes. Consensus nodes participate in the entire consensus process, are responsible for packaging blocks as bookkeepers, and verify blocks as verifiers to complete the consensus process.

[0043] Block: A block is a data structure built in chronological order. The first block of the blockchain is called the "genesis block". Subsequent blocks are identified by "height", and the height of each block increases one by one. Each new block introduces the hash information of the previous block, and generates a unique data fingerprint with the data of this block through the hash algorithm, thus forming an interconnected blockchain structure. The basic data structure of a block includes a block header and a block body. The block header contains basic information such as block height, hash value, block producer signature and state tree root, while the block body contains a list of transaction data and related receipt information. Depending on the size of the transaction list, the size of the entire block will vary.

[0044] Transaction: A transaction represents a piece of request data sent to the blockchain system, which is used to deploy contracts, call contract interfaces, maintain contract lifecycles, manage assets, and exchange value. The basic data structure of a transaction includes sender, receiver, and transaction data. Users can construct transactions, sign them with their own private keys, and send them to the blockchain. The transaction is then processed through the consensus mechanism of multiple nodes, executing the relevant smart contract code and generating the state data specified by the transaction. Finally, the transaction is packaged into a block and stored together with the state data.

[0045] FISCO BCOS (Be Credible, Open & Secure): It is a secure, controllable, stable, easy-to-use, high-performance financial-grade blockchain underlying platform, launched by the FISCO Open Source Working Group in 2017.

[0046] In the field of blockchain, performance has always been a challenge that restricts its application in more scenarios, especially in the field of consortium chain. The number of transactions processed per second and transaction latency of consortium chain have attracted wide attention. Blockchain is composed of continuously added blocks to form a chain data structure, and blocks are composed of transactions. In the consortium chain, the performance of blockchain can be improved by optimizing the consensus algorithm, parallel execution of transactions, network and storage, among which parallel execution of transactions is a very important aspect. Existing technologies improve the performance of consortium chain by improving the parallelism of transaction execution. The concurrency control algorithms on the current blockchain can be divided into optimistic concurrency control and pessimistic concurrency control. Optimistic concurrency control assumes that the probability of conflicts between transactions is low, while pessimistic concurrency control assumes that the probability of conflicts between transactions is high. The high transaction conflict rate may be due to the complexity of the contract and the large number of access resources, or it may be because static analysis misjudges that what can be parallelized is not parallelized. If pessimistic concurrency control is adopted, some of the parallelized ones will degenerate into serial, and the performance will be low; if optimistic concurrency control is adopted, it may cause a large number of rollbacks or re-executions, resulting in resource waste and poor performance. In scenarios where the conflict rate of transactions on the blockchain is high, the performance of the concurrency control algorithm on the existing blockchain is poor. Therefore, how to control concurrency during transaction execution, prevent transactions from conflicting on the same resource, and improve the performance of the concurrency control algorithm needs to be solved urgently.

[0047] To solve the above problems, an embodiment of the present application provides a parallel control method based on alliance chain transaction conflicts, which is applied to an alliance chain platform. First, t transactions of a target consensus node on a target alliance chain are obtained, where the target alliance chain includes f consensus nodes, and t and f are both integers greater than 1; then, the t transactions are packaged through a consensus algorithm to obtain a first block, and the first block is broadcast to f-1 consensus nodes among the f consensus nodes except the target consensus node; static analysis is performed on the first block to obtain a static analysis result; based on the static analysis result, a conflict rate is calculated for the transaction to obtain a transaction conflict rate; when the transaction conflict rate is greater than a preset threshold, the t transactions are executed in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result; based on the consensus algorithm, the first execution is used to perform a parallel control on the t transactions to obtain a first execution result; The result fills the first block to obtain the target first block, and broadcasts the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, the transaction is executed in parallel on the consensus node through the consistency concurrency control algorithm to obtain the second execution result; the second execution results corresponding to the f-1 consensus nodes are collected to obtain f-1 second execution results, and the f-1 second execution results are packaged to obtain the first execution result message packet; the first execution result message packet is detected by the consensus algorithm to see whether it meets the first preset condition; when the first execution result message packet meets the first preset condition, the target first block is submitted to the target alliance chain; when the first execution result message packet does not meet the first preset condition, the target first block is discarded. In the scenario where transactions conflict with the same resource, the performance of the concurrency control algorithm is improved.

[0048] Combine the following Figure 1 A parallel control method based on alliance chain transaction conflicts in an embodiment of the present application is described. Figure 1 The flowchart of a parallel control method based on alliance chain transaction conflicts provided by an embodiment of the present application specifically includes the following steps:

[0049] Step S110, obtaining t transactions of the target consensus node on the target alliance chain, the target alliance chain includes f consensus nodes, t and f are both integers greater than 1; the target consensus node is any consensus node among the f consensus nodes.

[0050] Among them, the alliance chain is composed of multiple consensus nodes. Consensus nodes are independent nodes running on different devices. Each node can process transactions on the chain and conduct consensus voting. These consensus nodes coordinate and communicate through a pre-set consensus algorithm to ensure the security and consistency of data on the alliance chain. Among them, for the t transactions on the target alliance chain, it refers to the current target consensus node selected from the transaction pool according to the existing transaction records in the transaction pool it manages, according to the preset rules and conditions. The transaction pool of the target consensus node usually stores multiple transactions on the chain waiting to be executed or processed, ensuring that these transactions comply with the preset order and can participate in the construction and consensus process of the block in sequence according to the specified priority.

[0051] Among them, the consensus nodes on the target alliance chain are distributed on different network nodes or physical nodes. Each consensus node has the ability to verify transactions on the chain and is responsible for maintaining the integrity of transactions and the consistency of data. In the consensus algorithm of the alliance chain, each consensus node is usually required to process and confirm a specific number of transactions. Each transaction contains information such as the initiator, recipient, transaction amount or data, and transaction timestamp. The target consensus node selects transactions that meet the current block construction conditions from t transactions and includes them in the block to be generated, and generates a hash value of the transaction for subsequent verification. After receiving these transactions, the target alliance chain will screen out appropriate transaction types, such as account transfers, smart contract calls, etc., based on the business needs of the alliance chain, so that these transactions can be fully recorded on the chain. Before each transaction is finally confirmed into the chain, it will go through multiple confirmations, executions, and data storage by the consensus node to ensure the immutability of the transaction and the consistency of the data.

[0052] Step S120: Pack the t transactions through a consensus algorithm to obtain a first block, and broadcast the first block to f-1 consensus nodes among the f consensus nodes except the target consensus node.

[0053] Among them, the blocks in the alliance chain are generated by the nodes participating in the consensus. In the Practical Byzantine Fault Tolerance (PBFT) consensus algorithm used by FISCO BCOS, the consensus nodes in each round are divided into leading consensus nodes and ordinary consensus nodes. In each round of consensus, the leading consensus node is responsible for the generation of new blocks. All consensus nodes verify the new blocks together. When more than 2f+1 nodes reach a consensus on the new block, the new block will be added to the blockchain. In each round of consensus, the leader node obtains transactions from its own transaction pool and uses the obtained transactions to construct a new block. The block consists of a block header and a block body. The block header contains information about the parent block, a list of consensus node signatures for this block, a transaction root, a receipt root, and a status root. When the leader node just constructs a new block, the transaction root and status root in the block header are both zero values, and the corresponding receipt-related fields in the block body are also empty, because the block has not been executed at this time. The leader node sends the block to other consensus nodes first rather than sending it to other nodes for verification after execution.

[0054] Among them, after receiving the message package containing the new block generated by the leader consensus node, the consensus node first verifies the legitimacy of the consensus message according to the rules of the consensus algorithm, such as verifying whether the signer of the message is a consensus node and whether the signature is valid. In order to reduce network overhead, the block message package sent by the leader consensus node only contains the transaction hash. After verification, the consensus node will do some preparation before executing the transaction, including obtaining complete transaction information from its own transaction pool or other consensus nodes based on the transaction hash, analyzing the conflict dependency of the transaction, calculating the conflict rate and selecting the transaction execution algorithm. Each consensus node will execute the transactions in the block and supplement the fields that were not filled when the leader node constructed the block based on their respective execution results. After that, each consensus node will broadcast its own execution results and check whether it can reach a consensus on this block according to the conditions required by the consensus algorithm (for example, PBFT requires the collection of more than 2f signatures with the same results except for itself). If consensus is reached, a new block will be generated. Otherwise, the current block will be discarded after the timeout and the next round of consensus will be started.

[0055] Step S130, performing static analysis on the first block to obtain a static analysis result.

[0056] Among them, blocks are composed of transactions. Transactions on the alliance chain can be divided into two types, one is the transaction of deploying contracts, and the other is the transaction of calling contracts. For transactions that deploy contracts, there will be no conflict with other transactions. For transactions that call contracts, the transaction will provide the calling interface and parameters. If there are multiple transactions accessing the same contract, conflicts may occur. Static analysis is completed when the contract is deployed. When the contract is deployed, static analysis analyzes the behavior of each contract interface based on the bytecode of the contract. According to whether there are bytecodes for storage, reading and writing, bytecodes for accessing globally shared environment variables, and bytecodes for contract calls, it analyzes whether each interface of this contract can be executed in parallel. If it can be executed in parallel, what are the keys that this interface competes for access. After the static analysis obtains the results, when the contract is deployed, the analysis results are stored in the interface description file of the contract. When executed, the interface description file of the contract called by the transaction is obtained, and the keys that will actually be accessed in this transaction are parsed in combination with the actual interface parameters in the transaction.

[0057] Among them, the interface description file refers to the behavior description of each interface of the contract, which records whether it involves operations such as storage, global variables, and contract calls, and pre-analyzes possible concurrency problems; the actual interface parameters refer to the specific input parameters in the contract interface when executing the contract transaction. In the call of the smart contract, parameters usually need to be passed. For example, in the transfer transaction, the interface parameters may include the sender address, the receiver address, the transfer amount, etc. These parameters determine which data the transaction will actually access (for example, which account balance, which key-value pair, etc.). Its function is to combine the information in the interface description file, and the system can analyze which keys will actually be accessed in the transaction through the actual interface parameters. For example, in the transfer operation, by parsing the transaction parameters, you can know which account balances this transaction will access, so as to determine whether there is a concurrency conflict. Through the static analysis results of the program when the user deploys the contract, combined with the input parameters of the contract interface in the transaction, you can obtain the key-value pairs stored on the alliance chain that each transaction will access. According to the key-value pairs stored on the alliance chain accessed by each transaction, you can analyze the transaction call contract of the block.

[0058] To describe static analysis more clearly, let's take an example to illustrate: there is a transfer contract, which has an interface called transfer(string memory from, string memory to, uint256 amount). The transfer interface has three parameters, namely from, to and amount, which are used to transfer amount from the from account to the to account. The logic of this interface is to deduct amount from the from account and increase amount to the to account. Then, when the from or to of two transactions calling this contract interface are the same, for example, transaction 1: A->B, transaction 2: A->C, these two transactions cannot be executed in parallel, because modifying the same key at the same time will cause uncertain results.

[0059] Step S140: Calculate the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate.

[0060] Among them, transaction conflict refers to the conflict between reading and writing of contracts called by different transactions in the block. Contract refers to the program or protocol deployed on the alliance chain. The contract is called by the transaction to perform corresponding operations or state changes. Among them, transaction conflict occurs when the contracts with the same key operation are divided into the same block when constructing the block. There are many ways to calculate the transaction conflict rate, for example, based on the percentage of non-parallel transactions in the block to the total transactions in the block; construct a directed acyclic graph based on the results of transaction conflict analysis, calculate the longest path of the directed acyclic graph, and divide the longest path by the total number of transactions to obtain the percentage.

[0061] In a possible embodiment, the conflict rate of the transaction is calculated based on the static analysis result to obtain the transaction conflict rate, which specifically includes: determining the number p of non-parallel transactions among the t transactions according to the static analysis result; p is an integer greater than 1 and less than or equal to t; and determining the transaction conflict rate according to the t transactions and the number p of non-parallel transactions.

[0062] The transaction conflict rate can be calculated based on the percentage of non-parallel transactions in the block to the total transactions in the block. The number of non-parallel transactions in t transactions is p, and the calculation formula for the transaction conflict rate is:

[0063] c=(p / t)*100%

[0064] Wherein, c is the transaction conflict rate, p is the number of non-parallel transactions among t transactions, and p is an integer greater than 1 and less than or equal to t.

[0065] It can be seen that in the embodiment of the present application, by calculating the transaction conflict rate of the block, the possibility of parallel execution of transactions in the block can be effectively evaluated. According to the result of the conflict rate, the strategy of parallel execution of blocks is adjusted, and the parallel execution mode of directed acyclic graph or consistent concurrent control algorithm is dynamically selected, which can improve the efficiency of block processing on the basis of maintaining transaction consistency, thereby ensuring the consistency of execution results between consensus nodes while efficiently utilizing system computing resources, which is conducive to improving the overall performance of the alliance chain and reducing the delay of transaction confirmation.

[0066] Step S150, when the transaction conflict rate is greater than a preset threshold, the t transactions are executed in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result.

[0067] Among them, if the transaction conflict rate is less than or equal to the preset threshold, the directed acyclic graph algorithm is used to execute the transaction in parallel; if the transaction conflict rate is greater than the preset threshold, the consistent concurrency control algorithm is used to process the transaction in parallel. For example, assuming that the conflict rate = non-parallel transactions / total number of block transactions * 100% method is used, there are 8 transactions, of which 8 transactions cannot obtain the keys that will be accessed during their execution through static analysis, using the number of non-parallel transactions = 8 / total number of transactions = 8, it can be concluded that the proportion of non-parallel transactions is 100%. Assuming that the conflict rate required by the directed acyclic graph is less than 80%, since 100%>80%, the consistent concurrency control algorithm is used for execution.

[0068] In a possible embodiment, the t transactions are executed in parallel on the target consensus node by using a consistency concurrency control algorithm to obtain a first execution result, which specifically includes:

[0069] 51. Obtain the number of machine logical cores M of the target consensus node, where M is an integer greater than 1; the number of machine logical cores M indicates that the target consensus node can process M tasks in parallel at the same time;

[0070] 52. Sequentially select transactions 1 to M in the first block to obtain a first group of M transactions;

[0071] 53. Execute the first group of M transactions in parallel on the target consensus node using the consistency concurrency control algorithm to obtain the first execution result.

[0072] Among them, in the high-concurrency transaction processing scenario, the transaction tasks are reasonably allocated by obtaining the logical core number M of the target consensus node. The logical core number M represents the maximum number of tasks that the target consensus node can process simultaneously. By grouping transactions, the consensus node can maximize the use of computing resources and improve the parallel execution efficiency of transactions. Then, 1 to M transactions are selected from the first block in the order of transactions as a group to ensure that the transactions maintain a consistent order during processing. Through this grouping method, the execution of each group of transactions will not be interfered by other unprocessed transactions, and can be dynamically adjusted according to the priority, data dependency and other characteristics of each transaction, ensuring that the dependency between transactions will not destroy the consistency of transactions during concurrent execution. Then, when executing the first group of M transactions in parallel, each transaction implements a distributed lock mechanism through a consistent concurrency control algorithm. Specifically, each transaction acquires the corresponding lock according to its operation type (such as read lock or write lock) during execution to ensure that it will not be affected by other transactions when operating key resources. In addition, during the transaction processing process, all locks are released only after the execution is completed to avoid deadlock problems during execution. If there are conflicting transactions in the first group of M transactions (i.e., write-write conflict, write-before-read conflict, or read-before-write conflict in operations on the same resource), the consistency concurrency control algorithm determines the priority of the conflicting transactions through the Index. Generally, transactions with smaller Indexes are processed first, that is, tasks with a higher transaction order will be executed first, while other transactions in the conflict may be rolled back or wait for operations. Finally, during the transaction execution process, if a rollback caused by a conflict is detected, the rolled back transaction will be reallocated to the next batch of transaction groups for re-execution. When the rolled back transaction is re-executed, it will be re-locked according to the latest resource status to ensure that the re-executed transaction no longer conflicts with other transactions, avoiding the execution failure or loss of the rolled back transaction. After all transactions are completed, all consensus nodes on the alliance chain perform consistency checks on the first execution result. Specifically, the target consensus node compares the execution results and data status of each transaction to ensure that the execution results obtained by each transaction on different nodes are consistent. If the results are inconsistent, the system will trigger a retry mechanism to re-execute the transaction with deviations until the execution results of all nodes are completely consistent, and finally achieve consensus in the network.

[0073] It can be seen that in the embodiment of the present application, by dynamically detecting the number of logical cores M, the system can make real-time task scheduling adjustments according to the current load of the target consensus node, so that the efficiency of multi-task parallel processing is optimized. Under high load conditions, the system can flexibly adjust the number of transactions in each group and dynamically adapt to the state of computing resources, thereby avoiding reduced execution efficiency or delays caused by overload or insufficient resources.

[0074] In a possible embodiment, executing the first group of M transactions in parallel on the target consensus node by using the consistency concurrency control algorithm to obtain the first execution result specifically includes:

[0075] 531. Determine the read-write key-value pairs of the first group of M transactions, and lock the read-write keys to obtain M transaction locks;

[0076] 532. Determine the state of the target transaction lock, where the state of the target transaction lock includes a read lock and / or a write lock, and the target transaction lock is any transaction lock among the M transaction locks;

[0077] 533. Determine whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock;

[0078] 534. When there is a mutual exclusion phenomenon among the target transaction locks, the first group of M transactions are executed in parallel on the conflicting transactions corresponding to the target transaction locks by using the consistency concurrency control algorithm on the target consensus node to obtain the first execution result.

[0079] Among them, in the process of executing the first group of M transactions in parallel through the consistency concurrency control algorithm, a multi-layer control mechanism is specially adopted to reasonably handle the acquisition of transaction locks, mutual exclusion detection and conflict handling. First, by determining the read-write key-value pairs involved in each transaction, the system assigns a corresponding read lock or write lock to each transaction, thereby forming M transaction locks. This locking mechanism allows the system to lock the resources required by the transaction before execution, ensuring that the transaction will not be affected by other transactions during execution. The read lock allows multiple transactions to read the same data at the same time, while the write lock monopolizes the corresponding resources to prevent write conflicts from other transactions. Then, in the process of parallel processing, the system detects the status of each transaction lock in the first group of M transactions to determine the specific status of the target transaction lock. The status of the target transaction lock can be a read lock or a write lock, or a combination of the two. The read lock status indicates that the transaction only needs to read data and does not involve data modification operations; the write lock status indicates that the transaction will modify the data. Then, after the status of the transaction lock is determined, the system performs mutual exclusion detection on each target transaction lock to identify conflicts that may affect parallel execution. The mutual exclusion phenomenon is mainly divided into the following situations: write-write conflict. When multiple transactions attempt to write to the same contract at the same time, the algorithm will detect a write-write conflict, which will lead to a resource exclusive conflict. To avoid deadlocks caused by write-write conflicts, the system will prioritize write locks or rollback strategies to ensure that transactions are executed in sequence; read-write conflict. When one transaction holds a write lock and another transaction only holds a read lock, a read-write conflict will occur. The algorithm will give priority to write lock transactions and make read lock transactions wait to ensure data consistency.

[0080] Among them, when mutual exclusion is detected in the target transaction lock, the conflicting transactions are processed through the consistency concurrency control algorithm. Specifically, for the conflicting transactions in the first group of M transactions, the system reorders and executes them step by step according to their lock types and priorities. After all transactions are executed in parallel, the system will perform a consistency check on the first execution result. In the above-mentioned locking and mutual exclusion processing mechanism, the algorithm also adopts a resource optimization strategy to prevent deadlock. By adopting a phased processing strategy of locking first and then unlocking, as well as rolling back high-index transaction lock resources, the possibility of deadlock is effectively reduced. In addition, the system also dynamically detects the availability of resources to reasonably allocate the parallel number of transactions and lock resources under high load, further improving the processing capacity and response speed of the target consensus node.

[0081] In a possible embodiment, judging whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock specifically includes:

[0082] 5331. Determine the target transaction corresponding to the target transaction lock;

[0083] 5332. Lock the target transaction and the first transaction to obtain a locked target transaction and a locked first transaction; the first transaction is a transaction corresponding to any transaction lock among the M transaction locks;

[0084] 5333. Perform mutual exclusion analysis on the target transaction in the locked state and the first transaction in the locked state to obtain a mutual exclusion analysis result.

[0085] S334. When the mutual exclusion analysis result meets the preset requirement, it is determined that the mutual exclusion phenomenon exists between the target transaction lock and the first transaction; the preset requirement is that there is at least one of the following conflicts between the target transaction lock and the first transaction: read-before-write conflict, write-before-read conflict, and write-write conflict.

[0086] Among them, before judging the mutual exclusion phenomenon, it is first necessary to determine the specific transaction corresponding to the target transaction lock, that is, the target transaction. After clarifying the target transaction, the system locks the target transaction and its potentially conflicting first transaction respectively to ensure that the transaction will not be interfered with by other concurrent transactions during the conflict detection process. The setting of the lock state includes read lock and write lock, which depends on the operation type of the transaction. The first transaction can be the transaction corresponding to any one of the M transaction locks, and the allocation of its lock state must ensure that it matches the lock state of the target transaction, so as to achieve accurate judgment during mutual exclusion detection. After the transaction is locked, the system performs mutual exclusion analysis on the target transaction in the locked state and the first transaction in the locked state. The mutual exclusion analysis is based on checking the read and write status and sequence relationship of the transaction lock to determine whether there is a conflict in resource use between the two transactions. Mutual exclusion analysis is usually performed based on the following three types of conflicts: read-before-write conflict. When the target transaction lock is a read lock and the first transaction intends to write to the same resource, a read-before-write conflict will occur. To ensure data consistency, the algorithm may prioritize the write transaction after detecting this conflict and allow the read lock transaction to reacquire the resource; write-before-read conflict. When the target transaction lock is a write lock and the first transaction is only a read lock, it means that the write operation is performed on the transaction first to avoid subsequent read operations from reading incomplete transactions. When encountering a write-before-read conflict, the algorithm usually prioritizes the write lock transaction to avoid data reading deviation. Write-write conflict. When the target transaction lock and the first transaction are both write locks, a write-write conflict will occur. At this time, the algorithm will decide the transaction to be executed first based on the order or priority of the transactions, and the other transaction needs to wait or roll back to ensure eventual consistency.

[0087] It can be seen that in the embodiments of the present application, accurate judgment and efficient processing of transaction conflicts are achieved, ensuring the integrity and consistency of data during parallel execution, while also improving the resource utilization efficiency and response speed of the multi-node system.

[0088] In a possible embodiment, executing the first group of M transactions in parallel on the conflicting transactions corresponding to the target transaction lock through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result specifically includes:

[0089] A1. Obtain a first transaction index corresponding to the first transaction, where the first transaction index indicates a serial number corresponding to the first transaction in the serial numbers of the M transactions in the first block;

[0090] A2. Determine the lock-holding transaction corresponding to the target transaction, where the lock-holding transaction includes a transaction holding a write lock and a transaction holding a read lock; the transaction holding a write lock corresponds to the transaction index holding a write lock, and the transaction holding a read lock corresponds to the transaction index holding a read lock;

[0091] A3. If the conflict between the target transaction lock and the first transaction is the write-write conflict, compare the Index of the transaction holding the write lock with the Index of the first transaction;

[0092] A4. When the Index of the transaction holding the write lock is greater than the Index of the first transaction, roll back the transaction holding the write lock;

[0093] A5. When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result;

[0094] A6. If the conflict between the target transaction lock and the first transaction is a write-before-read conflict, compare the Index of the transaction holding the write lock with the Index of the first transaction;

[0095] A7. When the Index of the transaction holding the write lock is greater than the Index of the first transaction, the transaction holding the write lock and the transaction holding the write lock and having an Index greater than the first transaction are rolled back;

[0096] A8. When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result;

[0097] A9. If the conflict between the target transaction lock and the first transaction is a read-before-write conflict, compare the Index of the transaction holding the read lock with the Index of the first transaction;

[0098] A10. When the Index of the transaction holding the read lock is greater than the Index of the first transaction, roll back the transaction holding the read lock.

[0099] A11. When the Index of the transaction holding the read lock is less than or equal to the Index of the first transaction, wait for the transaction holding the read lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result.

[0100] Among them, when each transaction is executed, the execution of the transaction is divided into two stages: locking and unlocking. During the execution process, only locks are added, and no locks are released. After the execution is completed, all locks are released uniformly. In this way, deadlock can be avoided. Among them, the locking and rollback method of transaction execution can be used to ensure the consistency of the execution results of multiple consensus nodes (through the analysis and processing of different situations, it can be ensured that the conflicts in the transaction execution process are handled in a certain order. Only in this way can the final execution results of the consensus nodes on different logical core machines be the same. Otherwise, different nodes will have different execution results, resulting in the inability of the consensus nodes to reach a consensus).

[0101] Among them, when a write-write conflict occurs, there is a transaction holding a write lock, and the conflicting transaction requests a write lock. At this time, the Index of the conflicting transaction is compared with the Index of the transaction holding a write lock. If the Index of the transaction holding a write lock is greater than the Index of the conflicting transaction, the transaction holding the write lock is rolled back. The transaction that has held a write lock in the past and whose Index is larger than the conflicting transaction also needs to be rolled back. If the Index of the write lock transaction is smaller than the Index of the conflicting transaction, wait for the transaction holding the write lock to complete before executing the transaction. When a write-first-read-later conflict occurs, there is a transaction holding a write lock, and the conflicting transaction requests a read lock. At this time, the Index of the conflicting transaction is compared with the Index of the transaction holding a write lock. If the Index of the transaction holding a write lock is greater than the Index of the conflicting transaction, the transaction holding the write lock is rolled back. The transaction that has held a write lock in the past and whose Index is larger than the conflicting transaction also needs to be rolled back. If the write lock If the transaction index is smaller than the conflicting transaction index, the transaction will be executed after waiting for the transaction holding the write lock to complete. If the write lock index is equal to the conflicting transaction index, it will be accessed directly. When a read-before-write conflict occurs, some transactions hold read locks, and the conflicting transaction requests a write lock. At this time, the index of the write lock transaction is compared with the index of the transaction holding the read lock. All read lock transactions that are larger than the write lock index need to be rolled back. Transactions that have held read locks in the past and whose index is larger than the write lock also need to be rolled back. At this time, the index of the transaction holding the read lock is less than or equal to the index of the reread transaction. For the case where the read lock is held and the index is smaller than the conflicting transaction index, the conflicting transaction needs to wait for the transaction holding the read lock to complete. After the transaction with an index smaller than the conflicting transaction index is completed, the conflicting transaction obtains the write lock to complete the transaction execution.

[0102] To more clearly illustrate the consistency control algorithm's deployment of rollback and waiting for conflicting transactions, an example is given to illustrate: for example, there are 4 transactions executed, and there are many possible situations. This example selects one possible situation to illustrate. Transactions 1, 2, 3, and 4 are executed in parallel, and the timing is exactly 1, 2, 4, and 3. Then: transaction 1 attempts to obtain the read lock of key1 and the write lock of key3. At this time, no other transaction holds the lock. Transaction 1 obtains the read lock of key1 and the write lock of key3 and continues to execute; transaction 2 attempts to obtain the read lock of key2 and the write lock of key5. At this time, no other transaction holds the lock. Transaction 2 obtains the read lock of key2 and the write lock of key5 and continues to execute; transaction 4 attempts to obtain the write lock of key2 and the write lock of key1. At this time, transaction 2 holds the read lock of key2. Transaction 4 continues to wait for transaction 2 to complete, obtains the write lock of key2, and tries to obtain the write lock of key1. At this time, transaction 1 holds k ey1's read lock, transaction 4 waits for transaction 1 to complete; transaction 3 tries to obtain the write lock of key1 and key2. At this time, transaction 1 holds the read lock of key1, and a conflict occurs. For key1, the Index = 3 of transaction 3 is greater than the Index = 1 of transaction 1 holding the read lock, so transaction 3 waits for transaction 1 to complete. After transaction 1 is completed, transaction 3 obtains the write lock of key1 and tries to obtain the write lock of key2. At this time, transaction 2 holds the read lock of key2. Transaction 3 continues to wait for transaction 2 to complete and obtain the write lock of key2; after transactions 1 and 2 are completed, transaction 3 obtains the write lock of key1, and transaction 4 obtains the write lock of key2; transaction 3 tries to obtain the write lock of key2 and finds that transaction 4 holds the write lock of key2. The Index = 3 of transaction 3 is less than the Index = 4 of transaction 4. At this time, transaction 4 is rolled back, and transaction 3 obtains the write lock of key2 and completes execution.

[0103] Among them, see Figure 2 , Figure 2 It is a flowchart of the execution of the consistency and concurrency control algorithm, such as Figure 2As shown in the figure, first, according to the number of machine cores M of the target consensus node, sequentially obtain transactions numbered 1-M from t transactions to start execution. If the number of transactions obtained is 0, the block execution is completed. If the number of transactions obtained is greater than or equal to 1, it is executed according to the rule consistency parallel control algorithm. For the key-value pairs of read and write, they must be locked first and then read and write. The lock is divided into read lock and write lock. The lock records the index of the transaction (this index can be understood as the sequential number of the transaction in the block). Read locks and read locks are not mutually exclusive, write-write, read-write are mutually exclusive, and mutually exclusive locks cannot exist at the same time (if not locked first, for the key with competitive access, the final result is uncertain). Then, the write-write conflict, write-first-read-later conflict, and write-first-read-later conflict are respectively rolled back or waited for execution to avoid conflicts in the call of the contract by the transaction, so that the transactions can be executed in parallel. Then, the above execution operations are repeated for the remaining transactions in sequence until the execution of p conflicting transactions is completed. Finally, the results of the execution of the consistency and concurrency control algorithm are filled into the block header, and consensus analysis is performed through all consensus nodes to verify the consistency of the execution results.

[0104] It can be seen that in the embodiment of the present application, when each transaction is executed, locking and unlocking are divided into two stages. During the execution process, only locks are added, and no locks are released. All locks are released uniformly after the execution is completed, thereby effectively avoiding the occurrence of deadlock. Through the locking and rollback strategy, it is possible to ensure that the execution results of each consensus node are consistent in various conflict scenarios, that is, a consensus can still be reached in the execution order of different nodes, ensuring the reliability and effectiveness of consistency control.

[0105] Step S160, based on the consensus algorithm, fill the first block with the first execution result to obtain a target first block, and broadcast the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, execute the transaction in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result.

[0106] Among them, the consensus algorithm is first used to process the first execution result. Specifically, the consensus algorithm will analyze the transaction execution results obtained after the consistency and concurrency control algorithm is processed, and integrate these results into the block header, so that some bytes in the previously generated block are filled with values. The target first block not only contains the core data of the execution result, but also includes relevant information of the transaction, such as the hash value of the transaction, the initiator and receiver information, and the timestamp, etc., so as to facilitate subsequent integrity verification and traceability. After the target first block is filled, the system will broadcast the first block to f-1 consensus nodes on the alliance chain except its own node through the network protocol. This broadcast process ensures that each consensus node can receive the information of the new block in real time and perform corresponding processing.

[0107] Among them, when any consensus node receives the target first block, the node will use the consistency concurrency control algorithm to process the transactions contained in it in parallel. The purpose of the design of this algorithm is to improve the efficiency of concurrent processing while ensuring the consistency of transaction execution. The result of the parallel execution of the consistency concurrency control algorithm will form the second execution result, which will be used in the further consensus process to ensure that the transaction processing of the entire alliance chain can be carried out efficiently and accurately.

[0108] Step S170, collect the second execution results corresponding to the f-1 consensus nodes, obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package.

[0109] Among them, the second execution result is the result of the consensus node processing the conflicting transactions in the block through the consistency parallel control algorithm. First, the target alliance chain collects the corresponding second execution results from each consensus node through the network protocol. Each consensus node generates an execution result based on the same transaction set during the parallel execution process. In theory, these results should be the same. If there are differences in the results, the system needs to check through the consistency check mechanism to ensure that the execution results of all nodes meet the preset business logic and technical standards. Then, the target alliance chain will uniformly format the collected f-1 second execution results for subsequent processing. This formatting process may include organizing the relevant data of each result (such as node ID, timestamp, execution status, etc.) into a unified data structure. Then, the target alliance chain packages these sorted second execution results to form a first execution result message package. During this packaging process, the system will summarize all valid execution results and attach the corresponding hash value to ensure the integrity and security of the data during transmission. This hash value is not only used to verify the integrity of the message package, but also can provide a fast verification method for the subsequent consensus process. Finally, when the first execution result message package is generated, the target consensus node will broadcast it to other consensus nodes in the target alliance chain so that other nodes can verify and make decisions. The broadcast mechanism ensures that all consensus nodes can obtain the execution result information in a timely manner and participate in the subsequent consensus process. At the same time, it also improves the transparency of the system, allowing all participants to clearly understand the status and results of transaction execution, thereby enhancing trust in the overall security of the alliance chain.

[0110] Step S180: Detecting whether the first execution result message packet meets a first preset condition through the consensus algorithm.

[0111] Among them, the first preset condition includes but is not limited to the number of collected execution result message packets reaching the required threshold. For example, in the PBFT consensus algorithm, a node needs to collect execution result message packets from at least 2f nodes other than itself. In addition, the execution result in the execution result message packet must be consistent with the execution result of the current node itself to ensure the validity and consistency of the block. The process of consensus algorithm detection involves verifying the received message packets, including checking the transaction hash, block header information and signature, etc., to ensure that each message packet comes from a legitimate consensus node and the data has not been tampered with.

[0112] In a possible embodiment, when the first execution result message package satisfies the first preset condition, the method specifically further includes: obtaining a transaction root, a receipt root, and a status root in the first execution result message; determining whether a third preset condition is satisfied between the first execution result and the f-1 second execution results; when the third preset condition is satisfied between the first execution result and the f-1 second execution results, filling the transaction root, the receipt root, and the status root into the first block through the consensus algorithm to obtain the filled first block; and updating the status root in the filled first block to obtain the target first block.

[0113] Among them, when the first execution result message packet meets the first preset condition, first, the transaction root, receipt root and status root in the first execution result message are obtained to ensure the integrity and traceability of the block. Among them, the transaction root, receipt root and status root are important components of the block header, and they are usually represented by a Merkle Tree to ensure the integrity and consistency of the data in the block. In simple terms, the transaction root is used to verify the integrity of the transaction in the block, the receipt root is used to verify the integrity of the transaction receipt; the status root is used to verify the change of the account status after the transaction in the block is executed. Among them, the block contains many transactions, each transaction will generate a hash value, all hash values ​​are calculated by the Merkle tree method, and finally a unique root hash value, namely the transaction root, is obtained; the receipt root is a summary of the hash values ​​of all transaction receipts. After each transaction is completed, a corresponding transaction receipt will be generated. The receipt root is the transaction receipt hash value calculated by the Merkle tree. The state root is a summary of the hash values ​​of all account states in the block. The state of each account (such as balance, storage, etc.) will be updated after the blockchain executes a transaction. The state root is the account state hash value calculated by the Merkle tree.

[0114] Next, the transaction roots, receipt roots and status roots of these execution results are compared to verify their consistency. Among them, the second execution result is the execution result obtained by other consensus nodes through the same parallel processing. When the first execution result and the f-1 second execution results meet the third preset condition, it means that the execution results of each node are consistent. At this time, the transaction root, receipt root and status root are filled into the first block through the consensus algorithm to form the filled first block. Among them, the third preset condition is that the execution results submitted by all consensus nodes should have the same transaction root, receipt root and status root, so as to ensure that the operation results of each node remain consistent during the generation and execution of the block.

[0115] Finally, the state root in the filled first block is updated to reflect the latest state of the current block, and the target first block is obtained. This update process ensures that the state of the blockchain can correctly reflect the execution status and results of all transactions, thereby maintaining the stability and consistency of the entire alliance chain system.

[0116] It can be seen that in the embodiment of the present application, by implementing the steps of obtaining the transaction root, receipt root and status root when the first execution result message packet meets the first preset condition, the integrity and consistency of the transactions in the block can be effectively ensured. Subsequently, it is determined whether the first execution result and the f-1 second execution results meet the third preset condition. Through this verification process, it is ensured that all participating consensus nodes obtain consistent results when executing transactions. After the third preset condition is met, the transaction root, receipt root and status root are filled into the first block through the consensus algorithm. The status root of the filled block is updated, and the target first block is finally obtained, ensuring that the state of the blockchain reflects the latest transaction execution status.

[0117] In a possible embodiment, each of the t transactions corresponds to a transaction access information, and the method further includes: when the transaction conflict rate is less than or equal to the preset threshold, obtaining first transaction access information, the first transaction access information being the transaction access information of any transaction among the t transactions; determining the corresponding transaction access key-value pair based on the first access information to obtain a first transaction key-value pair; judging whether the first transaction can be processed in parallel based on the first transaction key-value pair and the first transaction access information; when the first transaction can be processed in parallel, obtaining conflict domain information of the t transactions; determining conflict information corresponding to the first transaction access information based on the conflict domain information; determining a first directed acyclic graph of transaction execution based on the t transactions; constructing a dependency edge in the first directed acyclic graph based on the conflict information to obtain a second directed acyclic graph; executing the t transactions based on the second directed acyclic graph to obtain The third execution result; based on the consensus algorithm, the first block is filled with the third execution result to obtain the target second block, and the target second block is broadcast to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target second block, the t transactions are executed in parallel on the consensus node through the second directed acyclic graph to obtain a fourth execution result; the fourth execution results corresponding to the f-1 consensus nodes are collected to obtain f-1 fourth execution results, and the f-1 fourth execution results are packaged to obtain a second execution result message packet; the second execution result message packet is detected by the consensus algorithm to determine whether it meets the second preset condition; when the second execution result message packet meets the second preset condition, the target second block is submitted to the target alliance chain; when the second execution result message packet does not meet the second preset condition, the target second block is discarded.

[0118] When each consensus node executes a transaction, it will first parse the transaction parameters, analyze the contract data list that each transaction will access based on the called contract, method, parameters, and read-write access information registered on the chain in advance, and construct a directed acyclic graph based on the order of transactions in the block. The directed acyclic graph constructed by the transaction call situation can be used to process transactions in the block in parallel. Since the information used to construct the directed acyclic graph is consistent in each consensus node, and the construction algorithm of the directed acyclic graph is also the same in each node, the directed acyclic graphs constructed by different consensus nodes are exactly the same.

[0119] Among them, see Figure 3 , Figure 3 It is a flow chart constructed from a directed acyclic graph, such as Figure 3As shown in the figure, first, the transaction parameters are parsed and the contracts called by each transaction and their corresponding methods and parameters are identified. Based on this information and the previously registered read and write access information, a list of access data for each transaction is constructed. Then, after obtaining the access information of t transactions, the dependencies of each transaction are analyzed one by one according to the order of transactions in the block to ensure that the order between transactions does not cause conflicts, so as to determine which transactions can be executed in parallel and which transactions need to be processed serially, by arranging the access keys of transactions into nodes and adding directed edges in the graph according to the dependencies between transactions to indicate the execution order from one transaction to another. This construction process ensures that transactions can be executed in parallel only when there is no conflict, thereby optimizing the efficiency of transaction processing.

[0120] Furthermore, in the process of parallel processing of transactions within a block on a directed acyclic graph for transaction execution, the system's processing efficiency can be significantly improved by analyzing the dependencies between transactions. Specifically, using a directed acyclic graph, consensus nodes can identify which transactions can be executed simultaneously, thereby optimizing resource utilization. Each node in the directed acyclic graph represents a transaction, and directed edges indicate the order of transactions. Through this structure, consensus nodes can ensure that transactions are executed in parallel without violating transaction dependencies.

[0121] Among them, based on the constructed directed acyclic graph, the consensus node will execute t transactions in parallel to obtain the third execution result. Then, through the consensus algorithm, the consensus node uses the execution result to fill the information in the block header to form the target second block and broadcast it to all f-1 consensus nodes. After any consensus node receives the target second block, the node will execute t transactions in parallel through the second directed acyclic graph to obtain the execution result. Then, each consensus node collects its own execution results and packages them into a result message packet. Finally, the consensus node will use the consensus algorithm to verify the legal block and submit it to the target alliance chain; if the legitimacy of the consensus algorithm is not met, the block will be discarded. During the execution process, the consensus node can process transactions in parallel according to the same directed acyclic graph, taking advantage of the multi-core processor to accelerate the processing speed of transactions. In addition, using the parallel processing mechanism of the directed acyclic graph, the system can dynamically adjust the execution order and strategy of transactions. When it is detected that the conflict rate of some transactions is low, the system will choose the parallel processing method; when the conflict rate rises, it may automatically switch to the serial execution mode to ensure the consistency and correctness of the transaction. This flexible processing method enables the alliance chain to operate efficiently and stably when facing changing transaction requests.

[0122] It can be seen that in the embodiment of the present application, by processing transactions in parallel on a directed acyclic graph, not only the overall system performance is improved, but also a faster transaction confirmation experience is provided to users. This mechanism not only improves transaction efficiency, but also ensures the consistency of execution results between consensus nodes, further enhancing the reliability and availability of the alliance chain.

[0123] Step S190: when the first execution result message packet satisfies the first preset condition, the target first block is submitted to the target alliance chain; when the first execution result message packet does not satisfy the first preset condition, the target first block is discarded.

[0124] Among them, when the first execution result message packet meets the first preset condition, the process of submitting the target first block to the target alliance chain includes broadcasting the verified block information to all participating consensus nodes to ensure that each node can synchronously update its local blockchain status. In addition, the submitted block will be marked as valid, allowing subsequent transactions to be processed and executed based on this block, thereby ensuring the operating efficiency and consistency of the entire alliance chain; conversely, when the first execution result message packet does not meet the first preset condition, the operation of discarding the target first block ensures the integrity and security of the blockchain. Through this mechanism, any potential errors or inconsistent blocks will not be introduced into the chain, preventing data pollution and confusion in subsequent operations. This strategy enhances the consensus node's strict review of the validity of the block, ensuring that the block can only be formally accepted and added to the alliance chain when all verification conditions are met, thereby maintaining the stability and reliability of the entire system.

[0125] See also Figure 4 , Figure 4 It is a flowchart of executing the scheduling algorithm in the transaction conflict scenario on the alliance chain, such as Figure 4As shown in the figure, the leading consensus node first constructs a block from the transactions in the transaction pool and broadcasts it to other nodes participating in the consensus. When the consensus node receives a new block, it first verifies the validity of the block to ensure that the received block meets the requirements of the consensus algorithm. Then, the corresponding transaction content is retrieved one by one from each transaction pool in the order of transactions. If the corresponding transaction is missing in the transaction pool, these transactions can also be obtained from other consensus nodes through the network. Before preparing for transaction execution, the consensus node parses the key-value pairs that may be accessed during the execution of all transactions based on the static analysis results provided during deployment. Subsequently, the consensus node calculates whether to use the consistency concurrency control algorithm or the directed acyclic graph parallel algorithm for processing based on the conflict rate between transactions. Finally, the consensus node signs the block header information according to the consensus algorithm process and broadcasts the signed message package to other consensus nodes. Within the set timeout period, each consensus node collects the execution result message packages of other nodes to ensure that the execution results in these packages are consistent with its own results. For example, under the PBFT algorithm, the consensus node needs to collect message packets from 2f nodes except itself and verify their consistency (if the total number of nodes is 4, then f=1). If the conditions are met, it can enter the subsequent consensus process and finally complete the block submission. Otherwise, the block is discarded and the consensus state is restarted, thereby re-executing the block generation process.

[0126] It can be seen that through the above method flow, the directed acyclic graph parallel processing or the consistent concurrency control algorithm parallel processing can be adaptively selected according to the transaction conflict rate and the preset threshold to obtain better execution scheduling performance. Especially in the scenario with a high transaction conflict rate, a higher concurrency can be obtained, and concurrency control during transaction execution is realized to prevent transactions from conflicting with the same resource, thereby improving the performance of the concurrency control algorithm.

[0127] Combine the following Figure 5 The electronic device in the embodiment of the present application is described. Figure 5 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application is shown in FIG. Figure 5 As shown, the electronic device 500 includes a processor 510, a memory 520, a communication interface 530, and one or more programs 521. The processor 510 is connected to the memory 520 and the communication interface 530 through an internal communication bus. The one or more programs 521 are stored in the memory 520 and are configured to be executed by the processor 510. The one or more programs include instructions for executing any step in the above method embodiment.

[0128] Among them, the processor 510 can be a central processing unit (CPU), a general processor, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It can implement or execute various exemplary logic blocks, units and circuits described in conjunction with the disclosure of this application. The processor can also be a combination that implements a computing function, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, and the like. The communication unit can be a communication interface, a transceiver, a transceiver circuit, etc., and the storage unit can be a memory.

[0129] The memory 520 may be a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memories. The nonvolatile memory may be a read-only memory (ROM), a programmable ROM (PROM), an erasable PROM (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), which is used as an external cache. By way of example and not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic random access memory (DRAM), synchronous DRAM (SDRAM), double data rate synchronous dynamic random access memory (DDR SDRAM), enhanced synchronous dynamic random access memory (ESDRAM), synchronous link dynamic random access memory (SLDRAM), and direct rambus RAM (DR RAM).

[0130] Among them, the electronic device 500 may include smart phones (such as Android phones, iOS phones, Windows Phone phones, etc.), tablet computers, PDAs, driving recorders, vehicle-mounted electronic devices, servers, laptops, mobile Internet electronic devices (MID, Mobile Internet Devices) or wearable electronic devices (such as smart watches, Bluetooth headsets), etc. The above are only examples and not exhaustive, including but not limited to the above electronic devices.

[0131] It is understandable that the electronic device may include more or fewer structural elements than those in the above structural block diagram, for example, including a power module, physical buttons, a Wi-Fi module, a speaker, a Bluetooth module, a sensor, a display module, etc., which are not limited here.

[0132] The above mainly introduces the scheme of the embodiment of the present application from the perspective of the execution process on the method side. In order to realize the above functions, the electronic device includes a hardware structure and / or software module corresponding to the execution of each function. It should be easily appreciated by those skilled in the art that, in combination with the units and algorithm steps of each example described in the embodiments provided herein, the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a function is executed in the form of hardware or computer software driving hardware depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present application.

[0133] The embodiment of the present application can divide the electronic device into functional units according to the above method example. For example, each functional unit can be divided according to each function, or two or more functions can be integrated into one processing unit. The above integrated unit can be implemented in the form of hardware or in the form of software functional units. It should be noted that the division of units in the embodiment of the present application is schematic and is only a logical function division. There may be other division methods in actual implementation.

[0134] In the case of dividing each functional module into corresponding functional modules, Figure 6 A functional module composition block diagram of a parallel control device based on alliance chain transaction conflicts provided in an embodiment of the present application, wherein the parallel control device based on alliance chain transaction conflicts 600 includes:

[0135] The acquisition module 610 is used to acquire t transactions of a target consensus node on a target alliance chain, where the target alliance chain includes f consensus nodes, and t and f are both integers greater than 1; the target consensus node is any consensus node among the f consensus nodes;

[0136] The determination module 620 is configured to package the t transactions through a consensus algorithm to obtain a first block, and broadcast the first block to f-1 consensus nodes among the f consensus nodes except the target consensus node; perform static analysis on the first block to obtain a static analysis result; calculate the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate;

[0137] A judgment module 630 is used to execute the t transactions in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result when the transaction conflict rate is greater than a preset threshold;

[0138] The control module 640 is configured to fill the first block with the first execution result based on the consensus algorithm to obtain a target first block, and broadcast the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, the transaction is executed in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result;

[0139] The acquisition module 610 is further used to collect the second execution results corresponding to the f-1 consensus nodes, obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package;

[0140] The judgment module 630 is further configured to detect whether the first execution result message packet meets a first preset condition through the consensus algorithm;

[0141] The control module 640 is also used to submit the target first block to the target alliance chain when the first execution result message packet meets the first preset condition; and discard the target first block when the first execution result message packet does not meet the first preset condition.

[0142] In a possible embodiment, the determination module 620, in calculating the conflict rate of the transaction based on the static analysis result to obtain the transaction conflict rate, is specifically configured to:

[0143] Determine the number p of transactions that cannot be run in parallel among the t transactions according to the static analysis result; p is an integer greater than 1 and less than or equal to t;

[0144] The transaction conflict rate is determined according to the t transactions and the number p of non-parallel transactions.

[0145] In a possible embodiment, the judgment module 630 executes the t transactions in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result, specifically for:

[0146] Obtain the number of machine logical cores M of the target consensus node, where M is an integer greater than 1; the number of machine logical cores M indicates that the target consensus node can process M tasks in parallel at the same time;

[0147] Sequentially select transactions 1 to M in the first block to obtain a first group of M transactions;

[0148] The first group of M transactions are executed in parallel on the target consensus node using the consistency concurrency control algorithm to obtain the first execution result.

[0149] In a possible embodiment, the control module 640 executes the first group of M transactions in parallel on the target consensus node through the consistency concurrency control algorithm to obtain the first execution result, specifically for:

[0150] Determine the read-write key-value pairs of the first group of M transactions, and lock the read-write keys to obtain M transaction locks;

[0151] Determine a state of a target transaction lock, where the state of the target transaction lock includes a read lock and / or a write lock, and the target transaction lock is any one of the M transaction locks;

[0152] Determining whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock;

[0153] When there is a mutual exclusion phenomenon in the target transaction lock, the first group of M transactions are executed in parallel on the conflicting transactions corresponding to the target transaction lock on the target consensus node through the consistency concurrency control algorithm to obtain the first execution result.

[0154] In a possible embodiment, the determination module 630, in determining whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock, is further configured to:

[0155] Determine a target transaction corresponding to the target transaction lock;

[0156] The target transaction and the first transaction are locked to obtain a locked target transaction and a locked first transaction; the first transaction is a transaction corresponding to any one of the M transaction locks;

[0157] Performing a mutual exclusion analysis on the target transaction in the locked state and the first transaction in the locked state to obtain a mutual exclusion analysis result;

[0158] When the mutual exclusion analysis result meets a preset requirement, it is determined that the mutual exclusion phenomenon exists between the target transaction lock and the first transaction; the preset requirement is that there is at least one of the following conflicts between the target transaction lock and the first transaction: read-before-write conflict, write-before-read conflict, and write-write conflict.

[0159] In a possible embodiment, the control module 640 executes the first group of M transactions in parallel on the conflicting transactions corresponding to the target transaction lock through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result, and is specifically used to:

[0160] Obtaining a first transaction index corresponding to the first transaction, where the first transaction index represents a serial number corresponding to the first transaction in the sequential numbers of the M transactions in the first block;

[0161] Determine the lock-holding transaction corresponding to the target transaction, wherein the lock-holding transaction includes a transaction holding a write lock and a transaction holding a read lock; the transaction holding a write lock corresponds to the transaction index holding a write lock, and the transaction holding a read lock corresponds to the transaction index holding a read lock;

[0162] If the conflict between the target transaction lock and the first transaction is the write-write conflict, comparing the Index of the transaction holding the write lock with the Index of the first transaction;

[0163] When the Index of the transaction holding the write lock is greater than the Index of the first transaction, rolling back the transaction holding the write lock;

[0164] When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result;

[0165] If the conflict between the target transaction lock and the first transaction is a write-before-read conflict, compare the Index of the transaction holding the write lock with the Index of the first transaction;

[0166] When the Index of the transaction holding the write lock is greater than the Index of the first transaction, the transaction holding the write lock and the transaction holding the write lock and having an Index greater than the first transaction are rolled back;

[0167] When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result;

[0168] If the conflict between the target transaction lock and the first transaction is a read-before-write conflict, compare the Index of the transaction holding the read lock with the Index of the first transaction;

[0169] When the Index of the transaction holding the read lock is greater than the Index of the first transaction, rolling back the transaction holding the read lock;

[0170] When the Index of the transaction holding the read lock is less than or equal to the Index of the first transaction, the transaction holding the read lock is waited for to be completed, and the first group of M transactions are executed in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result.

[0171] In a possible embodiment, the control module 640 corresponds to one transaction access information for each of the t transactions, and the method is further used to:

[0172] When the transaction conflict rate is less than or equal to the preset threshold, obtaining first transaction access information, where the first transaction access information is transaction access information of any transaction among the t transactions;

[0173] Determine a corresponding transaction access key-value pair based on the first access information to obtain a first transaction key-value pair;

[0174] determining whether the first transaction can be processed in parallel according to the first transaction key-value pair and the first transaction access information;

[0175] When the first transaction can be processed in parallel, obtaining conflict domain information of the t transactions;

[0176] Determine, according to the conflict domain information, conflict information corresponding to the first transaction access information;

[0177] Determine a first directed acyclic graph of transaction execution based on the t transactions;

[0178] Constructing a dependency edge in the first directed acyclic graph according to the conflict information to obtain a second directed acyclic graph;

[0179] Executing the t transactions based on the second directed acyclic graph to obtain a third execution result;

[0180] Filling the first block with the third execution result based on the consensus algorithm to obtain a target second block, and broadcasting the target second block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target second block, executing the t transactions in parallel on the consensus node through the second directed acyclic graph to obtain a fourth execution result;

[0181] Collect the fourth execution results corresponding to the f-1 consensus nodes to obtain f-1 fourth execution results, and package the f-1 fourth execution results to obtain a second execution result message package;

[0182] Detecting, by the consensus algorithm, whether the second execution result message packet meets a second preset condition;

[0183] When the second execution result message packet meets the second preset condition, the target second block is submitted to the target alliance chain; when the second execution result message packet does not meet the second preset condition, the target second block is discarded.

[0184] In a possible embodiment, when the first execution result message packet satisfies the first preset condition, the determining module 620 is further configured to:

[0185] Obtaining the transaction root, receipt root and status root in the first execution result message;

[0186] Determining whether the first execution result and the f-1 second execution results satisfy a third preset condition;

[0187] When the first execution result and the f-1 second execution results satisfy the third preset condition, filling the transaction root, the receipt root, and the status root into the first block through the consensus algorithm to obtain the filled first block;

[0188] The state root in the filled first block is updated to obtain the target first block.

[0189] It is worth pointing out that the specific functional implementation of the parallel control device 600 based on alliance chain transaction conflicts can be found in the above Figure 1The description of the parallel control method based on alliance chain transaction conflicts shown in the figure, for example, the acquisition module 610 is used to implement the relevant content of executing S110 and S170, and the control module 640 is used to implement the relevant content of executing S160. Each unit or module in the parallel control device 600 based on alliance chain transaction conflicts can be separately or completely merged into one or several other units or modules to constitute, or one (some) of the units or modules can be further divided into multiple smaller units or modules in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units or modules are divided based on logical functions. In practical applications, the functions of one unit (or module) are implemented by multiple units (or modules), or the functions of multiple units (or modules) are implemented by one unit (or module).

[0190] It can be seen that the parallel control device based on alliance chain transaction conflicts described in the embodiment of the present application first obtains t transactions of the target consensus node on the target alliance chain, where the target alliance chain includes f consensus nodes, and t and f are both integers greater than 1; then, the t transactions are packaged through a consensus algorithm to obtain a first block, and the first block is broadcast to f-1 consensus nodes among the f consensus nodes except the target consensus node; static analysis is performed on the first block to obtain a static analysis result; based on the static analysis result, a conflict rate is calculated for the transaction to obtain a transaction conflict rate; when the transaction conflict rate is greater than a preset threshold, the t transactions are executed in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result; based on the consensus algorithm, the first execution result is used to fill the first block with the first execution result; A block, obtains the target first block, and broadcasts the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, the transaction is executed in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result; the second execution results corresponding to the f-1 consensus nodes are collected to obtain f-1 second execution results, and the f-1 second execution results are packaged to obtain a first execution result message packet; the first execution result message packet is detected by the consensus algorithm to see whether it meets the first preset condition; when the first execution result message packet meets the first preset condition, the target first block is submitted to the target alliance chain; when the first execution result message packet does not meet the first preset condition, the target first block is discarded. In the scenario where transactions conflict with the same resource, the performance of the concurrency control algorithm is improved.

[0191] It should be noted that the specific implementation of each operation can adopt the corresponding description of the method embodiment shown above. The parallel control device 600 based on alliance chain transaction conflicts can be used to execute the above method embodiment of the present application, which will not be repeated here.

[0192] An embodiment of the present application also provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program for electronic data exchange, wherein the computer program enables a computer to execute part or all of the steps of any method recorded in the above method embodiments, and the above computer includes an electronic device.

[0193] The embodiment of the present application also provides a computer program product, the computer program product includes a non-transitory computer-readable storage medium storing a computer program, the computer program is operable to cause a computer to execute some or all of the steps of any method described in the method embodiment. The computer program product may be a software installation package, and the computer includes an electronic device.

[0194] It should be noted that, for the above-mentioned various embodiments, for the sake of simple description, they are all expressed as a series of action combinations. Those skilled in the art should be aware that the present application is not limited by the described order of actions, because some steps in the embodiments of the present application can be performed in other orders or simultaneously. In addition, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions, steps, modules or units involved are not necessarily required by the embodiments of the present application.

[0195] In the above embodiments, the embodiments of the present application have different focuses on the description of each embodiment. For parts that are not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.

[0196] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0197] The steps of the method or algorithm described in the embodiments of the present application can be implemented in hardware or by executing software instructions by a processor. The software instructions can be composed of corresponding software modules, and the software modules can be stored in RAM, flash memory, ROM, EPROM, electrically erasable programmable read-only memory (electrically EPROM, EEPROM), registers, hard disks, mobile hard disks, read-only compact disks (CD-ROMs) or any other form of storage medium known in the art. An exemplary storage medium is coupled to the processor so that the processor can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be a component of the processor. The processor and the storage medium can be located in an ASIC. In addition, the ASIC can be located in a terminal device or a management device. Of course, the processor and the storage medium can also be present in a terminal device or a management device as discrete components.

[0198] Those skilled in the art should be aware that in one or more of the above examples, the functions described in the embodiments of the present application can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiments of the present application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server, or data center to another website site, computer, server, or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (digital subscriber line, DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrations. The available medium may be a magnetic medium (eg, a floppy disk, a hard disk, a magnetic tape), an optical medium (eg, a digital video disc (DVD)), or a semiconductor medium (eg, a solid state disk (SSD)).

[0199] The modules / units included in the devices and products described in the above embodiments may be software modules / units or hardware modules / units, or may be partially software modules / units and partially hardware modules / units. For example, for the devices and products applied to or integrated in the chip, the modules / units included therein may all be implemented in the form of hardware such as circuits, or at least some of the modules / units may be implemented in the form of software programs, which run on the processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits; for the devices and products applied to or integrated in the chip module, the modules / units included therein may all be implemented in the form of hardware such as circuits, and different modules / units may be located in the same component (such as a chip, circuit module, etc.) or in different components of the chip module, or at least some of the modules / units may be implemented in the form of software programs. The software programs run on the processor integrated inside the chip, and the remaining (if any) modules / units may be implemented in the form of hardware such as circuits. It is implemented in the form of a software program, which runs on a processor integrated inside the chip module, and the remaining (if any) modules / units can be implemented in hardware such as circuits; for various devices and products applied to or integrated in the terminal equipment, the various modules / units contained therein can be implemented in hardware such as circuits, and different modules / units can be located in the same component (for example, chip, circuit module, etc.) or in different components in the terminal equipment, or, at least some modules / units can be implemented in the form of a software program, which runs on a processor integrated inside the terminal equipment, and the remaining (if any) modules / units can be implemented in hardware such as circuits.

[0200] The specific implementation methods described above further illustrate the purpose, technical solutions and beneficial effects of the embodiments of the present application. It should be understood that the above description is only the specific implementation method of the embodiments of the present application and is not intended to limit the protection scope of the embodiments of the present application. Any modifications, equivalent substitutions, improvements, etc. made on the basis of the technical solutions of the embodiments of the present application should be included in the protection scope of the embodiments of the present application.

Claims

1. A parallel control method based on alliance chain transaction conflicts, characterized in that: The method comprises: Obtain t transactions of a target consensus node on a target alliance chain, where the target alliance chain includes f consensus nodes, t and f are both integers greater than 1; the target consensus node is any consensus node among the f consensus nodes; The t transactions are packaged by a consensus algorithm to obtain a first block, and the first block is broadcast to f-1 consensus nodes among the f consensus nodes except the target consensus node; Performing static analysis on the first block to obtain a static analysis result; Calculating the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate; When the transaction conflict rate is greater than a preset threshold, the t transactions are executed in parallel on the target consensus node by using a consistency concurrency control algorithm to obtain a first execution result; Filling the first block with the first execution result based on the consensus algorithm to obtain a target first block, and broadcasting the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, executing the transaction in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result; Collect the second execution results corresponding to the f-1 consensus nodes to obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package; Detecting whether the first execution result message packet meets a first preset condition by using the consensus algorithm; When the first execution result message packet meets the first preset condition, the target first block is submitted to the target alliance chain; when the first execution result message packet does not meet the first preset condition, the target first block is discarded.

2. The method according to claim 1, characterized in that The calculating the conflict rate of the transaction based on the static analysis result to obtain the transaction conflict rate includes: Determine the number p of transactions that cannot be run in parallel among the t transactions according to the static analysis result; p is an integer greater than 1 and less than or equal to t; The transaction conflict rate is determined according to the t transactions and the number p of non-parallel transactions.

3. The method according to claim 1 or 2, characterized in that The t transactions are executed in parallel on the target consensus node by using a consistency concurrency control algorithm to obtain a first execution result, including: Obtain the number of machine logical cores M of the target consensus node, where M is an integer greater than 1; the number of machine logical cores M indicates that the target consensus node can process M tasks in parallel at the same time; Sequentially select transactions 1 to M in the first block to obtain a first group of M transactions; The first group of M transactions are executed in parallel on the target consensus node using the consistency concurrency control algorithm to obtain the first execution result.

4. The method according to claim 3, characterized in that The executing the first group of M transactions in parallel on the target consensus node by using the consistency concurrency control algorithm to obtain the first execution result includes: Determine the read-write key-value pairs of the first group of M transactions, and lock the read-write keys to obtain M transaction locks; Determine a state of a target transaction lock, where the state of the target transaction lock includes a read lock and / or a write lock, and the target transaction lock is any one of the M transaction locks; Determining whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock; When there is a mutual exclusion phenomenon in the target transaction lock, the first group of M transactions are executed in parallel on the conflicting transactions corresponding to the target transaction lock on the target consensus node through the consistency concurrency control algorithm to obtain the first execution result.

5. The method according to claim 4, characterized in that The step of judging whether the target transaction lock has a mutual exclusion phenomenon according to the state of the target transaction lock includes: Determine a target transaction corresponding to the target transaction lock; The target transaction and the first transaction are locked to obtain a locked target transaction and a locked first transaction; the first transaction is a transaction corresponding to any one of the M transaction locks; Performing a mutual exclusion analysis on the target transaction in the locked state and the first transaction in the locked state to obtain a mutual exclusion analysis result; When the mutual exclusion analysis result meets a preset requirement, it is determined that the mutual exclusion phenomenon exists between the target transaction lock and the first transaction; the preset requirement is that there is at least one of the following conflicts between the target transaction lock and the first transaction: read-before-write conflict, write-before-read conflict, and write-write conflict.

6. The method according to claim 5, characterized in that The step of executing the first group of M transactions in parallel on the conflicting transactions corresponding to the target transaction lock by using the consistency concurrency control algorithm on the target consensus node to obtain the first execution result includes: Obtaining a first transaction index corresponding to the first transaction, where the first transaction index represents a serial number corresponding to the first transaction in the sequential numbers of the M transactions in the first block; Determine the lock-holding transaction corresponding to the target transaction, wherein the lock-holding transaction includes a transaction holding a write lock and a transaction holding a read lock; the transaction holding a write lock corresponds to the transaction index holding a write lock, and the transaction holding a read lock corresponds to the transaction index holding a read lock; If the conflict between the target transaction lock and the first transaction is the write-write conflict, comparing the Index of the transaction holding the write lock with the Index of the first transaction; When the Index of the transaction holding the write lock is greater than the Index of the first transaction, rolling back the transaction holding the write lock; When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result; If the conflict between the target transaction lock and the first transaction is a write-before-read conflict, compare the Index of the transaction holding the write lock with the Index of the first transaction; When the Index of the transaction holding the write lock is greater than the Index of the first transaction, the transaction holding the write lock and the transaction holding the write lock and having an Index greater than the first transaction are rolled back; When the Index of the transaction holding the write lock is less than or equal to the Index of the first transaction, wait for the transaction holding the write lock to be completed, and execute the first group of M transactions in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result; If the conflict between the target transaction lock and the first transaction is a read-before-write conflict, compare the Index of the transaction holding the read lock with the Index of the first transaction; When the Index of the transaction holding the read lock is greater than the Index of the first transaction, rolling back the transaction holding the read lock; When the Index of the transaction holding the read lock is less than or equal to the Index of the first transaction, the transaction holding the read lock is waited for to be completed, and the first group of M transactions are executed in parallel on the first transaction through the consistency concurrency control algorithm on the target consensus node to obtain the first execution result.

7. The method according to claim 1 or 2, characterized in that: Each of the t transactions corresponds to a piece of transaction access information, and the method further includes: When the transaction conflict rate is less than or equal to the preset threshold, obtaining first transaction access information, where the first transaction access information is transaction access information of any transaction among the t transactions; Determine a corresponding transaction access key-value pair based on the first access information to obtain a first transaction key-value pair; determining whether the first transaction can be processed in parallel according to the first transaction key-value pair and the first transaction access information; When the first transaction can be processed in parallel, obtaining conflict domain information of the t transactions; Determine, according to the conflict domain information, conflict information corresponding to the first transaction access information; Determine a first directed acyclic graph of transaction execution based on the t transactions; Constructing a dependency edge in the first directed acyclic graph according to the conflict information to obtain a second directed acyclic graph; Executing the t transactions based on the second directed acyclic graph to obtain a third execution result; Filling the first block with the third execution result based on the consensus algorithm to obtain a target second block, and broadcasting the target second block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target second block, executing the t transactions in parallel on the consensus node through the second directed acyclic graph to obtain a fourth execution result; Collect the fourth execution results corresponding to the f-1 consensus nodes to obtain f-1 fourth execution results, and package the f-1 fourth execution results to obtain a second execution result message package; Detecting, by the consensus algorithm, whether the second execution result message packet meets a second preset condition; When the second execution result message packet meets the second preset condition, the target second block is submitted to the target alliance chain; when the second execution result message packet does not meet the second preset condition, the target second block is discarded.

8. The method according to claim 1 or 2, characterized in that: When the first execution result message packet meets the first preset condition, the method further includes: Obtaining the transaction root, receipt root and status root in the first execution result message; Determining whether the first execution result and the f-1 second execution results satisfy a third preset condition; When the first execution result and the f-1 second execution results satisfy the third preset condition, filling the transaction root, the receipt root, and the status root into the first block through the consensus algorithm to obtain the filled first block; The state root in the filled first block is updated to obtain the target first block.

9. A parallel control device based on alliance chain transaction conflicts, characterized in that: The device includes an acquisition module, a determination module, a judgment module and a control module, wherein: The acquisition module is used to acquire t transactions of a target consensus node on a target alliance chain, where the target alliance chain includes f consensus nodes, and t and f are both integers greater than 1; the target consensus node is any consensus node among the f consensus nodes; The determination module is used to package the t transactions through a consensus algorithm to obtain a first block, and broadcast the first block to f-1 consensus nodes among the f consensus nodes except the target consensus node; perform static analysis on the first block to obtain a static analysis result; and calculate the conflict rate of the transaction based on the static analysis result to obtain a transaction conflict rate; The judgment module is used to execute the t transactions in parallel on the target consensus node through a consistency concurrency control algorithm to obtain a first execution result when the transaction conflict rate is greater than a preset threshold; The control module is configured to fill the first block with the first execution result based on the consensus algorithm to obtain a target first block, and broadcast the target first block to the f-1 consensus nodes; after any consensus node among the f-1 consensus nodes receives the target first block, the transaction is executed in parallel on the consensus node through the consistency concurrency control algorithm to obtain a second execution result; The acquisition module is further used to collect the second execution results corresponding to the f-1 consensus nodes, obtain f-1 second execution results, and package the f-1 second execution results to obtain a first execution result message package; The judgment module is further configured to detect whether the first execution result message packet meets a first preset condition through the consensus algorithm; The control module is further used to submit the target first block to the target alliance chain when the first execution result message packet meets the first preset condition; and discard the target first block when the first execution result message packet does not meet the first preset condition.

10. An electronic device, characterized in that: include: A processor, a memory, a communication interface, and one or more programs; The one or more programs are stored in the memory and configured to be executed by the processor, the programs comprising instructions for executing the steps in the method according to any one of claims 1 to 8.

Citation Information

Patent Citations

  • Service provision to IoT devices

    CN110024330A

  • Intelligent contract implementation method based on dynamic decision

    CN110276689A

  • Method and device for executing transaction in block chain

    CN111047449A

  • Alliance chain transaction concurrency scheme implementation method based on ring topology, dependency graph and multi-version control

    CN111724258A

  • Block verification method and device, and equipment

    CN111767337A