CN114564412B - Method and system for deterministic transaction concurrent scheduling of block chains - Google Patents

Method and system for deterministic transaction concurrent scheduling of block chains Download PDF

Info

Publication number
CN114564412B
CN114564412B CN202210453605.0A CN202210453605A CN114564412B CN 114564412 B CN114564412 B CN 114564412B CN 202210453605 A CN202210453605 A CN 202210453605A CN 114564412 B CN114564412 B CN 114564412B
Authority
CN
China
Prior art keywords
transaction
transactions
conflict
scheduling
starting
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.)
Active
Application number
CN202210453605.0A
Other languages
Chinese (zh)
Other versions
CN114564412A (en
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.)
Beijing Microchip Sensing Technology Co ltd
Original Assignee
Beijing Microchip Sensing Technology 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 Beijing Microchip Sensing Technology Co ltd filed Critical Beijing Microchip Sensing Technology Co ltd
Priority to CN202210453605.0A priority Critical patent/CN114564412B/en
Publication of CN114564412A publication Critical patent/CN114564412A/en
Application granted granted Critical
Publication of CN114564412B publication Critical patent/CN114564412B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/48Program initiating; Program switching, e.g. by interrupt
    • G06F9/4806Task transfer initiation or dispatching
    • G06F9/4843Task transfer initiation or dispatching by program, e.g. task dispatcher, supervisor, operating system
    • G06F9/4881Scheduling strategies for dispatcher, e.g. round robin, multi-level priority queues
    • 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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • General Engineering & Computer Science (AREA)
  • Quality & Reliability (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Development Economics (AREA)
  • Economics (AREA)
  • Marketing (AREA)
  • Strategic Management (AREA)
  • Technology Law (AREA)
  • General Business, Economics & Management (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application provides a deterministic transaction concurrent scheduling method and system for a block chain, which relate to the technical field of the block chain, and the method comprises the following steps: obtaining a plurality of pre-sequenced transactions to be scheduled, and starting a scheduling instance to perform the sequenced transactions in parallel; writing the execution result of each transaction into the corresponding transaction, starting a coroutine, and sequentially performing conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions; under the condition that conflict transactions are detected, packaging conflict-free transactions before the conflict transactions, and simultaneously generating a snapshot tool for conflict detection of subsequent transactions; starting a new scheduling example, and taking the conflict transaction as a starting point to re-schedule the transaction after the conflict transaction in parallel; and repeating the steps until the transaction is completely scheduled. The method can obviously improve the concurrent processing efficiency of the transaction, and the scheduling process does not need to generate a directed acyclic graph, thereby reducing the bandwidth occupied by transaction processing.

Description

Method and system for deterministic transaction concurrent scheduling of block chains
Technical Field
The present application relates to the field of block chain technologies, and in particular, to a method and a system for deterministic transaction concurrent scheduling for a block chain.
Background
At present, the block chain technology has been widely applied to various fields such as finance, internet of things, logistics, public service and the like. In practice, each transaction is performed by a node of the blockchain, and the time and sequence of the transaction are recorded by the block as part of the blockchain.
In the related art, when executing a transaction, a mode of generating an execution result of the transaction after pre-executing the transaction, then packaging the transaction into blocks and distributing the blocks to all nodes is generally adopted, or a mode of pre-executing the transaction after receiving a transaction request to be processed, generating an execution result, forming a dependency according to the execution result in a consensus process, namely, a directed acyclic graph DAG, and then executing the transaction in parallel is adopted.
For example, in the first related scheme, after the hyper hedger fabric1.0, the intelligent contract transaction of the user is pre-executed by the endorsement node to generate a read-write set of the transaction, and then the ordering node packs the transaction into blocks and distributes the blocks to all nodes. And the nodes can execute in parallel after generating the DAG according to the read-write set analysis dependency relationship. In the second related scheme, in a super chain, a transaction request to be processed is received firstly, a read-write set is generated after the intelligent contract transaction of a user is pre-executed by a certain node, and then in the process of consensus, the nodes can form a dependence DAG according to the read-write set and then are executed in parallel. In a third related approach, in FISCOCCOS, a user can follow a parallel framework when writing a smart contract. In the node validation block, dependencies between transactions may be analyzed according to a parallel contract framework, forming a DAG followed by parallel execution.
However, the applicant finds that in the first scheme, the pre-execution time of a batch of transactions in the same block is uncertain, which results in that whether a key is changed when pre-execution and real warehousing are executed needs to be determined by using a version number, and the version number of the key uses the block number changed last time, which results in that the conflict transactions in the same block can only succeed in one stroke and cannot be subjected to the operation of writing before reading. The second and third schemes perform dependency analysis and then perform parallel transaction execution based on the received transaction request, a DAG needs to be generated in the parallel scheduling and transaction execution processes, a certain bandwidth is occupied, and the third scheme depends on a parallel programming framework to judge the dependency relationship between intelligent contract transactions, so that requirements and constraints on developers are higher.
That is, the transaction execution scheme in the related art has low execution efficiency and a complex execution process, and a directed acyclic graph DAG must be generated, which occupies a certain bandwidth.
Disclosure of Invention
The present application is directed to solving, at least to some extent, one of the technical problems in the related art.
Therefore, a first object of the present application is to provide a deterministic transaction concurrent scheduling method for a blockchain, where the method is based on pre-ordered transactions, and nodes perform parallel pre-execution and parallel dependency management on the ordered transactions, so as to significantly improve dependency management processing efficiency, and no DAG is required to be generated in the whole process, thereby improving transaction concurrent processing efficiency.
A second objective of the present application is to provide a system for deterministic transaction concurrency scheduling of blockchains.
A third object of the present application is to propose a non-transitory computer-readable storage medium.
In order to achieve the above object, a first embodiment of the present application is to provide a method for deterministic transaction concurrent scheduling of block chains, the method including the following steps:
s101, acquiring a plurality of transactions to be scheduled, pre-sequencing the transactions, starting a scheduling instance, and pre-executing the sequenced transactions in parallel;
s102, writing the execution result of each transaction into the corresponding transaction, starting a coroutine for conflict detection, and sequentially performing conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions;
s103, under the condition that conflict transactions are detected, packaging conflict-free transactions before the conflict transactions, and simultaneously generating a Snapshot tool Snapshot to perform conflict detection on subsequent transactions;
s104, starting a new scheduling instance, and taking the conflict transaction as a starting point to schedule the transaction after the conflict transaction again in parallel;
and S105, repeatedly executing the steps S102 to S104 until all the transactions are scheduled to be completed.
Optionally, in an embodiment of the present application, a scheduling instance is started, and a coroutine for collision detection is started while the sequenced transactions are pre-executed in parallel.
Optionally, in an embodiment of the present application, the performing conflict detection on the execution result of each transaction sequentially according to the sequence of the sequenced multiple transactions includes sequentially detecting whether each transaction is executed completely according to the sequence; if the current transaction is executed, performing conflict detection on the execution result of the current transaction; and if the current transaction is not executed, waiting for all transactions to be executed and returning an execution result, and then performing conflict detection and judgment.
Optionally, in an embodiment of the present application, after packaging the conflict-free transactions before the conflict transaction, performing block consensus processing according to all conflict-free transactions in the packaged current batch.
Optionally, in an embodiment of the present application, the execution result of the transaction includes: the method for writing the execution result of each transaction into the corresponding transaction comprises the following steps: and writing the read set and the write set back to corresponding transactions.
In order to achieve the above object, a second aspect of the present application further provides a system for deterministic transaction concurrency scheduling of a blockchain, including the following modules:
the system comprises a pre-execution module, a scheduling instance and a scheduling module, wherein the pre-execution module is used for acquiring a plurality of transactions to be scheduled, pre-sequencing the transactions, starting the scheduling instance and pre-executing the sequenced transactions in parallel;
the conflict detection module is used for writing the execution result of each transaction into the corresponding transaction, starting a coroutine for conflict detection, and sequentially performing conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions;
the generating module is used for packaging conflict-free transactions before the conflict transactions under the condition that the conflict transactions are detected, and generating a Snapshot tool Snapshot to carry out conflict detection on subsequent transactions;
the starting module is used for starting a new scheduling instance and taking the conflict transaction as a starting point to schedule the transaction after the conflict transaction again in parallel;
and the repeating module is used for controlling the conflict detection module, the generating module and the starting module to repeatedly execute the functions of the repeating module until all the transactions are scheduled.
Optionally, in an embodiment of the present application, the pre-execution module is specifically configured to: and starting a coroutine for conflict detection while starting a scheduling instance and pre-executing the sequenced transactions in parallel.
Optionally, in an embodiment of the present application, the conflict detection module is specifically configured to: sequentially detecting whether each transaction is executed or not according to the sequence; if the current transaction is executed, performing conflict detection on the execution result of the current transaction; and if the current transaction is not executed, performing conflict detection after waiting for all transactions to be executed and returning execution results.
Optionally, in an embodiment of the application, the generating module is further configured to: and performing block consensus processing according to all conflict-free transactions in the packaged current batch.
In order to implement the foregoing embodiments, an embodiment of the third aspect of the present application further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the deterministic transaction concurrent scheduling method for a blockchain in the foregoing embodiments.
The technical scheme provided by the embodiment of the application at least has the following beneficial effects: the method and the device are based on the pre-sequencing transaction, can perform deterministic concurrent scheduling on the transaction, and can perform dependency management while executing, namely, the node performs parallel pre-execution and parallel dependency management on the sequenced transaction. Under the condition of no conflict, the conflict detection and dependence management processing efficiency of the transaction execution result of the scheme is close to the efficiency of only carrying out conflict detection, so that the dependence management processing efficiency is obviously improved. Moreover, based on the certainty of the transaction execution result, the directed acyclic graph DAG does not need to be generated in the whole transaction scheduling and execution process, the occupation of extra bandwidth is avoided, the cost and the limitation of transaction concurrent scheduling are reduced, and the transaction concurrent processing efficiency is remarkably improved.
Additional aspects and advantages of the invention will be set forth in part in the description which follows and, in part, will be obvious from the description, or may be learned by practice of the invention.
Drawings
The above and/or additional aspects and advantages of the present application will become apparent and readily appreciated from the following description of the embodiments, taken in conjunction with the accompanying drawings of which:
fig. 1 is a flowchart of a deterministic transaction concurrent scheduling method for a block chain according to an embodiment of the present application;
fig. 2 is a flowchart of a conflict detection method according to an embodiment of the present application;
fig. 3 is a flowchart of a specific deterministic transaction concurrent scheduling method for a blockchain according to an embodiment of the present invention;
fig. 4 is a schematic diagram illustrating a specific deterministic transaction concurrency scheduling method for a blockchain according to an embodiment of the present invention;
fig. 5 is a schematic structural diagram of a deterministic transaction concurrency scheduling system for a blockchain according to an embodiment of the present disclosure.
Detailed Description
Reference will now be made in detail to embodiments of the present invention, examples of which are illustrated in the accompanying drawings, wherein like or similar reference numerals refer to the same or similar elements or elements having the same or similar function throughout. The embodiments described below with reference to the accompanying drawings are illustrative and intended to explain the present invention and should not be construed as limiting the present invention.
It should be noted that, in the process of scheduling and executing transactions, compared with the process of sequentially and serially executing multiple transactions, the transaction scheduling mode in parallel can shorten the execution time of executing and verifying each transaction, and is more practical. In the related technology, when the transactions are scheduled in parallel, usually after multiple transactions are acquired, transaction dependency relationships among multiple contract transactions are generated according to corresponding parallel scheduling strategies, then the transactions in the candidate blocks are executed in parallel according to the transaction dependency relationships, and after the dependency relationships are verified to be correct according to execution results, the multiple contract transactions are executed. The transaction parallel execution process is based on non-deterministic transaction parallel scheduling, a dependency relationship needs to be generated in a parallel execution result, namely a Directed Acyclic Graph (DAG) occupies a certain bandwidth, and a parallel transaction scheduling scheme needs to perform conflict detection and transaction dependency analysis after parallel transaction execution, so that parallel execution of transaction conflict detection and dependency relationship (DAG) generation cannot be realized.
Therefore, the method for deterministically scheduling the transactions concurrently in the block chain is provided, and based on the determinacy of the transaction execution result, DAG does not need to be generated in the parallel scheduling and execution process, so that the occupied bandwidth is reduced, and the concurrent processing efficiency is improved.
The following describes a method and a system for deterministic transaction concurrent scheduling for a blockchain according to an embodiment of the present invention with reference to the accompanying drawings.
Fig. 1 is a flowchart of a method for deterministic transaction concurrent scheduling of a block chain according to an embodiment of the present invention, as shown in fig. 1, the method includes the following steps:
step S101, a plurality of transactions to be scheduled are obtained, the transactions are pre-sequenced, a scheduling instance is started, and the sequenced transactions are pre-executed in parallel.
The transaction in this application refers to a call to a blockchain intelligent contract, and includes all information for calling the intelligent contract, such as the name of the intelligent contract, the name and parameters of a calling function, and the like. The pre-ordering is an operation of ordering the acquired transactions according to a preset rule, for example, according to a transaction occurrence time or a sender priority. A scheduling instance is a process flow that schedules a corresponding number of transactions for execution.
Specifically, a plurality of blockchain transactions to be scheduled are obtained in different manners according to actual needs, for example, a batch of currently processed transactions are taken out from a transaction pool according to the needs of a user. And then, pre-sequencing the acquired multiple transactions according to a preset sequencing rule, sending the pre-sequenced multiple transactions to a transaction execution node, starting a scheduling instance by the node after the node receives the batch of pre-sequenced transactions, and executing the sequenced multiple transactions in parallel through the scheduling instance, namely executing each transaction in the batch of transactions simultaneously.
And step S102, writing the execution result of each transaction into the corresponding transaction, starting a coroutine for collision detection, and sequentially performing collision detection on the execution result of each transaction according to the sequence of the sequenced transactions.
The conflict detection refers to analyzing and detecting the transaction dependency relationship between two transactions, and can be performed according to the execution result of each transaction.
The transaction dependency will be explained in detail below. Specifically, in the blockchain technology, the state of the current blockchain is represented by a world state, the world state is a set of key-value sets, and the transaction realizes operations such as adding, deleting, checking and modifying the world state by calling an intelligent contract. And the transaction-to-world can be found by simulating the execution of the transactionThe dependency and influence of the state, and the determined dependency and influence are represented by read and write sets, respectively. Wherein, the reading set
Figure 832677DEST_PATH_IMAGE001
Is a subset, write set, of keys on which transactions depend on the current world state
Figure 493466DEST_PATH_IMAGE002
Is a subset of the keys that the transaction has an effect on the current world state.
In analyzing transaction dependencies, for example, if transaction 1 is a predecessor to transaction 2, the read-write set for transaction 1 is
Figure 573417DEST_PATH_IMAGE003
The read-write set of transaction 2 is
Figure 395880DEST_PATH_IMAGE004
. In the case where the following formula is expressed, that is,
Figure 928492DEST_PATH_IMAGE005
then it is determined that transaction 2 is dependent on transaction 1, i.e., transaction 2 must be executed after transaction 1; otherwise transaction 1 and transaction 2 may be performed in parallel. That is, only when there is no coincidence between the read-write sets of two transactions, or only when there is intersection between the read sets, the two transactions can be executed in parallel, i.e. it is detected that there is no dependency relationship between the two transactions.
In order to more clearly illustrate the implementation process of the deterministic transaction concurrent scheduling method and embody beneficial effects, the following first illustrates the process of the parallel scheduling method that needs to generate the DAG:
the master node performs all transactions in advance during the proposal block. The transactions are firstly sequenced according to rules, so that two transactions in subsequent dependency analysis are prevented from being dependent on each other to form a loop. After sequencing, a directed acyclic graph can be formed according to subsequent dependency analysis. And then calling the intelligent contract to execute the transaction in parallel, generating a read-write set of each transaction, and performing transaction dependence analysis according to the read-write set. Find transactions in which there is no dependency (i.e., transactions that can be executed in parallel) to join the DAG, and write its write set to the world state. Since the write action may cause the read-write set of the subsequent transaction to be changed, the remaining transactions need to be pre-executed again in parallel. The above operations are repeated until all transactions are added to the DAG.
For example, for ordered transactions 1 through 5 (hereinafter denoted as Tx1-Tx 5), the initial transaction execution DAG is empty, Tx1-Tx5 is added to parallel execution in conjunction with S, Tx1-Tx5 is pre-executed in parallel according to the initial state in the first iteration, and after the read-write set is derived, Tx3 is determined to depend on Tx1, Tx4 depends on Tx2 and Tx3, so Tx1, Tx2, Tx5 is removed from set S and added to the first layer of the DAG. Write sets (i.e., changes to state) of Tx1, Tx2, Tx5 are written into the cache. In the second round of iteration, based on the state after the write sets of Tx1, Tx2 and Tx5 are validated, Tx3 and Tx4 are pre-executed in parallel, and updated read-write sets of the two transactions are obtained. The decision Tx4 depends on Tx3, thus moving Tx3 out of set S and adding to the DAG second tier. Write set of Tx3 is written into the cache. In the third iteration, pre-executing Tx4 based on the write set validation state of Tx3, obtaining an updated read-write set, removing S and adding a third layer of DAG. Write set of Tx4 is written into the cache. Because S is already empty at this time, the scheduler terminates, resulting in a DAG dependent transaction from Tx1-Tx 5.
As can be seen from the above description, the transaction parallel execution process in the above embodiment is based on non-deterministic transaction parallel scheduling, and the parallel execution result needs to generate a dependency relationship (DAG), and therefore will occupy a certain bandwidth. The deterministic transaction concurrent scheduling method in the embodiment of the application performs deterministic concurrent scheduling, parallel pre-execution and parallel dependency management on the transaction based on the certainty of the transaction execution result, and does not need to generate DAG in the parallel scheduling and execution process.
In specific implementation, as a first possible implementation manner, after a plurality of ordered transactions are pre-executed in parallel, the execution result of each transaction is written into the corresponding transaction. As an example, the execution result of the transaction includes a read set and a write set generated after the transaction is executed, and the execution result of each transaction is written into the corresponding transaction, that is, the read set and the write set generated after the execution of each transaction are written back into the corresponding transaction. Further, a coroutine for conflict detection is started, and conflict detection is sequentially carried out on the execution result of each transaction in the coroutine according to the sequence of the plurality of sequenced transactions. In the present embodiment, parallel dependency management is performed after parallel pre-execution ends.
Preferably, in order to further improve the efficiency of transaction concurrent scheduling, in an embodiment of the present application, dependency management may be performed while performing transactions in parallel. As a second possible implementation manner, a scheduling instance is started, a schedule for collision detection is started while a plurality of ordered transactions are pre-executed in parallel, and parallel pre-execution and parallel dependency management are performed on the ordered transactions at the same time. And starting a coroutine for conflict detection while executing the transaction, sequentially performing conflict detection on the execution result of each transaction in the coroutine according to the sequence of the sequenced transactions, and judging whether the transaction is a dependent transaction or not according to the read-write set of the transaction, namely, the transaction conflict exists.
In this embodiment, since the time required for the read/write set conflict analysis is shorter than the transaction execution time, there is a possibility that a transaction is not executed yet when the conflict detection is performed on a certain transaction. Therefore, in order to ensure the applicability and reliability of the deterministic transaction concurrency scheduling method in the embodiment of the present application, a specific conflict detection method in the transaction concurrency scheduling process is further provided in the embodiment of the present application. Fig. 2 is a flowchart of a collision detection method according to an embodiment of the present application, and as shown in fig. 2, the method includes the following steps:
step S201, sequentially detecting whether each transaction is executed.
The sequence is the sequence of the plurality of transactions after sorting in the above embodiment.
Specifically, when the conflict detection is sequentially performed on the execution result of each transaction in sequence, whether the current transaction for performing the conflict detection is executed is detected first. As a possible implementation manner, whether a complete execution result is returned in the transaction is detected to determine whether the transaction is executed completely, for example, whether a read set and a write set returned in the transaction exist is detected.
Step S202, if the current transaction is executed, conflict detection is carried out on the execution result of the current transaction.
Specifically, after the completion of the execution of the current transaction is detected, conflict detection is performed according to the execution result of the current transaction, as a possible implementation manner, the overlapping condition between the read-write set of the current transaction and the read-write set of each transaction except the current transaction may be detected according to the manner in the above embodiment, and when the read-write sets of the current transaction and each transaction do not overlap or only the read sets have an intersection, it is detected that the current transaction is independent, and it is determined that the current transaction is a conflict-free transaction.
Step S203, if the current transaction is not executed, the conflict detection judgment is carried out after all transactions are executed and the execution result is returned.
Specifically, if the current transaction is detected not to be completely executed, the collision detection is suspended, and after all transactions in the current batch are completely executed and an execution result is returned, the collision detection determination is continued by taking the suspended position as a starting point.
Therefore, the transaction concurrent scheduling method can realize the dependence management while executing the transaction in parallel.
Step S103, under the condition that conflict transactions are detected, packaging conflict-free transactions before the conflict transactions, and meanwhile generating a Snapshot tool Snapshot to carry out conflict detection on subsequent transactions.
In the embodiment of the application, when parallel dependency management is performed, if the current transaction is detected to be a conflict transaction, in all the transactions to be dispatched after the batch is sequenced, each conflict-free transaction before the sequence of the conflict transaction is packed, and meanwhile, a Snapshot tool Snapshot is generated to perform conflict detection on subsequent transactions.
Specifically, when the execution results of each transaction are sequentially subjected to conflict detection in order, if no conflict transaction is detected, the conflict detection of the next transaction is continued, and when one conflict transaction is detected, the batch of conflict-free transactions before the conflict transaction is packaged. Meanwhile, the sequence and the position of the conflict transaction are recorded, a Snapshot tool Snapshot is generated, and the data of the blocks can be quickly synchronized through the Snapshot, for example, the data after the conflict transaction can be synchronized for subsequent transaction conflict detection.
Further, in an embodiment of the present application, after the conflict-free transactions before the conflict transactions are packaged, the consensus processing of the subsequent block output flow may be performed according to all conflict-free transactions in the packaged current batch. As one possible implementation manner, consensus information is generated according to all conflict-free transactions in a packed current batch, the consensus information is added to a block, the block is broadcasted to other nodes in the block outgoing process, and whether the block achieves consensus or not is determined according to the consensus information contained in the block.
Step S104, a new scheduling instance is started, and the transaction after the conflict transaction is scheduled again in parallel by taking the conflict transaction as a starting point.
And step S105, repeatedly executing the step S102 to the step S104 until all the transactions are scheduled to be completed.
In the embodiment of the present application, a scheduling instance is restarted, and the transaction after the conflict transaction is re-scheduled in parallel, with the conflict transaction detected in step S103 as a starting point. The detailed implementation process of the transaction re-parallel scheduling after the conflict transaction may refer to the description of performing parallel scheduling for the first time in the above embodiment, and the implementation principle is the same, that is, by performing parallel pre-execution on the transaction after the conflict transaction, and then repeating steps S102 to S104, it is detected whether there is a next conflict transaction. Further, if the next conflict transaction is detected, a new scheduling instance is started again in the manner described in step S102 to step S104, and the transaction is scheduled again in parallel from the new conflict transaction. Therefore, by repeatedly executing the parallel scheduling and the processing flows from step S102 to step S104, the multiple transactions to be scheduled are concurrently scheduled until the last transaction of the multiple transactions to be scheduled acquired in step S101 is scheduled, and the scheduling flow is ended.
Therefore, the transaction concurrent scheduling method in the embodiment of the application is based on the pre-ordered transaction block-out flow, can perform deterministic concurrent scheduling on transactions, can perform dependency management while executing, does not need DAG generation, and improves the transaction scheduling efficiency.
To sum up, the deterministic transaction concurrent scheduling method for a blockchain according to the embodiment of the present application can perform deterministic concurrent scheduling on transactions and perform dependency management while executing transactions based on pre-ordered transactions, that is, the node performs parallel pre-execution and parallel dependency management on the ordered transactions. Under the condition of no conflict, the conflict detection and dependence management processing efficiency of the transaction execution result of the method is close to the efficiency of only carrying out the conflict detection, so that the dependence management processing efficiency is obviously improved. In addition, based on the certainty of the transaction execution result, the directed acyclic graph DAG does not need to be generated in the whole transaction scheduling and execution process, the occupation of extra bandwidth is avoided, the cost and the limitation of transaction concurrent scheduling are reduced, and the transaction concurrent processing efficiency is obviously improved.
In order to more clearly illustrate the implementation process of the deterministic transaction concurrent scheduling method of the block chain of the present application, a specific embodiment in practical application is described below. Fig. 3 is a flowchart of a specific deterministic transaction concurrent scheduling method for a blockchain according to an embodiment of the present disclosure, and fig. 4 is a schematic diagram of a principle of the specific deterministic transaction concurrent scheduling method for a blockchain according to an embodiment of the present disclosure. The method is realized based on a novel block output process of pre-sequencing transaction.
As shown in fig. 3, the method comprises the steps of:
step S301, a batch of pre-ordered transactions are pre-executed in parallel, and the result is written back to the corresponding transaction.
In this step, the node first receives a batch of pre-ordered transactions, then the node starts a scheduling instance, executes the ordered transactions in parallel, and writes back the processing results such as read-write sets and the like to the transactions.
Referring to the example shown in FIG. 4, for N transactions after sorting: transaction 1 to transaction N (hereinafter Tx 1-TxN), initiating a scheduling instance to execute the transactions concurrently and write the read-write sets of each transaction back to the corresponding transaction, e.g., write Tx1 read-write set to transaction Tx1, and so on write TxN read-write set to transaction TxN
Step S302, conflict detection is carried out on transaction execution results in sequence, if transaction conflict occurs, the previous transaction conflict-free package is used for subsequent block consensus processing, simultaneously Snapshot is generated and used for subsequent transaction conflict detection, a new scheduling instance is started, parallel scheduling is carried out again from conflict transaction, and the steps are repeated until all transaction scheduling is completed.
In this step, when the node starts one scheduling instance in step S301, the node starts one coroutine, and performs conflict detection on the transaction execution results in sequence, where if the current transaction is not executed, it is necessary to wait for all transactions to be executed and perform conflict detection determination after returning the execution results, and if a transaction conflict occurs, the batch of conflict-free transactions are packaged for subsequent block-out consensus processing; meanwhile, a snapshot is generated for detecting subsequent transaction conflict: as a benchmark for subsequent transaction execution; further, the node starts a new scheduling instance, and schedules the subsequent transactions again in parallel from the conflict transaction and repeats the steps until all transactions are scheduled.
Continuing with the example shown in fig. 4, if a conflict transaction Tx5 is detected, bundling the conflict-free transactions Tx1-Tx4 for subsequent block consensus processing and generating Snapshot for subsequent conflict detection, then starting a new scheduling instance, starting from the conflict transaction Tx5, scheduling Tx5 subsequent transactions in parallel, and repeating step 1, where repeating step 1 refers to repeating the steps of sequentially performing conflict detection on transaction execution results in this step, and if a transaction conflict occurs, bundling the previous conflict-free transaction for subsequent block consensus processing and simultaneously generating Snapshot for subsequent transaction conflict detection and starting a new scheduling instance. Further, the next conflicting transaction after Tx5 is detected and a new round of parallel scheduling is performed, and by doing so until all transaction scheduling is completed, it is detected that the last transaction TxN is currently scheduled to be completed.
In order to implement the foregoing embodiment, the present application further provides a deterministic transaction concurrent scheduling system for a blockchain, and fig. 5 is a schematic structural diagram of the deterministic transaction concurrent scheduling system for a blockchain according to the embodiment of the present application, as shown in fig. 5, the system includes a pre-execution module 100, a conflict detection module 200, a generation module 300, a start module 400, and a repeat module 500.
The pre-execution module 100 is configured to obtain multiple transactions to be scheduled, pre-sequence the multiple transactions, start a scheduling instance, and pre-execute the sequenced multiple transactions in parallel.
And the conflict detection module 200 is configured to write the execution result of each transaction into the corresponding transaction, start a coroutine for conflict detection, and sequentially perform conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions.
The generating module 300 is configured to, when a conflict transaction is detected, package conflict-free transactions before the conflict transaction, and generate a Snapshot tool Snapshot for performing conflict detection on subsequent transactions.
The starting module 400 is used for starting a new scheduling instance, and taking the conflict transaction as a starting point to re-schedule the transaction after the conflict transaction in parallel.
A repeating module 500, configured to control the conflict detecting module 200, the generating module 300, and the starting module 400 to repeatedly execute their own functions until all of the multiple transactions are scheduled to be completed.
Optionally, in an embodiment of the present application, the pre-execution module 100 is specifically configured to: a schedule for conflict detection is initiated while concurrently pre-executing the sequenced transactions.
Optionally, in an embodiment of the present application, the conflict detection module 200 is specifically configured to: sequentially detecting whether each transaction is executed or not according to the sequence; if the current transaction is executed, performing conflict detection on the execution result of the current transaction; and if the current transaction is not executed, waiting for all transactions to be executed and returning an execution result, and then performing conflict detection and judgment.
Optionally, in an embodiment of the present application, the generating module 300 is further configured to: and performing block consensus processing according to all conflict-free transactions in the packaged current batch.
Optionally, in an embodiment of the present application, the execution result of the transaction includes: the read set and the write set generated after the transaction is executed, and the conflict detection module 200 is further configured to: and writing the read set and the write set back to the corresponding transaction.
It should be noted that the foregoing explanation of the embodiment of the deterministic transaction concurrent scheduling method for a block chain is also applicable to the system of the embodiment, and the implementation principle is similar, and is not described herein again.
To sum up, the deterministic transaction concurrency scheduling system for the block chain in the embodiment of the present application can perform deterministic concurrency scheduling on transactions and perform dependency management while executing transactions based on pre-ordered transactions, that is, nodes perform parallel pre-execution and parallel dependency management on ordered transactions. Under the condition of no conflict, the efficiency of the transaction execution result conflict detection and the dependency management processing of the system is close to the efficiency of only carrying out the conflict detection, so that the efficiency of the dependency management processing is obviously improved. Moreover, the system does not need to generate a directed acyclic graph DAG in the whole transaction scheduling and executing process based on the certainty of the transaction executing result, so that extra bandwidth occupation is avoided, the cost and the limitation of transaction concurrent scheduling are reduced, and the transaction concurrent processing efficiency is remarkably improved.
To achieve the above embodiments, the present application further proposes a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the deterministic transaction concurrency scheduling method for blockchains as described in any of the above embodiments.
In the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the application. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Moreover, various embodiments or examples and features of various embodiments or examples described in this specification can be combined and combined by one skilled in the art without being mutually inconsistent.
Furthermore, the terms "first", "second" and "first" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or to implicitly indicate the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present application, "plurality" means at least two, e.g., two, three, etc., unless explicitly specified otherwise.
Any process or method descriptions in flow charts or otherwise described herein may be understood as representing modules, segments, or portions of code which include one or more executable instructions for implementing steps of a custom logic function or process, and alternate implementations are included within the scope of the preferred embodiment of the present application in which functions may be executed out of order from that shown or discussed, including substantially concurrently or in reverse order, depending on the functionality involved, as would be understood by those reasonably skilled in the art of the present application.
The logic and/or steps represented in the flowcharts or otherwise described herein, such as an ordered listing of executable instructions that can be considered to implement logical functions, can be embodied in any computer-readable medium for use by or in connection with an instruction execution system, apparatus, or device, such as a computer-based system, processor-containing system, or other system that can fetch the instructions from the instruction execution system, apparatus, or device and execute the instructions. For the purposes of this description, a "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transport the program for use by or in connection with the instruction execution system, apparatus, or device. More specific examples (a non-exhaustive list) of the computer-readable medium would include the following: an electrical connection (electronic device) having one or more wires, a portable computer diskette (magnetic device), a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber device, and a portable compact disc read-only memory (CDROM). Further, the computer-readable medium could even be paper or another suitable medium upon which the program is printed, as the program can be electronically captured, via for instance optical scanning of the paper or other medium, then compiled, interpreted or otherwise processed in a suitable manner if necessary, and then stored in a computer memory.
It should be understood that portions of the present application may be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, various steps or methods may be implemented in software or firmware stored in a memory and executed by a suitable instruction execution system. If implemented in hardware, as in another embodiment, any one or combination of the following techniques, which are well known in the art, may be used: a discrete logic circuit having a logic gate circuit for implementing a logic function on a data signal, an application specific integrated circuit having an appropriate combinational logic gate circuit, a Programmable Gate Array (PGA), a Field Programmable Gate Array (FPGA), or the like.
It will be understood by those skilled in the art that all or part of the steps carried by the method for implementing the above embodiments may be implemented by hardware related to instructions of a program, which may be stored in a computer readable storage medium, and when the program is executed, the program includes one or a combination of the steps of the method embodiments.
In addition, functional units in the embodiments of the present application may be integrated into one processing module, or each unit may exist alone physically, or two or more units are integrated into one module. The integrated module can be realized in a hardware mode, and can also be realized in a software functional module mode. The integrated module, if implemented in the form of a software functional module and sold or used as a stand-alone product, may also be stored in a computer readable storage medium.
The storage medium mentioned above may be a read-only memory, a magnetic or optical disk, etc. While embodiments of the present application have been shown and described above, it will be understood that the above embodiments are exemplary and should not be construed as limiting the present application and that changes, modifications, substitutions and alterations in the above embodiments may be made by those of ordinary skill in the art within the scope of the present application.

Claims (6)

1. A method for deterministic transaction concurrent scheduling of a block chain, comprising the steps of:
s101, acquiring a plurality of transactions to be scheduled, pre-sequencing the transactions, starting a scheduling instance, and pre-executing the sequenced transactions in parallel;
s102, writing the execution result of each transaction into the corresponding transaction, starting a coroutine for conflict detection, and sequentially carrying out conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions;
s103, under the condition that conflict transactions are detected, packaging conflict-free transactions before the conflict transactions, and generating a Snapshot tool Snapshot to perform conflict detection on subsequent transactions;
s104, starting a new scheduling instance, and taking the conflict transaction as a starting point to re-schedule the transaction after the conflict transaction in parallel;
s105, repeatedly executing S102 to S104 until all the plurality of transactions are scheduled;
after the packaging of the conflict-free transactions before the conflict transaction, further comprising:
performing block-out consensus processing according to all conflict-free transactions in a packaged current batch, wherein consensus information is generated according to all conflict-free transactions in the packaged current batch, the consensus information is added into a block, the block is broadcasted to other nodes in the block-out process, and whether the block achieves consensus or not is determined according to the consensus information contained in the block;
and starting a coroutine for conflict detection while starting a scheduling instance and pre-executing a plurality of ordered transactions in parallel.
2. The scheduling method of claim 1, wherein the performing conflict detection for the execution result of each transaction in sequence according to the sequence of the ordered transactions comprises:
sequentially detecting whether each transaction is executed or not according to the sequence;
if the current transaction is executed, performing conflict detection on the execution result of the current transaction;
and if the current transaction is not executed, performing conflict detection after waiting for all transactions to be executed and returning execution results.
3. The scheduling method of claim 1 wherein the result of the execution of the transaction comprises: the method comprises the following steps of generating a read set and a write set after executing the transaction, and writing an execution result of each transaction into the corresponding transaction, wherein the steps comprise:
and writing the read set and the write set back to corresponding transactions.
4. A system for deterministic transaction concurrency scheduling for blockchains, comprising:
the system comprises a pre-execution module, a scheduling instance and a scheduling execution module, wherein the pre-execution module is used for acquiring a plurality of transactions to be scheduled, pre-sequencing the transactions, starting the scheduling instance and pre-executing the sequenced transactions in parallel;
the conflict detection module is used for writing the execution result of each transaction into the corresponding transaction, starting a coroutine for conflict detection, and sequentially performing conflict detection on the execution result of each transaction according to the sequence of the sequenced transactions;
the generating module is used for packaging conflict-free transactions before the conflict transactions under the condition that the conflict transactions are detected, and generating a Snapshot tool Snapshot to carry out conflict detection on subsequent transactions;
the starting module is used for starting a new scheduling instance and taking the conflict transaction as a starting point to re-schedule the transaction after the conflict transaction in parallel;
the repeating module is used for controlling the conflict detection module, the generating module and the starting module to repeatedly execute the functions of the repeating module until all the transactions are scheduled;
the pre-execution module is specifically configured to:
starting a scheduling instance, and starting a coroutine for conflict detection while pre-executing the sequenced transactions in parallel;
the generation module is further configured to:
and performing block consensus processing according to all conflict-free transactions in the packaged current batch, wherein one scheduling instance is started, and one protocol for conflict detection is started while a plurality of sequenced transactions are pre-executed in parallel.
5. The system of claim 4, wherein the collision detection module is specifically configured to:
sequentially detecting whether each transaction is executed or not according to the sequence;
if the current transaction is executed, performing conflict detection on the execution result of the current transaction;
and if the current transaction is not completely executed, performing conflict detection after waiting for the completion of the execution of all transactions and returning execution results.
6. A non-transitory computer-readable storage medium having stored thereon a computer program, wherein the computer program, when executed by a processor, implements the deterministic transaction concurrent scheduling method of a blockchain according to any one of claims 1 to 3.
CN202210453605.0A 2022-04-27 2022-04-27 Method and system for deterministic transaction concurrent scheduling of block chains Active CN114564412B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210453605.0A CN114564412B (en) 2022-04-27 2022-04-27 Method and system for deterministic transaction concurrent scheduling of block chains

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210453605.0A CN114564412B (en) 2022-04-27 2022-04-27 Method and system for deterministic transaction concurrent scheduling of block chains

Publications (2)

Publication Number Publication Date
CN114564412A CN114564412A (en) 2022-05-31
CN114564412B true CN114564412B (en) 2022-07-22

Family

ID=81720985

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210453605.0A Active CN114564412B (en) 2022-04-27 2022-04-27 Method and system for deterministic transaction concurrent scheduling of block chains

Country Status (1)

Country Link
CN (1) CN114564412B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116382815B (en) * 2023-06-05 2023-10-10 安徽中科晶格技术有限公司 Contract parallelization method based on DAG model

Family Cites Families (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9710532B2 (en) * 2014-08-21 2017-07-18 Codership Oy Method for avoiding conflicts in database cluster
CN109508337A (en) * 2018-11-12 2019-03-22 杭州秘猿科技有限公司 A kind of transaction is parallel to execute method, apparatus, electronic equipment and system
CN110555773B (en) * 2019-08-09 2021-04-20 腾讯科技(深圳)有限公司 Contract conflict detection method and device, readable storage medium and computer equipment
CN111882435B (en) * 2020-03-12 2023-01-31 支付宝(杭州)信息技术有限公司 Method and device for executing transaction in block chain
CN113077344B (en) * 2021-04-15 2023-06-30 恒生电子股份有限公司 Block chain-based transaction method, device, electronic equipment and storage medium
CN113220745B (en) * 2021-05-19 2024-02-09 中国科学技术大学 Transaction processing method and device based on blockchain and electronic equipment
CN113743940B (en) * 2021-11-04 2022-08-12 支付宝(杭州)信息技术有限公司 Method for executing transaction in block chain, main node and slave node
CN114253920A (en) * 2021-12-07 2022-03-29 中信银行股份有限公司 Transaction reordering method, device, equipment and readable storage medium

Also Published As

Publication number Publication date
CN114564412A (en) 2022-05-31

Similar Documents

Publication Publication Date Title
US20190324772A1 (en) Method and device for processing smart contracts
CN108595157B (en) Block chain data processing method, device, equipment and storage medium
CN112150163A (en) Block chain contract transaction parallel execution method and device
CN104881494B (en) The methods, devices and systems synchronous with Redis server progress data
US9417935B2 (en) Many-core process scheduling to maximize cache usage
CN101005486B (en) Resource access control method and system
CN110517140B (en) Block chain intelligent contract transaction concurrent execution method
CN110728578A (en) Parallel execution method, system and storage medium for block chain transaction
JP7394211B2 (en) Methods, devices, equipment, and media for parallel execution of smart contracts
JP2004302706A (en) Program parallelization device, program parallelization method, and program parallelization program
US9063778B2 (en) Fair stateless model checking
US8869129B2 (en) Apparatus and method for scheduling instruction
CN110675255B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN114564412B (en) Method and system for deterministic transaction concurrent scheduling of block chains
CN110648124B (en) Method and apparatus for concurrently executing transactions in a blockchain
CA2433379A1 (en) Modulo scheduling of multiple instruction chains
CN109901818B (en) System and method for software architecture design
US9921951B2 (en) Optimizations for regression tracking and triaging in software testing
CN110825427B (en) Code management method, device, server and storage medium
CN112487092A (en) Intelligent contract calling method and device based on block chain
JP6077004B2 (en) Job scheduler for electromechanical systems for biological analysis
CN113867709B (en) Block chain intelligent contract read-write set construction method and device
CN110515833A (en) A kind of method of software test, equipment and readable medium
US20110022373A1 (en) Model checking of liveness property in a phase abstracted model
CN109240701A (en) A kind of instruction dependence analysis method towards predicated execution High Performance DSP

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
GR01 Patent grant
GR01 Patent grant