Block chain transaction optimistic parallel execution method and system based on static analysis conflict detection
Contract functions are executed symbolically through static analysis tools, conflict matching rules are generated and independent sets are constructed, which solves the problem of low blockchain transaction execution efficiency and achieves more efficient parallel transaction execution.
Patent Information
- Application Number
- CN202510659161.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-08-12
AI Technical Summary
Existing blockchain transaction execution methods are inefficient in transaction execution due to contract type limitations, pre-execution performance impact, frequent update of dependency graphs and inability to adapt to complex read and write operations.
Through static analysis tools, symbolically execute the callable functions under the contract, generate conflict matching rules, build transaction conflict charts and obtain independent sets, execute transactions in batches and parallel, and use an optimistic parallel scheduling mechanism to process independent sets.
Obtain read and write conflict judgment rules in advance before contract deployment, reduce conflicts in parallel transaction execution, improve transaction execution efficiency, and apply to all blockchain systems that support smart contracts.
Smart Images

Figure CN120469822A_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present invention relate to the field of blockchain technology, and more particularly to a method and system for optimistic parallel execution of blockchain transactions based on static analysis conflict detection. Background Art
[0002] Optimistic parallel scheduling is a scheduling strategy designed to improve system processing efficiency and resource utilization, particularly in high-concurrency environments within blockchain systems. The basic idea is to process multiple transactions in parallel, assuming that most transactions will not conflict, and only roll back and retry when a conflict is detected. This mechanism can significantly improve system throughput and responsiveness.
[0003] With the development of blockchain technology, transaction execution efficiency has become a key factor affecting blockchain performance. Currently, blockchain transaction execution mainly involves serial execution and parallel execution. While serial execution is simple, it is inefficient and cannot meet the needs of large-scale transaction processing. Therefore, research on parallel execution methods to improve transaction processing efficiency has become an important direction.
[0004] Several parallel execution methods have been proposed in the prior art. For example, one approach is a transaction parallel execution method based on static analysis. After the leader node packages and distributes a batch of transactions, the validator node uses static analysis to obtain the transaction read-write sets and determine the read-write dependencies between transactions. This method then constructs a scheduling graph, topologically sorting the transactions based on the scheduling graph and executing them in parallel. However, this method only works for contracts whose actual read-write sets directly use input variables, and is not applicable to contracts whose read-write set addresses cannot be directly obtained from input variables.
[0005] Another existing technology is a blockchain transaction execution method based on conflict detection. This method marks the conflict type of smart contract methods as static, dynamic, or full, depending on the specific circumstances of each smart contract. It then performs conflict detection and generates a transaction conflict graph, scheduling transactions based on the graph. However, when this method cannot obtain the correspondence between direct conflicting items and function input parameters, it requires pre-execution to obtain the transaction read-write set of the dynamic conflict type contract method. Furthermore, it serializes all transactions corresponding to the full conflict type contract method, failing to consider the possibility that some transactions may be parallelizable.
[0006] Another approach involves pre-executing transactions after receiving them. Based on the pre-execution results, a transaction dependency graph is constructed and all transactions with an out-degree of 0 are selected for parallel execution. During the parallel execution process, the transaction dependency graph is updated based on the actual execution results, and conflicts in the parallel execution process are resolved through rollbacks. However, when receiving a large number of transactions, this pre-execution method may affect the performance of other blockchain processes. Furthermore, during the actual parallel execution process, the transaction dependency graph may need to be frequently updated, reducing transaction execution efficiency.
[0007] Alternatively, some techniques send transactions to task queues across multiple threads, processing them in parallel and caching the results of each version in a multi-version data structure. These techniques also perform conflict verification on the transaction tasks. However, excessive read-write conflicts between transactions can lead to numerous rollbacks and redos during parallel execution, reducing transaction efficiency.
[0008] Another method is to group transactions into X groups based on their from and to addresses. All transactions involving the same address are grouped together, and each group is executed concurrently. Transactions within the group are executed serially, and conflicts are checked between groups. Any conflicting transactions are regrouped and executed again. However, this method only works for contracts that specify from and to addresses in transactions and is not suitable for contracts with more complex read and write operations. Summary of the Invention
[0009] To this end, embodiments of the present invention provide a method and system for optimistic parallel execution of blockchain transactions based on static analysis conflict detection to address the technical problems of low transaction execution efficiency in the prior art due to contract type restrictions, pre-execution performance impact, frequent updates of dependency graphs, large-scale transaction rollbacks, and inability to adapt to complex read and write operation contracts.
[0010] In order to achieve the above objectives, the embodiments of the present invention provide the following technical solutions:
[0011] According to a first aspect of an embodiment of the present invention, a method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection is provided, the method comprising:
[0012] Use static analysis tools to perform symbolic execution on the callable functions under the contract and generate corresponding conflict matching rules;
[0013] All transactions are grouped according to the contract, and conflict rules are matched between different transactions. An undirected edge is established between two transactions that meet the rules, indicating that there is a read-write conflict in the transaction;
[0014] Construct a transaction conflict graph based on the undirected edges between all transactions, obtain independent sets for the transactions in the transaction conflict graph, and remove the corresponding transactions from the conflict graph;
[0015] Repeatedly obtain independent sets until all transactions in the transaction conflict graph are removed, and finally divide the transactions into multiple different independent sets;
[0016] Each independent set is processed in a serial manner, and an optimistic parallel scheduling mechanism is adopted for transactions under a unified independent set.
[0017] Furthermore, static analysis tools are used to perform symbolic execution on the callable functions under the contract to generate corresponding conflict matching rules, including:
[0018] S1. Use symbolic execution to obtain all read and write operations on the chain by function A and function B, as well as the constraints in the path from the input to the read and write operations, to form a constraint set.
[0019] S2. Obtain the symbolic values of the addresses corresponding to all read and write operations of function A and function B, and obtain the read and write addresses according to the symbolic values;
[0020] S3. Constraint solving is performed on the read address under function A and the write address under function B, or the write address under function A and the read address under function B, to determine whether there is an input restriction condition that causes function A and function B to read and write to the same address during execution;
[0021] S4. If there is a read / write operation on the same address, the input restriction condition is used as the conflict matching rule for the transactions corresponding to function A and function B under the specific input. When the transaction input meets the conflict matching rule, it is determined that there is a read / write conflict between the two transactions.
[0022] S5. Repeat S1-S4 to match all functions under the contract to generate corresponding conflict matching rules. When the contract is deployed, the corresponding conflict matching rules are deployed on the chain as additional contract information.
[0023] Furthermore, adjacent transactions in the conflicting transaction graph are transactions that may have read-write conflicts;
[0024] For transactions that are not involved in any conflict matching rules, they are directly set as independent nodes in the conflict transaction graph.
[0025] Furthermore, symbolic execution is used to obtain all read and write operations on the chain by function A and function B, as well as the constraints existing in the path from the input to the read and write operations, to form a constraint set, which also includes:
[0026] All read and write operations on the chain can be performed when the function input meets the constraint set.
[0027] Furthermore, the symbolic values of the addresses corresponding to all read and write operations of function A and function B are obtained, and the read and write addresses are obtained according to the symbolic values, specifically including:
[0028] The symbolic value is a symbolic expression with the function input as the main symbolic variable.
[0029] Furthermore, static analysis tools are used to perform symbolic execution on the callable functions under the contract to generate corresponding conflict matching rules, including:
[0030] Generate conflict matching rules through static analysis tools before contract deployment.
[0031] Furthermore, the method further comprises:
[0032] When conflicts between transactions still exist during optimistic parallel execution, the conflicting transactions are rolled back and the successful transactions are applied with the execution results.
[0033] According to a second aspect of an embodiment of the present invention, a system for optimistic parallel execution of blockchain transactions based on static analysis conflict detection is provided, the system comprising:
[0034] The symbolic execution module is used to perform symbolic execution on the callable functions under the contract through static analysis tools and generate corresponding conflict matching rules;
[0035] The grouping module is used to group all transactions according to the contract, match and determine the conflict rules between different transactions, and establish an undirected edge between two transactions that meet the rules, indicating that there is a read-write conflict in the transaction;
[0036] A transaction conflict graph construction module is used to construct a transaction conflict graph based on the undirected edges established between all transactions, obtain independent sets for transactions in the transaction conflict graph, and remove corresponding transactions from the conflict graph;
[0037] An independent set repeated obtaining module is used to repeatedly obtain independent sets until all transactions in the transaction conflict graph are removed, and finally the transactions are divided into multiple different independent sets;
[0038] The independent set processing module is used to process each independent set in a serial manner and adopt an optimistic parallel scheduling mechanism for transactions under the same independent set.
[0039] The embodiments of the present invention have the following advantages:
[0040] The embodiment of the present invention obtains in advance the judgment rules for possible read-write conflicts between transactions by symbolically executing the contract before deploying the contract off-chain; obtains independent set batches for the constructed transaction conflict graph, divides the transactions into different independent sets, and performs parallel execution as fully as possible while reducing conflicts, thereby improving transaction execution efficiency; in the actual execution process, an optimistic parallel execution scheme is adopted to ensure that read-write conflicts between transactions can be correctly handled during the actual execution process.
[0041] In an embodiment of the present invention, a static symbolic execution tool is used to symbolically execute the callable functions under a smart contract. The symbolic values of the corresponding read and write addresses of the read and write operations triggered during the function execution are calculated, resulting in a symbolic expression with the function input parameters as the main symbolic variables. Transaction conflict rules are then derived by performing constraint solving on the symbolic expressions of the read and write addresses between functions. During the parallel execution of transactions, transactions are first matched pairwise according to the conflict rules. Transactions that successfully match the rules are considered potentially conflicting transactions. Based on the transaction conflict relationships derived above, conflicting transactions are divided into different sets for optimistic parallel execution, attempting to reduce read and write conflicts under actual optimistic parallel execution. This embodiment of the present invention is applicable to all blockchain systems that support smart contracts, reducing read and write conflicts and improving the execution efficiency of blockchain transactions. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] To more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for the embodiments or the description of the prior art. Obviously, the drawings described below are merely exemplary, and those skilled in the art can derive other implementation drawings based on the provided drawings without inventive effort.
[0043] The structures, proportions, sizes, etc. illustrated in this specification are intended only to complement the contents disclosed herein and to facilitate understanding and reading by persons familiar with the art. They are not intended to limit the conditions under which the present invention may be implemented and therefore have no substantive technical significance. Any structural modifications, changes in proportions, or adjustments in sizes, without affecting the efficacy and objectives of the present invention, shall still fall within the scope of the technical contents disclosed herein.
[0044] Figure 1 A schematic diagram of the logical structure of a blockchain transaction optimistic parallel execution system based on static analysis conflict detection provided by an embodiment of the present invention;
[0045] Figure 2 A flowchart of a method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection provided by an embodiment of the present invention;
[0046] Figure 3 A schematic diagram of the symbolic execution process of an optimistic parallel execution method for blockchain transactions based on static analysis conflict detection provided by an embodiment of the present invention;
[0047] Figure 4 A schematic diagram of the process of deploying smart contracts on-chain in an optimistic parallel execution method for blockchain transactions based on static analysis conflict detection provided by an embodiment of the present invention;
[0048] Figure 5 A schematic diagram of the transaction scheduling process in a method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0049] The following describes the implementation of the present invention using specific embodiments. Those skilled in the art will readily understand the other advantages and benefits of the present invention from the disclosure herein. Obviously, the embodiments described are only a portion of the present invention, not all of it. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are intended to fall within the scope of protection of the present invention.
[0050] An independent set refers to a group of vertices in an undirected or directed graph. There are no direct edges connecting these vertices, and any two vertices in the independent set are non-adjacent.
[0051] Symbolic expressions represent mathematical expressions constructed during symbolic execution using symbolic variables instead of concrete values. These expressions can represent variables, operands, and operators in a program without relying on specific inputs. Symbolic execution engines generate a logical description of the program state and use constraint solvers to evaluate the symbolic expressions, analyzing the program's behavior under different input conditions.
[0052] Smart Contract Transaction (Tx): A smart contract transaction (or transaction) is the unit of program execution on the blockchain. After executing the transaction according to the steps specified in the smart contract, the transaction generates a read-write set of the blockchain state.
[0053] Read-write sets are divided into read sets and write sets, both of which are in the form of "key-value pairs", i.e. (key=..., value=...). After the read-write set is generated, it is stored in the cache and is written to the blockchain state only after it is applied.
[0054] Read-write conflict: In the parallel scheduling mechanism, a read-write conflict refers to a group of transactions operating on the same data address, where one transaction writes data and the other reads the same data address. If the write operation is completed first, the read operation will be considered a conflict and must be re-executed. More specifically, two transactions Txi ,Tx j , if Tx i Read(key, value i ), Tx j Write(key, value j ), Tx in sequence j Before Tx i , then this is a read-write conflict, because Tx j Write first, then Tx i The read value is changed, so Tx i The read-write set cannot be applied, Tx i Need to be re-executed.
[0055] The Transaction Pool is a cache area in the blockchain system that stores pending transactions. All pending transactions are first stored in the transaction pool, waiting to be retrieved and executed by the scheduling mechanism.
[0056] In order to solve the above technical problems of low transaction execution efficiency caused by contract type restrictions, pre-execution performance impact, frequent updates of dependency graphs, large-scale transaction rollbacks, and inability to adapt to complex read and write operation contracts.
[0057] refer to Figure 1 The embodiment of the present invention discloses an optimistic parallel execution system for blockchain transactions based on static analysis conflict detection, the system comprising: a symbolic execution module 1; a grouping module 2; a transaction conflict graph construction module 3; an independent set repeated obtaining module 4; and an independent set processing module 5.
[0058] Corresponding to the aforementioned optimistic parallel execution system for blockchain transactions based on static analysis conflict detection, embodiments of the present invention also disclose a method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection. The following describes in detail the method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection disclosed in embodiments of the present invention, in conjunction with the aforementioned optimistic parallel execution system for blockchain transactions based on static analysis conflict detection.
[0059] refer to Figure 2 and Figure 5The present invention discloses an optimistic parallel execution method for blockchain transactions based on static analysis conflict detection, the method comprising: performing symbolic execution on callable functions under a contract by using a static analysis tool to generate corresponding conflict matching rules; grouping all transactions according to the contract, performing conflict rule matching judgment between different transactions, establishing an undirected edge between two transactions that meet the rule, indicating that there is a read-write conflict in the transaction; constructing a transaction conflict graph based on the undirected edges established between all transactions, obtaining independent sets for transactions in the transaction conflict graph and removing corresponding transactions from the conflict graph; repeatedly obtaining independent sets until all transactions in the transaction conflict graph are removed, and finally dividing the transactions into multiple different independent sets; processing each independent set in a serial manner, and adopting an optimistic parallel scheduling mechanism for transactions under a unified independent set.
[0060] For example, a batch of transactions are in the process of being scheduled. The execution process for a batch of transactions in the scheduling process is as follows:
[0061] 1. All transactions are grouped by contract. Since different contracts use independent address spaces, only transactions under the same contract can read and write to the same address.
[0062] 2. For transactions under the same contract group, conflict rules are matched between different transactions based on the contract methods they call and the actual inputs. An undirected edge is established between two transactions that meet the rules, indicating that there is a read-write conflict in the transactions.
[0063] 3. Construct a transaction conflict graph based on the edges established between all transactions. Adjacent transactions in the conflict graph are transactions that may have read-write conflicts. Transactions that are not involved in any conflict matching rules are directly treated as independent nodes in the conflict graph.
[0064] 4. Obtain independent sets for transactions in the conflict graph and remove the corresponding transactions from the conflict graph. Repeat the process until all transactions in the conflict graph are removed. Finally, the transactions are batched into multiple independent sets.
[0065] 5. Sequential processing is used for different independent sets, while optimistic parallel scheduling is used for transactions within the same independent set. If conflicts still occur during optimistic parallel execution, the conflicting transactions are rolled back and redone, and the successful transaction is used as the execution result.
[0066] It should be noted that before the contract is deployed, the callable functions under the contract are first symbolically executed using static analysis tools:
[0067] 1. First, symbolic execution is used to obtain all read and write operations on the chain of functions A and B, as well as the set of constraints existing in the path from the input to the read and write operations. The above read and write operations can be executed when the function input meets the constraint set.
[0068] 2. Obtain the symbolic values of the addresses corresponding to all read and write operations of function A and function B, where the symbolic values are symbolic expressions with the function inputs as the main symbolic variables.
[0069] 3. Based on the corresponding read and write addresses represented by symbolic expressions under Function A and Function B, constraints are solved for the read address under Function A and the write address under Function B, or the write address under Function A and the read address under Function B. This determines whether there are any input restrictions that cause Function A and Function B to read and write to the same address during execution. In this case, there is a high probability of a read / write conflict during the parallel execution of the corresponding transactions.
[0070] 4. The above input restrictions are used as the conflict matching rules for the transactions corresponding to function A and function B under specific inputs. When the transaction input of calling function A and the transaction input of calling function B meet the conflict matching rules, it is determined that the above two transactions have a read-write conflict.
[0071] 5. Generate conflict matching rules for all functions under the contract and repeat steps 1 to 4 above.
[0072] 6. When deploying the contract, the corresponding rules will be deployed on the chain as additional contract information.
[0073] Further, see Figure 3 and Figure 4 , symbolic execution is performed on the callable functions under the contract through static analysis tools to generate corresponding conflict matching rules, including: S1. Using symbolic execution to obtain all read and write operations of function A and function B on the chain and the constraints existing in the path from the input to the read and write operations, forming a constraint set; S2. Obtaining the symbolic values of the addresses corresponding to all read and write operations of function A and function B, and obtaining the read and write addresses based on the symbolic values; S3. Constraint solving is performed on the read address under function A and the write address under function B / the write address under function A and the read address under function B to determine whether there is an input constraint condition that causes function A and function B to read and write to the same address during execution; S4. If there is a read and write to the same address, the input constraint condition is used as the conflict matching rule for the corresponding transactions of function A and function B under specific input. When the transaction input satisfies the conflict matching rule, it is determined that there is a read and write conflict between the two transactions; S5. Repeat S1-S4 to match all functions under the contract to generate corresponding conflict matching rules. When the contract is deployed, the corresponding conflict matching rule is deployed on the chain as additional contract information.
[0074] Adjacent transactions in the conflicting transaction graph are transactions that may have read-write conflicts; transactions that are not involved in any conflict matching rules are directly set as independent nodes in the conflicting transaction graph.
[0075] Symbolic execution is used to obtain all read and write operations on the chain by function A and function B and the constraints existing in the path from the input to the read and write operations, forming a constraint set, which also includes: all read and write operations on the chain can be executed when the function input meets the constraint set.
[0076] Obtaining symbolic values of addresses corresponding to all read and write operations of function A and function B, and obtaining read and write addresses according to the symbolic values, specifically including: the symbolic value is a symbolic expression with function input as the main symbolic variable.
[0077] Use static analysis tools to perform symbolic execution on the callable functions under the contract and generate corresponding conflict matching rules. Specifically, it also includes: generating conflict matching rules through static analysis tools before contract deployment.
[0078] When conflicts between transactions still exist during optimistic parallel execution, the conflicting transactions are rolled back and the successful transactions are applied with the execution results.
[0079] Although the present invention has been described in detail above using general descriptions and specific embodiments, it will be apparent to those skilled in the art that modifications and improvements may be made thereto. Therefore, such modifications and improvements, without departing from the spirit of the present invention, are intended to be within the scope of protection claimed herein.
Claims
1. A method for optimistic parallel execution of blockchain transactions based on static analysis conflict detection, characterized in that: The method comprises: Use static analysis tools to perform symbolic execution on the callable functions under the contract and generate corresponding conflict matching rules; All transactions are grouped according to the contract, and conflict rules are matched between different transactions. An undirected edge is established between two transactions that meet the rules, indicating that there is a read-write conflict in the transaction; Construct a transaction conflict graph based on the undirected edges between all transactions, obtain independent sets for the transactions in the transaction conflict graph, and remove the corresponding transactions from the conflict graph; Repeatedly obtain independent sets until all transactions in the transaction conflict graph are removed, and finally divide the transactions into multiple different independent sets; Each independent set is processed in a serial manner, and an optimistic parallel scheduling mechanism is adopted for transactions under a unified independent set.
2. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 1, characterized in that: Use static analysis tools to perform symbolic execution on the callable functions under the contract and generate corresponding conflict matching rules, including: S1. Use symbolic execution to obtain all read and write operations on the chain by function A and function B, as well as the constraints in the path from the input to the read and write operations, to form a constraint set. S2. Obtain the symbolic values of the addresses corresponding to all read and write operations of function A and function B, and obtain the read and write addresses according to the symbolic values; S3. Constraint solving is performed on the read address under function A and the write address under function B, or the write address under function A and the read address under function B, to determine whether there is an input restriction condition that causes function A and function B to read and write to the same address during execution; S4. If there is a read / write operation on the same address, the input restriction condition is used as the conflict matching rule for the transactions corresponding to function A and function B under the specific input. When the transaction input meets the conflict matching rule, it is determined that there is a read / write conflict between the two transactions. S5. Repeat S1-S4 to match all functions under the contract to generate corresponding conflict matching rules. When the contract is deployed, the corresponding conflict matching rules are deployed on the chain as additional contract information.
3. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 2 is characterized in that: Adjacent transactions in the conflicting transaction graph are transactions that may have read-write conflicts; For transactions that are not involved in any conflict matching rules, they are directly set as independent nodes in the conflict transaction graph.
4. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 3 is characterized in that: Symbolic execution is used to obtain all read and write operations on the chain by function A and function B, as well as the constraints in the path from the input to the read and write operations, to form a constraint set, which also includes: All read and write operations on the chain can be performed when the function input meets the constraint set.
5. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 4 is characterized in that: Obtaining the symbolic values of the addresses corresponding to all read and write operations of function A and function B, and obtaining the read and write addresses according to the symbolic values, specifically including: The symbolic value is a symbolic expression with the function input as the main symbolic variable.
6. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 5, characterized in that: Use static analysis tools to perform symbolic execution on the callable functions under the contract and generate corresponding conflict matching rules, including: Generate conflict matching rules through static analysis tools before contract deployment.
7. The optimistic parallel execution method for blockchain transactions based on static analysis conflict detection according to claim 6, characterized in that: The method further comprises: When conflicts between transactions still exist during optimistic parallel execution, the conflicting transactions are rolled back and the successful transactions are applied with the execution results.
8. An optimistic parallel execution system for blockchain transactions based on static analysis conflict detection, characterized in that: The system comprises: The symbolic execution module is used to perform symbolic execution on the callable functions under the contract through static analysis tools and generate corresponding conflict matching rules; The grouping module is used to group all transactions according to the contract, match and determine the conflict rules between different transactions, and establish an undirected edge between two transactions that meet the rules, indicating that there is a read-write conflict in the transaction; A transaction conflict graph construction module is used to construct a transaction conflict graph based on the undirected edges established between all transactions, obtain independent sets for transactions in the transaction conflict graph, and remove corresponding transactions from the conflict graph; An independent set repeated obtaining module is used to repeatedly obtain independent sets until all transactions in the transaction conflict graph are removed, and finally the transactions are divided into multiple different independent sets; The independent set processing module is used to process each independent set in a serial manner and adopt an optimistic parallel scheduling mechanism for transactions under the same independent set.