CN112487096A - Block transaction execution method and device - Google Patents

Block transaction execution method and device Download PDF

Info

Publication number
CN112487096A
CN112487096A CN202011440624.7A CN202011440624A CN112487096A CN 112487096 A CN112487096 A CN 112487096A CN 202011440624 A CN202011440624 A CN 202011440624A CN 112487096 A CN112487096 A CN 112487096A
Authority
CN
China
Prior art keywords
transaction
conflict
transactions
determining
block
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202011440624.7A
Other languages
Chinese (zh)
Inventor
李陈希
李辉忠
张开翔
范瑞彬
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202011440624.7A priority Critical patent/CN112487096A/en
Publication of CN112487096A publication Critical patent/CN112487096A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange

Abstract

The embodiment of the invention provides a block transaction execution method and a block transaction execution device. Because the transactions without execution conflicts are summarized into the same non-conflict transaction set, the influence of the transaction sequence on the transaction parallelism can be avoided, and because any non-conflict transaction set is constructed according to the transaction with the highest latitude in the set, the width of a transaction dependency graph can be expanded, and all transactions in any non-conflict transaction set can be completely executed in parallel, so that the influence of the transaction sequence on the parallelism during the execution of the transactions can be reduced, the parallelism of the execution of the transactions can be improved, and the efficient execution of the transactions can be ensured.

Description

Block transaction execution method and device
Technical Field
The embodiment of the invention relates to the field of financial technology (Fintech), in particular to a block transaction execution method and device.
Background
With the development of computer technology, more and more technologies are applied in the financial field, and the traditional financial industry is gradually changing to financial technology, but due to the requirements of the financial industry on safety and real-time performance, higher requirements are also put forward on the technologies.
At this stage, in order to improve the transaction execution efficiency, the blockchain consensus node tries to execute the transactions in the transaction list in the block in a parallel manner. Before the transaction in the transaction list in the block is executed, the blockchain consensus node analyzes each transaction to analyze the common resources used by the transaction. If the common resources used by the two transactions conflict (namely at least one of the two needs to change the state of the common resources), the two transactions are executed in series according to a certain sequence, otherwise, the two transactions are executed in parallel. Specifically, the blockchain consensus node organizes all transactions into a directed acyclic graph, the nodes in the graph are the transactions, and when a conflict exists between the transactions, the blockchain consensus node establishes a directed edge for two transactions in the graph to represent that a dependency relationship exists between the two transactions, so that the constructed directed acyclic graph is called a transaction dependency graph. The transaction list is required to be traversed according to a certain sequence in the process of establishing the transaction dependency graph, and only the transaction ranked at the back in the traversal process depends on the transaction ranked at the front. However, since the manner of constructing the transaction dependency graph is sensitive to the order of the transactions in the transaction list, different transaction orders may cause different parallelism in the execution of the transactions, that is, if the transaction order is not proper, the parallelism in the execution of the transactions may be reduced, thereby resulting in inefficient execution of the transactions.
In summary, there is a need for a block transaction execution method to reduce the effect of transaction sequence on the parallelism of transaction execution and ensure efficient execution of transactions.
Disclosure of Invention
The embodiment of the invention provides a block transaction execution method and device, which are used for reducing the influence of transaction sequence on the parallelism degree during transaction execution and ensuring efficient execution of transaction.
In a first aspect, an embodiment of the present invention provides a method for performing a block transaction, including:
determining each non-conflict transaction set in sequence according to the transaction sequence of each transaction in the block; executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block;
determining the dependency relationship of adjacent non-conflict transaction sets according to the construction sequence of each non-conflict transaction set;
and executing in sequence according to the dependency relationship of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel.
In the technical scheme, each non-conflict transaction set is sequentially determined according to the transaction sequence of each transaction in the block, and the dependency relationship of adjacent non-conflict transaction sets is determined according to the construction sequence of each non-conflict transaction set. And executing according to the dependency relationship sequence of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel. Because the transactions without execution conflicts are summarized into the same non-conflict transaction set, the influence of the transaction sequence on the parallelism during the execution of the transactions can be avoided, and because any non-conflict transaction set is constructed according to the transaction with the highest tolerance in the set, the width of a transaction dependency graph can be expanded, and all transactions in any non-conflict transaction set can be completely executed in parallel, so that the influence of the transaction sequence on the parallelism during the execution of the transactions can be reduced, the parallelism during the execution of the transactions can be improved, and the efficient execution of the transactions can be ensured.
Optionally, the sequentially determining the non-conflicting transaction sets according to the transaction sequence of the transactions in the block includes:
sequentially storing the transactions into the rest transaction records according to the transaction sequence of the transactions in the block;
for a first transaction in the remaining transaction records, constructing a first initial set of the first transaction; the first initial set includes the first transaction; the first transaction is the first transaction in the remaining transaction records;
determining a first candidate set of the first transaction from the remaining transaction records; there is no execution conflict between any transaction in the first candidate set and the first transaction;
determining the transactions which can be added into the first initial set according to the tolerance of each transaction in the first candidate set, thereby constructing a non-conflict transaction set of the first transactions;
deleting each transaction in the non-conflict transaction set of the first transaction from the remaining transaction records, returning to execute the first transaction in the remaining transaction records, and constructing a first initial set of the first transaction until no transaction exists in the remaining transaction records.
In the technical scheme, the transactions are sequentially stored in the remaining transaction records according to the transaction sequence of the transactions in the block, and the first candidate set of the first transaction is determined from the remaining transaction records. And then, based on the tolerance of each transaction in the first candidate set, a non-conflict transaction set of the first transaction can be quickly and accurately constructed, so that the influence of the transaction sequence on the parallelism during transaction execution is small, and the full and efficient execution of the transaction is facilitated.
Optionally, the determining, according to the tolerance of each transaction in the first candidate set, the transactions that can be added to the first initial set, so as to construct a non-conflicting transaction set of the first transactions, includes:
determining that there is no second transaction in the first candidate set with a higher latitude than the first transaction;
adding a third transaction in the first candidate set to the first initial set; the latitude of the third transaction is the transaction with the highest latitude except the first transaction in the first candidate set;
and after the third transaction and the conflict transaction of the third transaction are deleted from the first candidate set, returning to the step of adding the third transaction in the first candidate set into the first initial set until no transaction exists in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction.
In the above technical solution, when it is determined that there is no second transaction with a higher latitude than the first transaction in the first candidate set, a third transaction with a highest latitude except the first transaction in the first candidate set is added to the first initial set, so as to construct a non-conflict transaction set of the first transaction. Therefore, the influence of the transaction sequence on the parallelism of the transaction execution is small, and the method is favorable for ensuring the sufficient and efficient execution of the transaction.
Optionally, the determining, according to the tolerance of each transaction in the first candidate set, the transactions that can be added to the first initial set, so as to construct a non-conflicting transaction set of the first transactions, includes:
determining that there is a second transaction in the first candidate set that is more tolerant than the first transaction;
and adjusting the first transaction to the tail part in the residual transaction records, and returning to the step of executing the first transaction in the residual transaction records and constructing a first initial set of the first transaction.
In the above technical solution, if it is determined that the second transaction with the higher tolerance than the first transaction exists in the first candidate set, the first transaction is adjusted to the tail of the remaining transaction records, so that the transaction located at the start position of the remaining transaction records can be ensured to be executed smoothly.
Optionally, the determining a first candidate set of the first transaction from the remaining transaction records includes:
finding out a first conflict transaction set of the first transaction according to a conflict transaction dictionary;
if it is determined that the mth transaction in the list of remaining transactions does not exist in the first set of conflicting transactions, storing the mth transaction in the first candidate set;
the latitude of each transaction in the first candidate set is determined according to a transaction latitude dictionary.
In the above technical solution, the first conflict transaction set with the first transaction is found out according to the conflict transaction dictionary, and the first candidate set of the first transaction can be accurately determined based on the first conflict transaction set, so as to provide support for subsequently determining the non-conflict transaction set of the first transaction.
Optionally, the transaction latitude dictionary and the conflict transaction dictionary are determined according to the following:
analyzing the public resource of the nth transaction and analyzing the public resource of the r transaction before the nth transaction when traversing the nth transaction in each transaction based on the transaction sequence of each transaction in the block;
if the fact that the public resource of the nth transaction conflicts with the public resource of the r transaction is determined, processing the tolerance of the nth transaction and processing the tolerance of the r transaction; storing the r transaction into a conflict transaction set of the n transaction, and storing the n transaction into the conflict transaction set of the r transaction; and determining the transaction latitude dictionary and determining the conflict transaction dictionary until all the transactions are traversed.
In the technical scheme, on the basis of the transaction sequence of each transaction in the block, when the nth transaction is traversed in each transaction, the public resource of the nth transaction is analyzed, and the public resource of the r-th transaction before the nth transaction is analyzed. And constructing a transaction tolerance dictionary and a conflict transaction dictionary based on judging whether the common resource of the nth transaction and the common resource of the r transaction conflict or not so as to provide support for subsequently determining a non-conflict transaction set of each transaction.
Optionally, determining the dependency relationship of adjacent non-conflicting transaction sets according to the construction order of each non-conflicting transaction set, including:
aiming at the jth transaction in the (i + 1) th non-conflict transaction set, finding out a third conflict transaction set which conflicts with the jth transaction from a conflict transaction dictionary;
if the kth transaction in the ith non-conflict transaction set is determined to exist in the third conflict transaction set, establishing a directed edge between the kth transaction and the jth transaction; the jth transaction is dependent on the kth transaction.
In the above technical solution, by determining that the kth transaction in the ith non-conflicting transaction set exists in the third conflicting transaction set, the directed edge between the kth transaction and the jth transaction can be accurately established, and support is provided for the sufficient and efficient execution of subsequent transactions.
In a second aspect, an embodiment of the present invention further provides an apparatus for performing a block transaction, including:
the determining unit is used for sequentially determining each non-conflict transaction set according to the transaction sequence of each transaction in the block; executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block;
the processing unit is used for determining the dependency relationship of adjacent non-conflict transaction sets according to the construction sequence of each non-conflict transaction set; and executing in sequence according to the dependency relationship of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel.
Optionally, the processing unit is specifically configured to:
sequentially storing the transactions into the rest transaction records according to the transaction sequence of the transactions in the block;
for a first transaction in the remaining transaction records, constructing a first initial set of the first transaction; the first initial set includes the first transaction; the first transaction is the first transaction in the remaining transaction records;
determining a first candidate set of the first transaction from the remaining transaction records; there is no execution conflict between any transaction in the first candidate set and the first transaction;
determining the transactions which can be added into the first initial set according to the tolerance of each transaction in the first candidate set, thereby constructing a non-conflict transaction set of the first transactions;
deleting each transaction in the non-conflict transaction set of the first transaction from the remaining transaction records, returning to execute the first transaction in the remaining transaction records, and constructing a first initial set of the first transaction until no transaction exists in the remaining transaction records.
Optionally, the processing unit is specifically configured to:
determining that there is no second transaction in the first candidate set with a higher latitude than the first transaction;
adding a third transaction in the first candidate set to the first initial set; the latitude of the third transaction is the transaction with the highest latitude except the first transaction in the first candidate set;
and after the third transaction and the conflict transaction of the third transaction are deleted from the first candidate set, returning to the step of adding the third transaction in the first candidate set into the first initial set until no transaction exists in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction.
Optionally, the processing unit is specifically configured to:
determining that there is a second transaction in the first candidate set that is more tolerant than the first transaction;
and adjusting the first transaction to the tail part in the residual transaction records, and returning to the step of executing the first transaction in the residual transaction records and constructing a first initial set of the first transaction.
Optionally, the processing unit is specifically configured to:
finding out a first conflict transaction set of the first transaction according to a conflict transaction dictionary;
if it is determined that the mth transaction in the list of remaining transactions does not exist in the first set of conflicting transactions, storing the mth transaction in the first candidate set;
the latitude of each transaction in the first candidate set is determined according to a transaction latitude dictionary.
Optionally, the processing unit is specifically configured to:
analyzing the public resource of the nth transaction and analyzing the public resource of the r transaction before the nth transaction when traversing the nth transaction in each transaction based on the transaction sequence of each transaction in the block;
if the fact that the public resource of the nth transaction conflicts with the public resource of the r transaction is determined, processing the tolerance of the nth transaction and processing the tolerance of the r transaction; storing the r transaction into a conflict transaction set of the n transaction, and storing the n transaction into the conflict transaction set of the r transaction; and determining the transaction latitude dictionary and determining the conflict transaction dictionary until all the transactions are traversed.
Optionally, the processing unit is specifically configured to:
aiming at the jth transaction in the (i + 1) th non-conflict transaction set, finding out a third conflict transaction set which conflicts with the jth transaction from a conflict transaction dictionary;
if the kth transaction in the ith non-conflict transaction set is determined to exist in the third conflict transaction set, establishing a directed edge between the kth transaction and the jth transaction; the jth transaction is dependent on the kth transaction.
In a third aspect, an embodiment of the present invention provides a computing device, including:
a memory for storing a computer program;
and the processor is used for calling the computer program stored in the memory and executing the execution method of the block transaction according to the obtained program.
In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer-executable program, where the computer-executable program is used to make a computer execute an execution method of a block transaction.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed to be used in the description of the embodiments will be briefly introduced below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on these drawings without creative efforts.
Fig. 1 is a schematic diagram of a block transaction execution system architecture according to an embodiment of the present invention;
fig. 2 is a flowchart illustrating a method for performing a block transaction according to an embodiment of the present invention;
FIG. 3 is a schematic diagram of an optimal transaction dependency graph constructed by a prior art scheme according to an embodiment of the present invention;
FIG. 4 is a schematic diagram of a non-optimal transaction dependency graph constructed based on the set { E → A, C → D }, according to an embodiment of the present invention;
FIG. 5 is a flowchart illustrating a process of constructing a transaction latitude dictionary and a conflict transaction dictionary according to an embodiment of the present invention;
FIG. 6 is a flow chart illustrating a process of partitioning a non-conflicting transaction set according to an embodiment of the present invention;
FIG. 7 is a schematic flow chart illustrating the establishment of a directed edge with transaction dependency according to an embodiment of the present invention;
FIG. 8 is a schematic diagram of an optimal transaction dependency graph constructed using the solution of the embodiment of the present invention according to the embodiment of the present invention;
fig. 9 is a schematic structural diagram of an apparatus for performing a block transaction according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention clearer, the present invention will be described in further detail with reference to the accompanying drawings, and it is apparent that the described embodiments are only a part of the embodiments of the present invention, not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
In the following, some terms related to the embodiments of the present invention are first explained to facilitate understanding by those skilled in the art.
(1) Block chains: is a distributed storage system commonly maintained and trusted by multiple nodes. The blockchain bottom is a chain of blocks, which consist of a series of blocks, a blockhead containing metadata, followed by a long list of transactions that constitute the body of the block. In addition to recording the data of the block, the hash value of the block is recorded on each block, and in this way, a chained data structure is formed.
(2) Trading: in blockchains, any operation (deploying a contract, invoking a contract interface, etc.) is done by sending a transaction. The transaction is initiated by the user and sent to the blockchain node through the client. After receiving the transaction, the blockchain node packs the transaction into blocks and executes the blocks.
(3) And (3) consensus nodes: the node which can participate in the common identification block has the following main functions: packaging the transaction in the transaction pool into blocks, executing the transaction, running a consensus algorithm, and writing the blocks which achieve consensus into an account book.
(4) Directed acyclic graph: a graph is composed of vertices and edges connecting the vertices. A graph with each edge having a direction pointing from one vertex to another is a directed graph. The path in the directed graph is a series of edges, the end point of each edge in the series being the start point of the next edge. If the start of a path is the end of the path, then the path is a loop. A directed acyclic graph is a directed graph in which no rings are present.
(5) Degree of entry: in a directed acyclic graph, the degree of entry of a node (vertex) refers to the number of edges that enter the node (vertex).
(6) A critical path: if the tasks to be executed are organized in the directed acyclic graph, the path with the longest length in the directed acyclic graph is called a critical path. The delay (float) time of a task on any critical path will directly affect the overall completion time of all tasks.
(7) Parallelism: in computer architectures, parallelism refers to the maximum number of data or instructions that can be executed in parallel. In the blockchain domain, the parallelism of transaction execution refers to the maximum number of transactions that can be executed in parallel at the same time.
(8) The start-up algorithm: an algorithm based on an intuitive or empirical construct gives, at an acceptable cost (in terms of computation time and space), a feasible solution for each instance of the combinatorial optimization problem to be solved, the degree of deviation of which from the optimal solution is generally unpredictable.
To facilitate understanding of the embodiment of the present invention, first, a block transaction execution system architecture suitable for the embodiment of the present invention is described by taking the system architecture shown in fig. 1 as an example. The block transaction execution system architecture may be applied to execute each transaction in the transaction list in the block based on the transaction dependency graph in the block chain, and the present invention is not limited in this respect in an actual application scenario. As shown in fig. 1, the system architecture may be a server 100 including a processor 110, a communication interface 120, and a memory 130.
The communication interface 120 is used for communicating with a terminal device, and transceiving information transmitted by the terminal device to implement communication.
The processor 110 is a control center of the server 100, connects various parts of the entire server 100 using various interfaces and lines, and performs various functions of the server 100 and processes data by operating or executing software programs and/or modules stored in the memory 130 and calling data stored in the memory 130. Alternatively, processor 110 may include one or more processing units.
The memory 130 may be used to store software programs and modules, and the processor 110 executes various functional applications and data processing by operating the software programs and modules stored in the memory 130. The memory 130 may mainly include a storage program area and a storage data area, wherein the storage program area may store an operating system, an application program required for at least one function, and the like; the storage data area may store data created according to a business process, and the like. Further, the memory 130 may include high speed random access memory, and may also include non-volatile memory, such as at least one magnetic disk storage device, flash memory device, or other volatile solid state storage device.
It should be noted that the structure shown in fig. 1 is only an example, and the embodiment of the present invention is not limited thereto.
Based on the above description, fig. 2 exemplarily shows a flow of an execution method of a block transaction according to an embodiment of the present invention, and the flow may be executed by an execution apparatus of the block transaction.
As shown in fig. 2, the process specifically includes:
step 201, determining each non-conflict transaction set in sequence according to the transaction sequence of each transaction in the block.
Step 202, determining the dependency relationship of the adjacent non-conflict transaction sets according to the construction sequence of each non-conflict transaction set.
And step 203, executing according to the dependency relationship sequence of each non-conflict transaction set.
In step 201, the non-conflicting transaction sets are sequentially determined according to the transaction sequence of the transactions in the block. The method comprises the steps of sequentially storing all transactions in a residual transaction record according to the transaction sequence of all transactions in a block, constructing a first initial set of first transactions aiming at the first transactions in the residual transaction record, determining a first candidate set of the first transactions from the residual transaction record, wherein any transaction in the first candidate set does not have execution conflict with the first transactions, namely, finding out a first conflict transaction set with the first transactions according to a conflict transaction dictionary, and storing an mth transaction in the residual transaction list into the first candidate set if the mth transaction does not exist in the first conflict transaction set, wherein the tolerance of all transactions in the first candidate set is determined according to a transaction tolerance dictionary. And determining the transactions which can be added into the first initial set according to the tolerance of each transaction in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction, deleting each transaction in the non-conflict transaction set of the first transaction from the rest transaction records, returning to execute the first transaction in the rest transaction records, and constructing the first initial set of the first transaction until no transaction exists in the rest transaction records. Therefore, the influence of the transaction sequence on the parallelism of the transaction execution is small, and the method is favorable for ensuring the sufficient and efficient execution of the transaction. Executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block; the first initial set includes a first transaction; the first transaction is the first transaction in the remaining transaction records.
When a non-conflict transaction set of the first transaction is constructed, if it is determined that a second transaction with higher latitude than the first transaction does not exist in the first candidate set, adding a third transaction in the first candidate set into the first initial set, wherein the latitude of the third transaction is the transaction with the highest latitude in the first candidate set except the first transaction. And after deleting the third transaction and the conflict transaction of the third transaction from the first candidate set, returning to the step of adding the third transaction in the first candidate set into the first initial set until no transaction exists in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction. And if the second transaction with the tolerance higher than that of the first transaction exists in the first candidate set, adjusting the first transaction to the tail part of the rest transaction records, returning to execute the step of constructing the first initial set of the first transaction aiming at the first transaction in the rest transaction records. Therefore, the influence of the transaction sequence on the parallelism of the transaction execution is small, and the method is favorable for ensuring the sufficient and efficient execution of the transaction.
Further, a transaction latitude dictionary and a conflict transaction dictionary are determined by: and on the basis of the transaction sequence of each transaction in the block, when traversing to the nth transaction in each transaction, resolving public resources of the nth transaction, resolving public resources of the r transaction before the nth transaction, if determining that the public resources of the nth transaction and the public resources of the r transaction have conflict, processing the tolerance of the nth transaction, processing the tolerance of the r transaction, storing the r transaction into a conflict transaction set of the nth transaction, storing the nth transaction into the conflict transaction set of the r transaction until all the transactions are traversed, determining a transaction tolerance dictionary, and determining a conflict transaction dictionary. Thus, based on the judgment whether the public resource of the nth transaction conflicts with the public resource of the r transaction, a transaction tolerance dictionary and a conflict transaction dictionary are constructed so as to provide support for subsequently determining a non-conflict transaction set of each transaction. Wherein the common resource may be represented as having the same transfer transaction object, or may be represented as having the same storage space, etc.
In the above step 202, the dependency relationship between adjacent non-conflicting transaction sets is determined according to the construction sequence of each non-conflicting transaction set. Specifically, for the jth transaction in the (i + 1) th non-conflict transaction set in the non-conflict transaction set list, a third conflict transaction set which conflicts with the jth transaction is found from the conflict transaction dictionary, and if the kth transaction in the ith non-conflict transaction set in the non-conflict transaction set list is determined to exist in the third conflict transaction set, directed edges of the kth transaction and the jth transaction are established, so that an optimal transaction dependency graph of each transaction in the block is established, and support is provided for fully and efficiently executing subsequent transactions. Wherein the jth transaction is dependent on the kth transaction.
In step 203, the execution is performed according to the dependency relationship sequence of each non-conflicting transaction set. Wherein each transaction in each non-conflicting transaction set is executed in parallel. That is, after the optimal transaction dependency graph for each transaction in the block is constructed, each transaction in the block may be executed based on the transaction optimal transaction dependency graph, so that each transaction in the block can be executed sufficiently and efficiently. It should be noted that, in the implementation of the present invention, the construction method of the transaction dependency graph is not affected by the transaction order of each transaction in the transaction list, so that, no matter how the transaction order of each transaction in the transaction list changes, the embodiment of the present invention can construct the transaction dependency graph with the highest possible parallelism with the acceptable computational overhead.
The following briefly introduces the design idea of the embodiment of the present invention:
in the blockchain system, the only precondition for each consensus node to achieve consensus for a certain block is that the results of the block executed by each consensus node are consistent, i.e. the consensus process does not care about the transaction execution sequence of each consensus node, and only needs that after all transactions in the block are executed by each consensus node, the final influence on the state of the blockchain system is the same. Based on the situation, when the transaction dependency graph is constructed, the embodiment of the invention rearranges the transactions, so that all irrelevant transactions are executed in parallel as much as possible, and therefore, the embodiment of the invention can construct the transaction dependency graph with the maximum concurrency degree no matter what the arrangement sequence of the transactions in the transaction list is. After the transaction is rearranged, the transaction that can be successfully executed may fail, but the transaction that can be failed may also be successfully executed, so that compared with the original execution sequence, the rearranged transaction execution sequence does not bring disadvantages, and the precondition of reaching consensus in the blockchain system can still be satisfied. That is, in the embodiment of the present invention, all transactions in the transaction list are divided into a plurality of sets, and there is no conflict between transactions in each set, that is, transactions in each set can be executed completely in parallel. By summarizing the conflict-free transactions into the same set as much as possible, the width of the transaction dependency graph can be extended, so that the maximum concurrency of the transaction dependency graph can be improved, the length of a key path of the transaction dependency graph is further reduced, and all transactions can be executed at a higher speed by block chain nodes under a multi-core architecture.
For example, a transaction may be generalized into multiple non-conflicting sets of transactions. For example, the original transaction list shown on the left side of FIG. 3 is taken as an example for explanation (FIG. 3 is an optimal transaction dependency graph constructed by the prior art; it should be noted that if the order of the original transaction list shown on the left side of FIG. 3 is changed, the optimal transaction dependency graph shown on the right side of FIG. 3 is not constructed, for example, the transaction order is sensitive to the transaction order by taking the transaction order in the transaction list as example for explaining the prior art method for constructing the transaction dependency graph, according to the prior art construction method, the execution order of the transaction dependency graph is executed according to the order of transaction A → B, then transaction A → C, and then transaction C → D, and if the order of transaction A → C and transaction C → D in the transaction list is exchanged, the transaction order in the transaction list is changed into the order of transaction A → B, transaction C → D, transaction A → B, transaction C → D, Transaction A → C, then transaction A → B and transaction C → D are executed in parallel, and after the parallel execution is completed, transaction A → C is executed again. It can be seen from this that the prior art method for constructing the transaction dependency graph is sensitive to the transaction sequence), the transfer transaction C → D can be summarized in the set { a → B, C → D, E → F }, or in the set { E → a, C → D }, however, if the transfer transaction C → D is selected to be summarized in the set { E → a, C → D }, as can be seen from fig. 4, the maximum parallelism of the transaction dependency graph constructed by this selection is 2, and as can be seen from fig. 3, the maximum parallelism of the transaction dependency graph in fig. 4 is reduced, so that the transaction execution efficiency under this selection is also reduced. Therefore, it can be seen that the generalization of transactions into an optimal set of non-conflicting transactions is of paramount importance to the construction of the transaction dependency graph.
In addition, the embodiment of the invention defines a tolerance for each transaction in the transaction list, and the tolerance of one transaction is the number of transactions which do not conflict with the transaction. For example, continuing with the description of the tolerance level by taking the original transaction list shown on the left side of fig. 3 as an example, and then calculating the tolerance level of each transaction in the original transaction list shown on the left side of fig. 3, the transaction tolerance table of the original transaction list may be as shown in table 1.
TABLE 1
Transfer transactions Tolerance of
A→B 3
C→D 4
E→F 2
D→E 2
A→F 2
E→A 1
As can be seen from Table 1, the higher the latitude of a transaction, the more transactions with which a non-conflicting transaction set can be composed. Based on the thought, when the optimal conflict-free transaction set where a certain transaction is located is solved based on the starting algorithm, firstly, the optimal conflict-free transaction set is initialized to only contain the transaction, and then, the transaction with the highest latitude is continuously selected from the rest of the transactions which do not conflict with the transactions in the optimal conflict-free transaction set to expand the optimal conflict-free transaction set until no transaction does not conflict with the optimal conflict-free transaction set. For example, the steps for solving the optimal non-conflicting set of transfer transactions C → D based on the initiator algorithm are as follows:
a. the optimal set of non-conflicting transactions is initialized to { C → D }, where non-conflicting transactions include A → B, E → F, E → A, A → F.
b. By looking up the transaction latitude table (table 1), the highest latitude among the non-conflicting transactions is a → B, so the set is expanded to { C → D, a → B }, and the transaction that does not conflict with the optimal set of non-conflicting transactions among the remaining transactions is E → F.
c. Because only one non-conflict transaction remains, the optimal non-conflict transaction set is directly expanded to { C → D, A → B, E → F }, and then the non-conflict transactions with the optimal non-conflict transaction set do not exist in the remaining transactions.
d. The enabler algorithm ends, and the result indicates that the transfer transaction C → D should be generalized to the set { C → D, A → B, E → F }.
The embodiment of the invention divides the transactions in the transaction list into a plurality of sets of non-conflict transactions, then sequentially traverses the sets, establishes directed edges for representing the dependency relationship between the transactions of the sets, and specifies that only the transactions in the subsequent sets depend on the transactions in the preamble sets, thereby ensuring the correctness of the transactions in parallel execution, and the finally generated transaction dependency graph has no loop. It should be noted that, after the preceding transaction in the transaction dependency graph is completed, the income of the subsequent transaction dependent on the transaction is decreased by 1, and the transaction with the income of 0 can be immediately put into operation. When there are a plurality of transactions with an in-degree of 0 at the same time, the plurality of transactions can be executed in parallel.
In view of the above, the implementation of the block transaction in the embodiment of the present invention is described in detail below.
Step 1: and constructing a transaction tolerance dictionary and a conflict transaction dictionary.
Referring to fig. 5, fig. 5 is a schematic flowchart of a process for constructing a transaction latitude dictionary and a conflict transaction dictionary according to an embodiment of the present invention. And establishing a transaction tolerance dictionary and a conflict transaction dictionary based on the analyzed common resources used by each transaction. The specific process of constructing the transaction tolerance dictionary and the conflict transaction dictionary comprises the following steps:
(1) reading a transaction list S of length N from the block, using notation SiIndicating the ith transaction in S.
(2) Initializing a transaction tolerance dictionary T, and directly querying the tolerance of a certain transaction through the T, wherein the tolerance of each transaction is N-1 at the beginning.
(3) A conflict transaction dictionary R is initialized, and a set of transactions which conflict with a certain transaction can be directly inquired through the dictionary R. Wherein, each element in R is a transaction set, and initially, the conflict transaction set of each transaction is empty.
(4) The initialization variable I is 1.
(5) Check if I is greater than or equal to N. If yes, jumping to (17); otherwise, jump to (6).
(6) Resolving transaction SIThe common resource used.
(7) The initialization variable J is 0.
(8) Check if J is greater than or equal to I. If yes, jumping to (16); otherwise jump to (9).
(9) Resolving transaction SJThe common resource used;
(10) checking transaction SJCommon resource used and transaction SIWhether there is a conflict with the common resources used. If yes, jumping to (11); otherwise jump to (15).
(11) Mixing T [ S ]J]And subtracting one.
(12) Mixing T [ S ]I]And subtracting one.
(13) Will SJTo R [ S ]I]In (1).
(14) Will SITo R [ S ]J]In (1).
(15) J ═ J +1, and jump to (8).
(16) I ═ I +1, and jump to (5).
(17) And (6) ending.
Step 2: the non-conflicting transaction sets are partitioned.
Referring to fig. 6, fig. 6 is a schematic flowchart illustrating a process of dividing a non-conflicting transaction set according to an embodiment of the present invention. And processing each transaction in the transaction list in the block through the transaction latitude dictionary and the conflict transaction dictionary constructed based on the Step1 to determine a non-conflict transaction set list. The specific process for dividing the conflict-free transaction set comprises the following steps:
(1) reads in the transaction latitude dictionary T constructed in Step 1.
(2) Reads into conflict transaction dictionary R constructed in Step 1.
(3) The transaction list S in the block is read in.
(4) Initializing a non-conflict transaction set list U, wherein each element in the list is a transaction set, and the U is empty initially.
(5) Initializing a remaining transaction list V, each element in the list being a transaction, initially V being empty.
(6) And adding all the transactions in the S into the residual transaction list V in sequence.
(7) Check if V is empty. If yes, jumping to (25); otherwise, jump to (8).
(8) The first transaction x in V is read in. The first transaction x is referred to herein as the transaction located at the beginning of the remaining transactions list V.
(9) The set of conflicting transactions x is looked up from the conflicting transaction dictionary R.
(10) Initializing a non-conflicting transaction candidate set C, each element in the set being a transaction, and initially C being null.
(11) The initialization variable I is 1.
(12) Check if I is greater than or equal to the length of V. If yes, jumping to (16); otherwise, jump to (13).
(13) Inspection VIWhether it is in the set of transactions that conflict with transaction x. If yes, jumping to (15); otherwise, jump to (14).
(14) Will VITo the non-conflicting transaction candidate set C.
(15) I +1, jump to (12).
(16) Initializing an optimal conflict-free transaction set O, wherein each element in the set is a transaction, and initially, the optimal conflict-free transaction set O only contains a transaction x.
(17) It is checked whether the non-conflicting transaction candidate set C is empty. If yes, jumping to (23); otherwise, jump to (18).
(18) And inquiring the transaction y with the highest latitude in the non-conflict transaction candidate set C from the transaction latitude dictionary T.
(19) It is checked whether the latitude of transaction x is greater than or equal to the latitude of transaction y. If yes, jumping to (20); otherwise, transaction x is adjusted to the end of the remaining list V and jumps to (8).
(20) Adding the transaction y to the optimal conflict-free transaction set O.
(21) The set of conflicting transactions y is looked up from the conflicting transaction dictionary R.
(22) The transaction that conflicts with transaction y is removed from the non-conflicting transaction candidate set C and then jumps to (17).
(23) All transactions in the optimal non-conflicting transaction set O are removed from the remaining transaction list V.
(24) And adding the optimal conflict-free transaction set O into a conflict-free transaction set list U, and then jumping to (7).
(25) And (6) ending.
Step 3: directed edges with transaction dependencies are established.
Referring to fig. 7, fig. 7 is a schematic flowchart of establishing a directed edge with a transaction dependency according to an embodiment of the present invention. And processing each non-conflict transaction set in the non-conflict transaction set list by the conflict transaction dictionary constructed based on the Step1 and the non-conflict transaction set list constructed based on the Step2, and establishing a directed edge with transaction dependency relationship. The specific process of establishing the directed edge with the transaction dependency relationship comprises the following steps:
(1) the conflict transaction dictionary R constructed in Step1 is read in.
(2) Reading in the non-conflicting transaction set list U constructed in Step2, and using notation UiRepresenting the ith set of non-conflicting transactions in U.
(3) The set of dependent edges E is initialized, and E is initially null.
(4) The initialization variable I is 0.
(5) Check if I +1 is greater than or equal to the length of U. If yes, jumping to (17); otherwise, jump to (6).
(6) Read-in UIAnd UI+1
(7) The initialization variable J is 0.
(8) Checking whether J is greater than or equal to UI+1Length of (d). If yes, jumping to (16); otherwise jump to (9).
(9) Inquiring and trading U from conflict trading dictionary RI+1[J]A set of conflicting transactions.
(10) The initialization variable K is 0.
(11) Checking whether K is greater than or equal to UILength of (d). If yes, jumping to (15); otherwise, jumping to (12);
(12) checking transaction UI[K]Whether or not to be transacted with UI+1[J]In the set of conflicting transactions. If so. Then go to (13); otherwise go to (14).
(13) Adding a record (U) in the dependent edge set EI[K],UI+1[J]) The record representing a transaction UI+1[J]Dependent on transaction UI[K]。
(14) K +1, and jumps to (11).
(15) J ═ J +1, and jump to (8).
(16) I ═ I +1, and jump to (5).
(17) And (6) ending.
Step 4: and executing the block transaction.
After the optimal transaction dependency graph is constructed according to steps 1 to 3, each transaction in the block can be executed based on the optimal transaction dependency graph. The method for constructing the optimal transaction dependency graph from Step1 to Step3 is insensitive to the sequence of the transactions in the transaction list in the block, that is, no matter how the sequence of the transactions in the transaction list in the block is arranged, the transaction dependency graph with the highest transaction execution parallelism can be constructed from Step1 to Step3, and the transaction execution parallelism is not reduced due to the change of the transaction sequence, so that the efficiency of transaction execution is not reduced.
Illustratively, the construction of the transaction dependency graph continues as described by way of example with the original transaction list shown on the left side of FIG. 3. Step2 is executed to store the transactions in the original transaction list into the remaining transaction list V according to the transaction sequence of the transactions. Reading in the first transaction A → B, inquiring the transaction set which conflicts with the transaction A → B from the conflict dictionary to be { A → B, A → F, E → A }, and determining the non-conflict transaction candidate set of the transaction A → B to be { C → D, E → F, D → E }, according to the conflict transaction set { A → F, E → A }. Then, an initial optimal non-conflict transaction set which only comprises the transactions A → B is constructed, and the transaction with the highest tolerance in the non-conflict transaction candidate set is the transaction C → D and the tolerance is 4 by inquiring the transaction tolerance dictionary (table 1). Since the tolerance of transaction A → B (3) is less than the tolerance of transaction C → D (4), transaction A → B is adjusted to the tail of the remaining list V.
After the transaction A → B is processed, the first transaction C → D in the residual list V is read, the transaction set which conflicts with the transaction C → D is searched from the conflict dictionary to be { D → E }, and according to the conflict transaction set { D → E }, the conflict-free transaction candidate set of the transaction C → D is determined to be { A → B, E → F, E → A, A → F }. Then, an initial optimal non-conflict transaction set containing only the transactions C → D is constructed, and the transaction with the highest tolerance in the non-conflict transaction candidate set is the transaction A → B by inquiring the transaction tolerance (table 1), and the tolerance is 3. Since the tolerance of transaction C → D (4) is greater than the tolerance of transaction A → B (3), transaction A → B is added to the initial optimal set of non-conflicting transactions of transaction C → D, i.e., the optimal set of non-conflicting transactions is { C → D, A → B }. Then, the set of transactions that conflict with transaction A → B is looked up from the conflict transaction dictionary as { A → B, A → F, E → A }, and the transactions that conflict with transaction A → B are deleted from the set of conflict-free transaction candidates { A → B, E → F, E → A, A → F }, i.e., the set of conflict-free transaction candidates for transaction C → D becomes { E → F }. Then, the check continues to see if the set of non-conflicting transaction candidates is empty, and when it is determined not to be empty, transaction E → F is added to the initial optimal set of non-conflicting transactions of transaction C → D, i.e., the optimal set of non-conflicting transactions of transaction C → D is { C → D, A → B, E → F }, since the latitude of transaction C → D (4) is greater than the latitude of transaction E → F (2). At this point in time when the candidate set of non-conflicting transactions is empty, all transactions in the optimal set of non-conflicting transactions { C → D, A → B, E → F } of transactions C → D are deleted from the remaining list, and the optimal set of non-conflicting transactions { C → D, A → B, E → F } of transactions C → D is added as set U1 to the list of non-conflicting transactions U, at which time the remaining list becomes { D → E, A → F, E → A }.
And then, reading the first transaction D → E in the residual list V, inquiring the transaction set which conflicts with the transaction D → E from the conflict dictionary into { C → D, E → F, E → A }, and determining the non-conflict transaction candidate set of the transaction D → E as { A → F }, according to the conflict transaction set { C → D, E → F, E → A }. Then, an initial optimal non-conflict transaction set which only comprises the transactions D → E is constructed, and the transaction with the highest tolerance in the non-conflict transaction candidate set is the transaction A → F by inquiring the transaction tolerance (table 1), and the tolerance is 2. Since the latitude of transaction D → E (2) is equal to the latitude of transaction A → F (2), transaction A → F is added to the initial optimal set of non-conflicting transactions of transaction D → E, i.e., the optimal set of non-conflicting transactions is { D → E, A → F }. At this time, the candidate set of non-conflicting transactions is empty, then all transactions in the optimal set of non-conflicting transactions { D → E, A → F } of transactions D → E are deleted from the remaining list, and the optimal set of non-conflicting transactions { D → E, A → F } of transactions D → E is added as set U2 to the list U of non-conflicting transactions set, at which time the remaining list becomes { E → A }, and transaction E → A is added as an optimal set U3 to the list U of non-conflicting transactions set, at which time the list U of non-conflicting transactions set is { { C → D, A → B, E → F }, { D → E, A → F }, { E → A } }.
Finally, according to the execution Step of Step3, an optimal transaction dependency graph as shown in fig. 8 is constructed according to the non-conflict transaction set list U { { C → D, a → B, E → F }, { D → E, a → F }, { E → a } } and the non-conflict transaction dictionary, and then each transaction in the block is executed based on the optimal transaction dependency graph. It should be noted that, no matter how the transaction sequence of each transaction in the original transaction list changes, an optimal transaction dependency graph can be constructed. However, in the prior art, the transaction list is required to be traversed according to a certain sequence in the process of establishing the transaction dependency graph, and only the transaction which is sequenced later in the traversal process depends on the transaction which is sequenced earlier. Thus, once the order of the original transaction list is changed, an optimal transaction dependency graph as shown on the right side of FIG. 3 cannot be constructed.
The above embodiment shows that each non-conflicting transaction set is determined in sequence according to the transaction sequence of each transaction in the block, and the dependency relationship between adjacent non-conflicting transaction sets is determined according to the construction sequence of each non-conflicting transaction set. And executing according to the dependency relationship sequence of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel. Because the transactions without execution conflicts are summarized into the same non-conflict transaction set, the influence of the transaction sequence on the parallelism during the execution of the transactions can be avoided, and because any non-conflict transaction set is constructed according to the transaction with the highest tolerance in the set, the width of a transaction dependency graph can be expanded, and all transactions in any non-conflict transaction set can be completely executed in parallel, so that the influence of the transaction sequence on the parallelism during the execution of the transactions can be reduced, the parallelism during the execution of the transactions can be improved, and the efficient execution of the transactions can be ensured.
Based on the same technical concept, fig. 9 exemplarily shows an apparatus for performing a block transaction according to an embodiment of the present invention, and the apparatus can perform a flow of a method for performing a block transaction.
As shown in fig. 9, the apparatus includes:
a determining unit 901, configured to sequentially determine each non-conflicting transaction set according to a transaction sequence of each transaction in the block; executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block;
a processing unit 902, configured to determine a dependency relationship between adjacent non-conflicting transaction sets according to a construction sequence of each non-conflicting transaction set; and executing in sequence according to the dependency relationship of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel.
Optionally, the processing unit 902 is specifically configured to:
sequentially storing the transactions into the rest transaction records according to the transaction sequence of the transactions in the block;
for a first transaction in the remaining transaction records, constructing a first initial set of the first transaction; the first initial set includes the first transaction; the first transaction is the first transaction in the remaining transaction records;
determining a first candidate set of the first transaction from the remaining transaction records; there is no execution conflict between any transaction in the first candidate set and the first transaction;
determining the transactions which can be added into the first initial set according to the tolerance of each transaction in the first candidate set, thereby constructing a non-conflict transaction set of the first transactions;
deleting each transaction in the non-conflict transaction set of the first transaction from the remaining transaction records, returning to execute the first transaction in the remaining transaction records, and constructing a first initial set of the first transaction until no transaction exists in the remaining transaction records.
Optionally, the processing unit 902 is specifically configured to:
determining that there is no second transaction in the first candidate set with a higher latitude than the first transaction;
adding a third transaction in the first candidate set to the first initial set; the latitude of the third transaction is the transaction with the highest latitude except the first transaction in the first candidate set;
and after the third transaction and the conflict transaction of the third transaction are deleted from the first candidate set, returning to the step of adding the third transaction in the first candidate set into the first initial set until no transaction exists in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction.
Optionally, the processing unit 902 is specifically configured to:
determining that there is a second transaction in the first candidate set that is more tolerant than the first transaction;
and adjusting the first transaction to the tail part in the residual transaction records, and returning to the step of executing the first transaction in the residual transaction records and constructing a first initial set of the first transaction.
Optionally, the processing unit 902 is specifically configured to:
finding out a first conflict transaction set of the first transaction according to a conflict transaction dictionary;
if it is determined that the mth transaction in the list of remaining transactions does not exist in the first set of conflicting transactions, storing the mth transaction in the first candidate set;
the latitude of each transaction in the first candidate set is determined according to a transaction latitude dictionary.
Optionally, the processing unit 902 is specifically configured to:
analyzing the public resource of the nth transaction and analyzing the public resource of the r transaction before the nth transaction when traversing the nth transaction in each transaction based on the transaction sequence of each transaction in the block;
if the fact that the public resource of the nth transaction conflicts with the public resource of the r transaction is determined, processing the tolerance of the nth transaction and processing the tolerance of the r transaction; storing the r transaction into a conflict transaction set of the n transaction, and storing the n transaction into the conflict transaction set of the r transaction; and determining the transaction latitude dictionary and determining the conflict transaction dictionary until all the transactions are traversed.
Optionally, the processing unit 902 is specifically configured to:
aiming at the jth transaction in the (i + 1) th non-conflict transaction set, finding out a third conflict transaction set which conflicts with the jth transaction from a conflict transaction dictionary;
if the kth transaction in the ith non-conflict transaction set is determined to exist in the third conflict transaction set, establishing a directed edge between the kth transaction and the jth transaction; the jth transaction is dependent on the kth transaction.
Based on the same technical concept, an embodiment of the present invention provides a computing device, including:
a memory for storing a computer program;
and the processor is used for calling the computer program stored in the memory and executing the execution method of the block transaction according to the obtained program.
Based on the same technical concept, embodiments of the present invention provide a computer-readable storage medium storing a computer-executable program for causing a computer to perform an execution method of a block transaction.
As will be appreciated by one skilled in the art, embodiments of the present invention may be provided as a method, system, or computer program product. Accordingly, the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present invention may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present invention is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the invention. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all such alterations and modifications as fall within the scope of the invention.
It will be apparent to those skilled in the art that various changes and modifications may be made in the present invention without departing from the spirit and scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present application and their equivalents, the present invention is also intended to include such modifications and variations.

Claims (10)

1. A method for performing a block transaction, comprising:
determining each non-conflict transaction set in sequence according to the transaction sequence of each transaction in the block; executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block;
determining the dependency relationship of adjacent non-conflict transaction sets according to the construction sequence of each non-conflict transaction set;
and executing in sequence according to the dependency relationship of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel.
2. The method of claim 1, wherein determining the non-conflicting sets of transactions in order of transaction for each transaction in the block comprises:
sequentially storing the transactions into the rest transaction records according to the transaction sequence of the transactions in the block;
for a first transaction in the remaining transaction records, constructing a first initial set of the first transaction; the first initial set includes the first transaction; the first transaction is the first transaction in the remaining transaction records;
determining a first candidate set of the first transaction from the remaining transaction records; there is no execution conflict between any transaction in the first candidate set and the first transaction;
determining the transactions which can be added into the first initial set according to the tolerance of each transaction in the first candidate set, thereby constructing a non-conflict transaction set of the first transactions;
deleting each transaction in the non-conflict transaction set of the first transaction from the remaining transaction records, returning to execute the first transaction in the remaining transaction records, and constructing a first initial set of the first transaction until no transaction exists in the remaining transaction records.
3. The method of claim 2, wherein said determining transactions that can be added to said first initial set based on the latitude of each transaction in said first candidate set to construct said first set of non-conflicting transactions comprises:
determining that there is no second transaction in the first candidate set with a higher latitude than the first transaction;
adding a third transaction in the first candidate set to the first initial set; the latitude of the third transaction is the transaction with the highest latitude except the first transaction in the first candidate set;
and after the third transaction and the conflict transaction of the third transaction are deleted from the first candidate set, returning to the step of adding the third transaction in the first candidate set into the first initial set until no transaction exists in the first candidate set, thereby constructing a non-conflict transaction set of the first transaction.
4. The method of claim 2, wherein said determining transactions that can be added to said first initial set based on the latitude of each transaction in said first candidate set to construct said first set of non-conflicting transactions comprises:
determining that there is a second transaction in the first candidate set that is more tolerant than the first transaction;
and adjusting the first transaction to the tail part in the residual transaction records, and returning to the step of executing the first transaction in the residual transaction records and constructing a first initial set of the first transaction.
5. The method of claim 2, wherein said determining a first candidate set of said first transaction from said remaining transaction records comprises:
finding out a first conflict transaction set of the first transaction according to a conflict transaction dictionary;
if it is determined that the mth transaction in the list of remaining transactions does not exist in the first set of conflicting transactions, storing the mth transaction in the first candidate set;
the latitude of each transaction in the first candidate set is determined according to a transaction latitude dictionary.
6. The method of claim 5, wherein the transaction latitude dictionary and the conflict transaction dictionary are determined according to:
analyzing the public resource of the nth transaction and analyzing the public resource of the r transaction before the nth transaction when traversing the nth transaction in each transaction based on the transaction sequence of each transaction in the block;
if the fact that the public resource of the nth transaction conflicts with the public resource of the r transaction is determined, processing the tolerance of the nth transaction and processing the tolerance of the r transaction; storing the r transaction into a conflict transaction set of the n transaction, and storing the n transaction into the conflict transaction set of the r transaction; and determining the transaction latitude dictionary and determining the conflict transaction dictionary until all the transactions are traversed.
7. The method of any of claims 1 to 6, wherein determining the dependencies of adjacent non-conflicting transaction sets in the order in which they are constructed comprises:
aiming at the jth transaction in the (i + 1) th non-conflict transaction set, finding out a third conflict transaction set which conflicts with the jth transaction from a conflict transaction dictionary;
if the kth transaction in the ith non-conflict transaction set is determined to exist in the third conflict transaction set, establishing a directed edge between the kth transaction and the jth transaction; the jth transaction is dependent on the kth transaction.
8. An apparatus for performing a block transaction, comprising:
the determining unit is used for sequentially determining each non-conflict transaction set according to the transaction sequence of each transaction in the block; executing conflicts do not exist among all the transactions in any conflict-free transaction set, and any conflict-free transaction set is constructed according to the transaction with the highest tolerance in the set; the tolerance is used for representing the number of the transactions which do not conflict with the number of the transactions in the block;
the processing unit is used for determining the dependency relationship of adjacent non-conflict transaction sets according to the construction sequence of each non-conflict transaction set; and executing in sequence according to the dependency relationship of each non-conflict transaction set, wherein each transaction in each non-conflict transaction set is executed in parallel.
9. A computing device, comprising:
a memory for storing a computer program;
a processor for calling a computer program stored in said memory, for executing the method of any one of claims 1 to 7 in accordance with the obtained program.
10. A computer-readable storage medium, characterized in that the computer-readable storage medium stores a computer-executable program for causing a computer to execute the method of any one of claims 1 to 7.
CN202011440624.7A 2020-12-08 2020-12-08 Block transaction execution method and device Pending CN112487096A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202011440624.7A CN112487096A (en) 2020-12-08 2020-12-08 Block transaction execution method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202011440624.7A CN112487096A (en) 2020-12-08 2020-12-08 Block transaction execution method and device

Publications (1)

Publication Number Publication Date
CN112487096A true CN112487096A (en) 2021-03-12

Family

ID=74941677

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202011440624.7A Pending CN112487096A (en) 2020-12-08 2020-12-08 Block transaction execution method and device

Country Status (1)

Country Link
CN (1) CN112487096A (en)

Similar Documents

Publication Publication Date Title
US20180158034A1 (en) Dynamic reordering of blockchain transactions to optimize performance and scalability
CN112150163A (en) Block chain contract transaction parallel execution method and device
US9870221B2 (en) Providing code change job sets of different sizes to validators
CN110675255B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN110599183B (en) Intelligent contract calling method and device and storage medium
US20200264856A1 (en) Compilation Method
CN110648124B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN110599166A (en) Method and device for acquiring transaction dependency relationship in block chain
CN113743950A (en) Method for performing transactions in a blockchain, blockchain node and blockchain
US10853341B2 (en) Blockchain based hierarchical data storage
CN113744062B (en) Method for performing transactions in a blockchain, blockchain node and blockchain
US20220050827A1 (en) Block verification method, apparatus and device
CN113869902A (en) Block chain transaction execution method and device
CN114298713A (en) Alliance chain fragmentation method and device and storage medium
CN110689344B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN110706108B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN112487096A (en) Block transaction execution method and device
CN114564412B (en) Method and system for deterministic transaction concurrent scheduling of block chains
CN113656507B (en) Method and device for executing transaction in block chain system
CN113867903B (en) Method and device for determining parallel conflict domain of intelligent contract in block chain
CN115760405A (en) Transaction execution method, device, computer equipment and medium
CN113077344B (en) Block chain-based transaction method, device, electronic equipment and storage medium
CN114331440A (en) Conflict detection and performance optimization method and device
Qi et al. Smart contract parallel execution with fine-grained state accesses
US8290917B2 (en) Reordering of data elements in a data parallel system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination