[go: up one dir, main page]

CN110706108B - Method and apparatus for concurrently executing transactions in a blockchain - Google Patents

Method and apparatus for concurrently executing transactions in a blockchain Download PDF

Info

Publication number
CN110706108B
CN110706108B CN201910939502.3A CN201910939502A CN110706108B CN 110706108 B CN110706108 B CN 110706108B CN 201910939502 A CN201910939502 A CN 201910939502A CN 110706108 B CN110706108 B CN 110706108B
Authority
CN
China
Prior art keywords
transaction
log
predetermined
order
transactions
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
CN201910939502.3A
Other languages
Chinese (zh)
Other versions
CN110706108A (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.)
Ant Blockchain Technology Shanghai Co Ltd
Original Assignee
Alipay Hangzhou Information 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 Alipay Hangzhou Information Technology Co Ltd filed Critical Alipay Hangzhou Information Technology Co Ltd
Priority to CN201910939502.3A priority Critical patent/CN110706108B/en
Publication of CN110706108A publication Critical patent/CN110706108A/en
Application granted granted Critical
Publication of CN110706108B publication Critical patent/CN110706108B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • 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
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/08Payment architectures
    • G06Q20/10Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems
    • G06Q20/102Bill distribution or payments
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/389Keeping log of transactions for guaranteeing non-repudiation of a transaction
    • 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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/40Authorisation, e.g. identification of payer or payee, verification of customer or shop credentials; Review and approval of payers, e.g. check credit lines or negative lists
    • G06Q20/405Establishing or using transaction specific rules

Landscapes

  • Business, Economics & Management (AREA)
  • Accounting & Taxation (AREA)
  • Finance (AREA)
  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Strategic Management (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Economics (AREA)
  • Development Economics (AREA)
  • Marketing (AREA)
  • Technology Law (AREA)
  • Computer Security & Cryptography (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the specification provides a method and a device for executing a plurality of transactions in a blockchain concurrently, wherein the plurality of transactions have a preset submission sequence, the plurality of transactions comprise a first transaction, the sequence in the first transaction comprises at least one preset operation, the preset operation corresponds to the first operation when a preset condition is met, and the current submission sequence of the first transaction is located at a position after a first bit, and the method is executed at a first node in the blockchain and comprises the following steps: when a first predetermined operation of the at least one predetermined operation is executed, recording a first log in a first storage space corresponding to a first transaction, and recording a recording order of the first log in a log recorded in the first storage space, the first log corresponding to the first operation of the first predetermined operation, in the first storage space; and skipping the first predetermined operation to continue performing operations in the first transaction that follow the first predetermined operation.

Description

Method and apparatus for concurrently executing transactions in a blockchain
Technical Field
The embodiments of the present disclosure relate to the field of blockchain technologies, and more particularly, to a method and an apparatus for concurrently executing transactions in a blockchain.
Background
The blockchain technology is a brand-new distributed infrastructure and computing paradigm that is built on a peer-to-peer (P2P) network, utilizes a chained data structure to verify and store data, utilizes a distributed node consensus algorithm to generate and update data, utilizes cryptography to ensure the security of data transmission and access, and utilizes an intelligent contract composed of automated script codes to program and operate data. The block chain technology is also called as distributed book technology, is decentralized distributed database technology and is characterized by decentralized, transparent disclosure, no tampering and trusty. Each data of the block chain is broadcasted to the block chain nodes of the whole network, and each whole node has the full amount of consistent data. The nodes in the blockchain perform services such as transfer and data storage by sending transactions, the accounting nodes in the blockchain collect the transactions in the blockchain in the transaction pool, execute the transactions, and package the transactions into blocks and spread the transactions into the blockchain after executing the transactions. The block sent from the accounting node is verified by a verification node in the block chain, and after the verification is passed, each node executes each transaction included in the block when receiving the block.
In order to ensure the data consistency of each node, when executing multiple transactions in a block, the submission order of the multiple transactions in each node needs to be consistent, so that a consistent execution result can be obtained. Therefore, in the prior art, before executing a transaction, an accounting node numbers a plurality of transactions to be executed according to a predetermined rule, and sequentially executes the plurality of transactions according to the numbering order, that is, sequentially submits the plurality of transactions, and after receiving the block, other nodes also sequentially execute and submit the plurality of transactions according to the transaction numbering order. However, the multiple transactions are not necessarily all interdependent, and in the absence of a dependency between two transactions, concurrent execution of the two transactions does not affect the final result. In the process of concurrently executing a transaction, if a predetermined operation such as a transfer is included in the transaction, whether the predetermined operation can be successfully executed is determined based on a predetermined condition, for example, whether the balance is sufficient, in which case if the transfer is previously performed in a non-submission stage of the transaction, and in a submission stage, if the balance is changed, the transfer is to be newly performed, and generally the possibility of a change in the balance of the account is large, and therefore, if the transfer is previously performed in the concurrent execution, the possibility of a transaction redo at the time of the submission of the transaction is large. And the operation of inquiring account information is also included before the transfer operation, the operation of inquiring the account information takes longer time, and if the transaction is completely executed in series to avoid the transaction redo caused by the transfer operation, the transaction execution speed is slow.
For transfer transactions, the prior art includes such a method that a transfer party account and a transfer party account are designated by utilizing display in a transaction request, the transactions to be processed are divided into a plurality of groups, and the transactions among different groups do not relate to the same account, so that component transactions can be executed in parallel, and the transactions in the groups can only be executed in series. However, when there is a hotspot account, a large number of transactions can be executed serially, and when the transfer is performed by a contract calling method, the transfer-out party account and the transfer-in party account cannot be obtained in advance, and the method is not applicable any more.
Accordingly, there is a need for a more efficient method of performing multiple transfer transactions concurrently in a blockchain.
Disclosure of Invention
Embodiments of the present disclosure are directed to a method for performing transactions concurrently in a blockchain, which is more efficient and solves the deficiencies of the prior art.
To achieve the above object, one aspect of the present specification provides a method for concurrently executing multiple transactions in a blockchain, where the multiple transactions have a predetermined submission order, including a first transaction, the order in the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and a current submission order of the first transaction is located at a position after a first bit, and the method is executed at a first node in the blockchain, and includes:
when a first predetermined operation of the at least one predetermined operation is executed, recording a first log in a first storage space corresponding to a first transaction, and recording a recording order of the first log in a log recorded in the first storage space, the first log corresponding to the first operation of the first predetermined operation, in the first storage space; and
skipping the first predetermined operation continues to perform operations in the first transaction that follow the first predetermined operation.
In one embodiment, a first operation of the first scheduled operations comprises a write operation on a first variable, and a read operation on the first variable is included after the first scheduled operation in the first transaction, and the method further comprises, upon execution of the read operation, in the event that it is determined that a first log is recorded in the first storage space, marking in a second storage space corresponding to the first transaction to indicate that the first transaction needs to be re-executed in its commit phase, wherein a commit order of the first transaction in the commit phase is first.
In one embodiment, a first operation of the first scheduled operations comprises a write operation on a first variable, and a read operation on the first variable is included after the first scheduled operation in the first transaction, and the method further comprises, upon execution of the read operation, in a case where it is determined that a first log is recorded in the first storage space, waiting until the first transaction reaches a commit stage, and then stopping waiting to re-execute the first transaction in the commit stage of the first transaction, wherein a commit order of the first transaction in the commit stage is first.
In one embodiment, a transaction execution window is preset in the first node, and the transactions are transactions arranged in a submission order currently included in the transaction execution window, where the first transaction is currently located at a position after a first position in the transaction execution window.
In one embodiment, the at least one predetermined operation includes at least one type of predetermined operation.
Another aspect of the present specification provides a method for concurrently executing multiple transactions in a blockchain, where the multiple transactions have a predetermined commit order, including a first transaction, the first transaction includes at least one predetermined operation in an order, the predetermined operation corresponds to a first operation when a predetermined condition is satisfied, and a current commit order of the first transaction is located at a first position, the first transaction has been previously executed before the commit order changes to the first position, and at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log are currently recorded in a first storage space corresponding to the first transaction, the log corresponds to the first operation in the corresponding predetermined operation, and the method is executed at a first node in the blockchain, and includes:
acquiring the at least one log and the recording sequence of the at least one log;
on the basis of the recording sequence of the at least one log, sequentially judging whether a preset condition corresponding to the log is met or not for each log;
and in the case that the preset condition corresponding to the log is judged not to be satisfied, re-executing the first transaction and submitting the first transaction.
In one embodiment, the method further includes, in a case where it is determined that each of the predetermined conditions corresponding to the at least one log is satisfied, sequentially performing at least one first operation corresponding to the at least one log, based on a recording order of the at least one log, and submitting the first transaction.
In one embodiment, in the first transaction, the predetermined operation corresponds to a second operation if the predetermined condition is not satisfied, wherein, in the case where it is determined that the predetermined condition corresponding to the log is not satisfied, re-executing and submitting the first transaction includes, when the predetermined operation corresponding to the log is re-executed, executing the second operation corresponding to the predetermined operation.
In one embodiment, a transaction execution window is preset in the first node, and the transactions are transactions arranged in a submission order currently included in the transaction execution window, where the first transaction is currently located at a first position in the transaction execution window.
In one embodiment, the first predetermined operation is a transfer operation from the first account to a second account, and the first predetermined operation corresponds to an operation of transferring a first amount from the first account to the second account when a predetermined condition is satisfied.
In one embodiment, the predetermined condition is that the balance of the first account is equal to or greater than the first amount.
Another aspect of the present specification provides an apparatus for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined submission order, including a first transaction, the order in the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and a current submission order of the first transaction is located at a position after a first bit, the apparatus is disposed in a first node in the blockchain, and includes:
a recording unit configured to, when a first predetermined operation out of the at least one predetermined operation is performed, record a first log in a first storage space corresponding to a first transaction, and record, in the first storage space, a recording order of the first log in logs already recorded in the first storage space, the first log corresponding to the first operation out of the first predetermined operation; and
and the execution unit is configured to skip the first predetermined operation and continue to execute the operation in the first transaction after the first predetermined operation.
In one embodiment, a first operation of the first predetermined operations includes a write operation on a first variable, and a read operation on the first variable is included after the first predetermined operation in the first transaction, and the apparatus further includes a marking unit configured to, when the read operation is executed, mark in a second storage space corresponding to the first transaction in a case where it is determined that a first log is recorded in the first storage space to indicate that the first transaction needs to be re-executed in a commit stage thereof, wherein a commit order of the first transaction in the commit stage is first.
In one embodiment, a first operation of the first predetermined operations includes a write operation on a first variable, and a read operation on the first variable is included after the first predetermined operation in the first transaction, and the apparatus further includes a waiting unit configured to, when executing to the read operation, wait until the first transaction reaches a commit stage and then stop waiting to re-execute the first transaction in the commit stage of the first transaction, in a case where it is determined that a first log is recorded in the first storage space, wherein a commit order of the first transaction in the commit stage is first.
Another aspect of the present specification provides an apparatus for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined commit order including a first transaction, the first transaction includes at least one predetermined operation in an order, the predetermined operation corresponds to a first operation when a predetermined condition is satisfied, and a current commit order of the first transaction is located at a first position, the first transaction has been previously executed before the commit order changes to the first position, and at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log are currently recorded in a first storage space corresponding to the first transaction, the log corresponds to the first operation in the corresponding predetermined operation, the apparatus is disposed in a first node in the blockchain, and includes:
an acquisition unit configured to acquire the at least one log and a recording order of the at least one log;
a judging unit configured to judge, for each log in turn, whether a predetermined condition corresponding to the log is satisfied based on a recording order of the at least one log;
and the re-execution unit is configured to re-execute the first transaction and submit the first transaction in the case that the preset condition corresponding to the log is judged not to be satisfied.
In one embodiment, the apparatus further includes a submitting unit configured to, in a case where it is determined that each of the predetermined conditions corresponding to the at least one log is satisfied, sequentially perform at least one first operation corresponding to the at least one log, based on a recording order of the at least one log, and submit the first transaction.
In one embodiment, in the first transaction, the predetermined operation corresponds to a second operation if the predetermined condition is not satisfied, wherein in a case where it is determined that the predetermined condition corresponding to the log is not satisfied, the re-execution unit is further configured to, when the predetermined operation corresponding to the log is re-executed, execute the second operation corresponding to the predetermined operation.
Another aspect of the present specification provides a computer readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform any one of the above methods.
Another aspect of the present specification provides a computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor implements any one of the above methods when executing the executable code.
According to the scheme for concurrently executing the transaction, aiming at the scheduled operation comprising the condition judgment, the scheduled operation is not executed in the non-submission stage, only the record is carried out in the buffer area, and the scheduled operation is executed in the submission stage by judging whether the predetermined condition is met, so that compared with the scheme for previously executing the scheduled operation in the non-submission stage, the possible larger time cost caused by the re-execution of the transaction in the submission stage can be avoided, and meanwhile, other operations except the scheduled operation included in the transaction are executed in advance when the transaction is concurrently executed, and the efficiency for concurrently executing the transaction is integrally accelerated.
Drawings
The embodiments of the present specification may be made more clear by describing the embodiments with reference to the attached drawings:
FIG. 1 illustrates a block chain system in accordance with an embodiment of the present description;
FIG. 2 illustrates a flow diagram of a method of concurrently executing multiple transactions in a blockchain in accordance with an embodiment of the present description;
FIG. 3 is a diagram illustrating a first storage space in a first buffer;
FIG. 4 shows a schematic diagram of a transaction execution window in accordance with an embodiment of the present description;
FIG. 5 is a diagram illustrating a second storage space in a second buffer;
FIG. 6 illustrates a method of concurrently executing multiple transactions in a blockchain according to one embodiment of the present description;
FIG. 7 illustrates an apparatus 700 for concurrently performing multiple transactions in a blockchain according to one embodiment of the present description;
fig. 8 illustrates an apparatus 800 for concurrently performing multiple transactions in a blockchain according to one embodiment of the present description.
Detailed Description
The embodiments of the present specification will be described below with reference to the accompanying drawings.
Fig. 1 shows a block chain system according to an embodiment of the present disclosure. As shown in fig. 1, the system includes a plurality of nodes (6 nodes are schematically shown in the figure) forming a block chain, and the nodes are connected in pairs, wherein the nodes include, for example, a node 11, a node 12, and a node 13. As known to those skilled in the art, in a blockchain, some nodes collect multiple transactions in the blockchain into a transaction pool and compete for billing rights. For example, node 11 in the figure becomes the accounting node by acquiring accounting rights. Node 11, after becoming an accounting node, performs multiple transactions in its transaction pool and packages the multiple transactions into blocks for transmission to other nodes, such as node 12. Node 12 will authenticate the block and similarly perform transactions in the block. After a predetermined number of nodes verify the block, i.e., the block is known to be known, other nodes in the block chain (e.g., node 13) will not need to continue verifying the block, but will perform transactions directly in the block to update the local related data.
When the plurality of transactions are executed by each node, a predetermined number of transactions may be concurrently executed at one time in order to increase the execution speed. The concurrently executed transactions may involve the calculation of multiple variables, in case the same variable is not involved in both transactions, the execution order may not affect the final calculation result, and in case the same variable is involved in both transactions, the execution order may affect the final calculation result, e.g. the commit order of the first transaction precedes the second transaction, in which case the value of the first variable read by the second transaction is the wrong value, if the first transaction writes the first variable after the reading of the first variable was performed in the second transaction, the second transaction needs to be re-executed.
The concurrently executed transaction may include a predetermined action such as a transfer, the success of which depends on whether the transferred account balance is sufficient, e.g., if the transferred account balance is less than the transfer amount, the transfer will not be successfully executed. That is, whether the predetermined operation can be successfully performed is based on whether a predetermined condition is satisfied. Generally, before a transfer operation is performed, an account status is firstly acquired, after a transfer authority is determined according to the account status, the transfer operation is performed, wherein the transfer operation comprises the steps of acquiring a balance, determining whether the balance is sufficient, and modifying the balance of a corresponding account under the condition that the balance is sufficient. The account state acquisition time is long, the transfer operation time is short, if the two steps are fixedly combined together and executed concurrently, the possibility of transaction redoing is high due to high possibility of balance change, and finally, the transfer is completely and serially performed. If the account state is separated from the account state, the account state is allowed to be acquired in parallel, and the transfer operation is performed when the account state is submitted, so that the time-consuming operation of acquiring the account state is completed when the account state is executed in parallel, and meanwhile, the transfer operation is performed only when the account state is submitted, the transaction redo caused by balance change is avoided, and the execution of the transfer operation can be accelerated. Therefore, in the solution of the present embodiment, for the above-mentioned predetermined operation, in the non-submission stage of the transaction, the predetermined operation is not executed, but only the record of the predetermined operation is made in the log, and the other operations in the transaction are executed continuously after the record, and in the submission stage of the transaction, it is determined whether the predetermined operation can be successfully executed based on the record, and in the determination that the predetermined operation can be successfully executed, the predetermined operation is executed and the transaction is submitted, and in the determination that the predetermined operation cannot be successfully executed, the transaction is re-executed. Therefore, the time cost for executing the predetermined operation in advance is avoided while the transaction is executed concurrently, and the transaction executing speed is further accelerated.
Fig. 2 is a flowchart illustrating a method for concurrently executing multiple transactions in a blockchain, where the multiple transactions have a predetermined submission order, including a first transaction, the order in the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and a current submission order of the first transaction is located at a position after a first position, and the method is executed at a first node in the blockchain, and includes:
step S202, when a first predetermined operation in the at least one predetermined operation is executed, recording a first log in a first storage space corresponding to a first transaction and a recording sequence of the first log in logs recorded in the first storage space, wherein the first log corresponds to the first operation in the first predetermined operation; and
and step S204, skipping the first predetermined operation and continuing to execute the operation in the first transaction after the first predetermined operation.
First, in step S202, when a first predetermined operation out of the at least one predetermined operation is performed, a first log corresponding to the first operation out of the first predetermined operation is recorded in a first storage space corresponding to a first transaction, and a recording order of the first log in logs already recorded in the first storage space.
As described above with reference to fig. 1, the method is performed at a node in the blockchain. The node performs commit on the associated transactions either while packaging the block or after receiving the newly generated block. For example, thousands of transactions may be included in a block, and the thousands may involve hundreds of variables, where multiple transactions may access different variables, or multiple transactions may access the same variable. In the prior art, in the accounting node, the respective transaction numbers of a plurality of transactions to be packed into one block have been determined according to predetermined rules, and the order of the transaction numbers indicates the execution order and the submission order of the transactions. In the embodiment of the present specification, in order to make the final calculation result the same as the serial calculation result in the prior art, a predetermined submission order is reserved for the multiple transactions in the block, for example, the number order of each transaction is used as its respective submission order, so that the multiple transactions can be executed concurrently, and the multiple transactions are submitted sequentially according to the number order of each transaction.
The predetermined operation is an operation that, when starting execution, needs to first determine whether a predetermined condition is satisfied, and then execute a corresponding operation according to the result of the determination. For example, the transfer operation is one of the predetermined operations. Before the transfer operation of the transaction is executed, account information is generally acquired first, whether the transfer right is available or not is determined, after the transfer right is determined to be available, the transfer operation is carried out, for example, the transfer operation comprises a first operation of transferring a first amount from a first account to a second account, generally, whether the balance of the first account is greater than or equal to the first amount is judged first (namely, whether a preset condition is met or not), and in the case that the balance of the first account is greater than or equal to the first amount, the first operation is executed. The operation also comprises a second operation of returning transfer failure information to the first account, for example, and the second operation is executed when the balance of the first account is judged to be less than the first amount. It is to be understood that the above description of the transfer operation is only illustrative and not restrictive, for example, the predetermined condition is not limited to the above predetermined condition, and may be set to, for example: the balance of the first account is equal to or greater than the first amount, and the balance of the second account after the transfer is less than the second amount, for example, the second operation is not limited to returning the transfer failure information, and it may be set, for example, to transfer a third amount from the first account to the second account, where the third amount is less than the first amount, for example, the first amount is 100 yuan, and the third amount is 1 yuan.
It is to be understood that the predetermined operation is not limited to the transfer operation, but may be any operation that performs a corresponding operation based on a predetermined condition, for example, the predetermined operation is a counting operation within a predetermined range, the counting operation adds 1 to the total count in a case where the total count is equal to or less than a predetermined value, and returns to the end of the count in a case where the total count is greater than the predetermined value. That is, in this scenario, the predetermined condition is that the total number of counts is equal to or less than a predetermined value, and in the case where the condition is satisfied, a first operation is performed, that is, 1 is added to the total number of counts, and in the case where the condition is not satisfied, a second operation is performed, that is, the end of counting is returned. The scheme of the embodiment of the present specification will be schematically described below by taking a transfer operation as an example.
For example, the at least one predetermined operation included in the first transaction includes a transfer operation, such as transferring 100 units to account B when the balance of account a is equal to or greater than 100 units, and returning "transfer failure" information to account a when the balance of account a is less than 100 units.
When a first transaction is executed in the process of concurrently executing transactions, in the case that the first transaction is in a non-submission stage, that is, the first transaction is not currently a transaction in which the first transaction is first in the submission order, when the transfer operation is executed, a determination as to whether a predetermined condition is satisfied may be performed first, but a log (for example, a first log) corresponding to the transfer operation is directly recorded in a first storage space corresponding to the first transaction in a buffer corresponding to the first transaction, an operation of transferring 100 elements from the account a to the account B (that is, the first operation) is directly recorded in the first log, and "transfer success" is notified to the transaction, and then the transfer operation in the first transaction is skipped, and the subsequent operations are continuously executed. That is, in this process, an actual transfer operation is not performed in advance, but only a log corresponding to the first operation is recorded. For at least one predetermined operation in the first transaction, for example, at least one log may be recorded successively in consecutive addresses sequentially arranged in the first storage space, and the at least one log corresponds to the at least one predetermined operation, so that the recording order of the at least one log is represented by the recording order of the addresses.
Fig. 3 schematically shows a schematic diagram of a first storage space in a first buffer. As shown in FIG. 3, the first buffer includes three first storage spaces corresponding to transactions 3-5, respectively, wherein logs corresponding to the transactions are recorded: logs 31 to 34, logs 41 to 43 and logs 51 to 52. For example, if the first transaction is transaction 3, the corresponding first storage space is a block of storage space corresponding to transaction 3. The left side of the figure is marked with 1-4 as address marks which represent four continuous address spaces, and in each address space, the logs 31-34 are stored, so that the recording sequence of the logs 31-34 can be determined to be the logs 31-32-33-34 based on the sequence of the addresses. The first buffer area may be a buffer area in a shared memory or a buffer area allocated to only a single thread, depending on the specific manner of concurrently executing transactions. It is to be understood that, in the embodiments of the present specification, the recording order of the at least one log is not limited in this way, for example, while recording the at least one log, the recording time of each log may be recorded accordingly, so that the recording order of the at least one log is recorded by the recording time, and so on.
It is to be understood that the at least one predetermined operation included in the first transaction is not limited to all transfer operations, for example, different types of predetermined operations such as transfer operations, counting operations, function operation operations, and the like may be included in the first transaction at the same time, and the first predetermined operation is not limited to transfer operations, but may be any predetermined operation included in the first transaction.
In one embodiment, due to the large number of transactions, a transaction execution window may be set to slide among a plurality of transactions arranged in a commit order (or transaction number) so that the plurality of transactions in the transaction execution window may be concurrently executed in the blockchain node, and the transaction execution window may be set to slide one transaction backward every time one transaction is committed. FIG. 4 illustrates a schematic diagram of a transaction execution window according to an embodiment of the present description. As shown in fig. 4, the ten numbers 1 to 10 in the figure represent ten transactions numbered 1 to 10, respectively, and the transaction execution window may include, for example, 5 transactions. The transaction execution window may initially fall on transactions 1 through 5. After transaction 1 is submitted, the window moves one transaction back, falling on transactions 2 to 6, and likewise after transaction 2 is submitted, the window moves one more transaction back, falling on transactions 3 to 7 as shown in the figure. In the method of FIG. 2, the first transaction may be any one of transactions 4-7 of FIG. 4, i.e., it is the first transaction in the order of presentation from a plurality of transactions that are executed concurrently.
In step S204, the operations subsequent to the first predetermined operation in the first transaction are executed continuously by skipping the first predetermined operation.
That is, in the embodiment of the present specification, in the first transaction, operations other than the at least one predetermined operation are performed in advance, so that only the at least one predetermined operation can be performed in the commit stage, thereby saving the total execution time.
In one embodiment, for example, the first transaction includes the above-described transfer operation, and the first operation performed when the predetermined condition is satisfied is, for example, as described above, transferring 100 units from the account a to the account B, and assuming that the balance of the account a is the variable k1 and the balance of the account B is the variable k2, the first operation corresponds to reading an initial value of the variable k1, determining whether the initial value is equal to or greater than 100, in the case where the initial value is determined to be equal to or greater than 100, reducing the initial value by 100 to obtain a second value, writing the value of the variable k1 to the second value, and similarly operating the variable k 2. That is, the transfer operation, when actually performed, would include read and write processes to the variable k 1. In the case where a read operation for the variable k1 is also included after the transfer operation in the first transaction, if the read operation for the variable k1 is continued by skipping the transfer operation in the non-commit stage as described above, the value of k1 read here is not the value after the transfer operation is actually performed, and thus an erroneous value of k1 is read. Thus, in embodiments of the present description, in order to avoid misreading of the variable, in the event that a read operation on variable k1 is also included after the transfer operation in the first transaction, after executing the code to the read operation, in the event that it is determined that there is a first journal in the first memory space, a flag may be placed in the second memory space in the second buffer corresponding to the first transaction to indicate that the first transaction needs to be re-executed in its commit stage, where the commit order of the first transaction in its commit stage is first, for example as shown in fig. 4, where transaction 3 is at bit 1 of the transaction execution window, and thus transaction 3 is currently the commit stage. In one embodiment, where a read operation to variable k1 is also included after the transfer operation in the first transaction, after executing code to the read operation, in the event that it is determined that a first journal exists in the first memory space, a wait may be made until the wait is stopped after the first transaction reaches the commit phase to re-execute the first transaction at the commit phase of the first transaction. That is, here, similar to a read-write conflict detection, a "transfer operation" is considered as a "write operation" to the relevant account balance, and a "read balance operation" is considered as a "read operation" to the account balance, so that in a case where a read operation is also included after the write operation, that is, an access conflict occurs, and thus redo or wait is required. The second buffer may be a buffer in the shared memory or a buffer allocated to a single thread according to a specific manner of concurrently executing transactions.
In one embodiment, the method of FIG. 2 is performed by thread 1, which, after executing code to the read operation, marks in its assigned second memory space corresponding to the first transaction that the first transaction needs to be re-executed. For example, fig. 5 shows a schematic diagram of the second storage space in the second buffer. As shown in fig. 5, the numbers 1-5 in the lower part of the figure represent transaction numbers, each transaction corresponding to a second memory space, for example a bit corresponding to the respective transaction, which is initially 0, marked by modifying it to 1. For example, the first transaction is transaction 3 in fig. 5, and assuming that transaction 3 does not currently reach the commit stage, the second storage space corresponding to the first transaction is the bit in the second buffer corresponding to transaction 3. Thread 1 thus modifies the bit in the second buffer in figure 5 corresponding to transaction 3 to 1 to mark. Thread 1 may then either continue to execute the current first transaction or may obtain a new task for execution and, after execution is complete, determine whether transaction 3 is currently in the commit stage based on the indicia in the second memory space corresponding to transaction 3, if transaction 3 reaches the commit stage (i.e., is first in the window) due to the movement of the transaction execution window as shown in fig. 4, may re-execute the first transaction based on the indicia, and if not in the commit stage, thread 1 may obtain a new task and subsequently repeat the above steps. After thread 1 re-executes the first transaction, the flag in the second memory space may be restored to 0.
In one embodiment, thread 1 marks in a second buffer in the shared memory that a first transaction needs to be re-executed in a second storage space corresponding to the first transaction after executing code to the read operation, so that thread 1 may fetch a new task for execution, and other threads (e.g., thread 2) may determine whether the first transaction is currently in a commit phase after reading the mark in the second storage space corresponding to the first transaction, and if so, thread 2 may begin re-executing the first transaction, and if not, thread 2 may fetch a new task for execution.
In one embodiment, thread 1 may wait after executing code to the read operation, e.g., thread 1 may sleep to wait, thread 1 awaken after receiving a notification to thread 1 that the previous transaction to the first transaction was after commit, thereby determining that the first transaction is in a commit phase, or actively determine whether the first transaction is in a commit phase when thread 1 grabs a pending task, in which case re-execution of the first transaction may begin when thread 1 determines that the first transaction is in a commit phase.
Figure 6 illustrates a method of concurrently executing multiple transactions in a blockchain according to one embodiment of the present description, wherein the plurality of transactions have a predetermined submission order, including a first transaction in which the order includes at least one predetermined operation, the predetermined operation corresponding to the first operation if a predetermined condition is satisfied, and the current commit order of the first transaction is at the first place, the first transaction having been previously executed before the commit order changes to the first place, and currently recording at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log in a first storage space corresponding to the first transaction, the log corresponding to a first operation of respective predetermined operations, the method performed at a first node in a blockchain, comprising:
step S602, obtaining the at least one log and the recording sequence of the at least one log;
step S604, based on the recording sequence of at least one log, sequentially judging whether a preset condition corresponding to the log is met for each log;
step S606, in case that it is determined that the predetermined condition corresponding to the log is not satisfied, re-executing the first transaction and submitting the first transaction.
First, in step S602, the at least one log and a recording order of the at least one log are acquired.
In this method, a first transaction is in the commit phase, e.g., as shown in FIG. 4, the first transaction is, e.g., transaction 3 in FIG. 4, which is currently at position 1 of the transaction window, and thus is currently in the commit phase. Since at least one log corresponding to the at least one predetermined operation, respectively, and a recording order of the at least one log have been stored in the corresponding first storage space in fig. 3 by the method shown in fig. 2 in the non-commit stage of the first transaction, the step S602 may be started to be performed after the first transaction is changed from the non-commit stage to the commit stage. That is, the at least one log and the recording order thereof, for example, log 31-log 32-log 33-log 34, are obtained from the first storage space corresponding to the first transaction, the arrangement order of which represents the recording order thereof, and the first operation of the corresponding predetermined operations is recorded in each log, for example, log 34 corresponds to the transfer operation, which records 100 yuan transferred from account a to account B.
In one embodiment, after retrieving the at least one log and its recording order from the corresponding first storage space, the first storage space may be emptied for subsequent recording.
In step S604, it is determined whether a predetermined condition corresponding to the log is satisfied for each log in turn based on the recording order of the at least one log.
That is, the above determination is performed for each log in turn in the order of the log records 31 to 34. For example, after determining that the predetermined conditions are satisfied for all of the logs 31 to 33, the log 34 is determined, that is, whether the balance of the account a is greater than or equal to 100 yuan is determined, specifically, the value of the balance k1 of the account a is read, and it is determined whether the value of k1 minus 100 is greater than or equal to zero.
In step S606, in the case where it is judged that the predetermined condition corresponding to the log is not satisfied, the first transaction is re-executed and submitted.
In an example such as that shown in FIG. 3, the "log" may be any one of the logs 31-34, and the first transaction (i.e., transaction 3 in FIG. 3) may need to be re-executed and submitted as long as it is determined that the predetermined condition of any one of the logs 31-34 cannot be met. For example, it is determined that the predetermined condition of the log 34 cannot be met, i.e., the value of k1 minus 100 is less than zero, thereby determining that the predetermined condition cannot be met and that the first transaction needs to be re-executed. In this case, the transfer operation in the first transaction corresponds to the second operation if the predetermined condition is not satisfied, for example, the second operation is to return "transfer failure" to the account a, so that, when the first transaction is re-executed in the first node, because the first transaction is the transaction ranked first in the transaction execution window at this time (i.e., the first transaction is in the commit stage), the log is not recorded any more, and the second operation corresponding to the predetermined operation is directly executed, i.e., the "transfer failure" is returned to the account a, and after the first transaction is executed, the first transaction is committed. For example, the transfer operation in the first transaction corresponds to a second operation under the condition that the predetermined condition is not met, for example, the second operation is "transfer 1 yuan from the account a to the account B", so that, when the first transaction is re-executed in the first node, because the first transaction is the transaction arranged at the first position in the transaction execution window at this time, the log is not recorded any more, the second operation corresponding to the predetermined operation is directly executed, that is, transfer 1 yuan from the account a to the account B, and the first transaction is submitted after the first transaction is executed.
In one embodiment, in the case that the predetermined conditions corresponding to each log are judged to be satisfied sequentially for each log, for example, the predetermined conditions corresponding to the logs 31 to 34 are judged to be satisfied for the logs 31 to 34, the corresponding first operations in the logs 31 to 34 are sequentially executed based on the recording sequence of the logs 31 to 34, and the first transaction is submitted after the first operations are executed in combination with the execution information executed in advance in the non-submission stage of the first transaction.
Fig. 7 illustrates an apparatus 700 for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined submission order, including a first transaction, the order of the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and the current submission order of the first transaction is located at a position after the first position, the apparatus is disposed in a first node in the blockchain, and includes:
a recording unit 71 configured to, when a first predetermined operation out of the at least one predetermined operation is performed, record a first log in a first storage space corresponding to a first transaction, and record, in the first storage space, a recording order of the first log in logs already recorded in the first storage space, the first log corresponding to the first operation out of the first predetermined operation; and
an execution unit 72 configured to skip the first predetermined operation to continue to execute an operation in the first transaction after the first predetermined operation.
In one embodiment, a first operation of the first predetermined operations includes a write operation on a first variable, the code following the code in the first transaction includes a read operation on the first variable, the apparatus further includes a marking unit 73 configured to, upon execution to the read operation, in a case where it is determined that a first log is recorded in the first storage space, mark in a second storage space corresponding to the first transaction to indicate that the first transaction needs to be re-executed in a commit stage thereof, wherein a commit order of the first transaction in the commit stage is first.
In one embodiment, a first operation of the first predetermined operations includes a write operation on a first variable, the code following the code in the first transaction includes a read operation on the first variable, and the apparatus further includes a waiting unit 74 configured to, when executing to the read operation, wait until the first transaction reaches a commit phase after stopping waiting to re-execute the first transaction in the commit phase of the first transaction, in a case where it is determined that a first log is recorded in the first storage space, wherein a commit order of the first transaction in the commit phase is first.
Figure 8 illustrates an apparatus 800 for concurrently performing multiple transactions in a blockchain according to one embodiment of the present description, wherein the plurality of transactions have a predetermined submission order, including a first transaction in which the order includes at least one predetermined operation, the predetermined operation corresponding to the first operation if a predetermined condition is satisfied, and the current commit order of the first transaction is at the first place, the first transaction having been previously executed before the commit order changes to the first place, and currently recording at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log in a first storage space corresponding to the first transaction, the log corresponding to a first one of the respective predetermined operations, the apparatus deployed in a first node in a blockchain, comprising:
an acquiring unit 81 configured to acquire the at least one log and a recording order of the at least one log;
a judging unit 82 configured to judge, for each log in turn, whether a predetermined condition corresponding to the log is satisfied based on a recording order of the at least one log;
a re-execution unit 83 configured to re-execute the first transaction and submit the first transaction in case it is determined that the predetermined condition corresponding to the log is not satisfied.
In one embodiment, the apparatus further includes a submitting unit 84 configured to, in a case where it is determined that the respective predetermined conditions corresponding to the at least one log are satisfied, sequentially perform at least one first operation corresponding to the at least one log, based on a recording order of the at least one log, and submit the first transaction.
In one embodiment, in the first transaction, the predetermined operation corresponds to a second operation if the predetermined condition is not satisfied, wherein in the case where it is determined that the predetermined condition corresponding to the log is not satisfied, the re-execution unit 83 is further configured to, when re-executing the predetermined operation corresponding to the log, execute the second operation corresponding to the predetermined operation.
Another aspect of the present specification provides a computer readable storage medium having a computer program stored thereon, which, when executed in a computer, causes the computer to perform any one of the above methods.
Another aspect of the present specification provides a computing device comprising a memory and a processor, wherein the memory stores executable code, and the processor implements any one of the above methods when executing the executable code.
According to the scheme for concurrently executing the transaction, aiming at the scheduled operation comprising the condition judgment, the scheduled operation is not executed in the non-submission stage, only the record is carried out in the buffer area, and the scheduled operation is executed in the submission stage by judging whether the predetermined condition is met, so that compared with the scheme for previously executing the scheduled operation in the non-submission stage, the possible larger time cost caused by the re-execution of the transaction in the submission stage can be avoided, and meanwhile, other operations except the scheduled operation included in the transaction are executed in advance when the transaction is concurrently executed, and the efficiency for concurrently executing the transaction is integrally accelerated. In addition, compared with the traditional serial execution of the transfer transaction of the blockchain, the transfer transaction is divided into two stages by recording the log, the originally conflicting transfer transaction is converted into the transaction which can be executed in parallel, and the system performance is prompted.
It is to be understood that the terms "first," "second," and the like, herein are used for descriptive purposes only and not for purposes of limitation, to distinguish between similar concepts.
The embodiments in the present specification are described in a progressive manner, and the same and similar parts among the embodiments are referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
It will be further appreciated by those of ordinary skill in the art that the elements and algorithm steps of the examples described in connection with the embodiments disclosed herein may be embodied in electronic hardware, computer software, or combinations of both, and that the components and steps of the examples have been described in a functional general in the foregoing description for the purpose of illustrating clearly the interchangeability of hardware and software. Whether these functions are performed in hardware or software depends on the particular application of the solution and design constraints. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied in hardware, a software module executed by a processor, or a combination of the two. A software module may reside in Random Access Memory (RAM), memory, Read Only Memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (24)

1. A method for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined commit order including a first transaction, the order in the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and a current commit order of the first transaction is located at a position after the first bit, the method performed at a first node in the blockchain, comprising:
when a first predetermined operation of the at least one predetermined operation is executed, recording a first log in a first storage space corresponding to a first transaction, and recording a recording order of the first log in a log recorded in the first storage space, the first log corresponding to the first operation of the first predetermined operation, in the first storage space; and
skipping the first predetermined operation continues to perform operations in the first transaction that follow the first predetermined operation.
2. The method of claim 1, wherein a first operation of the first predetermined operations comprises a write operation to a first variable, and a read operation to the first variable is included after the first predetermined operation in the first transaction, the method further comprising, upon execution to the read operation, in an instance in which it is determined that the first log is recorded in the first storage space, marking in a second storage space corresponding to the first transaction to indicate that the first transaction needs to be re-executed in its commit phase, wherein a commit order of the first transaction in the commit phase is first.
3. The method of claim 1, wherein a first operation of the first scheduled operations comprises a write operation to a first variable, and a read operation to the first variable is included after the first scheduled operation in the first transaction, the method further comprising, upon execution of the read operation, in determining that the first log is recorded in the first storage space, waiting until the first transaction reaches a commit phase and then stopping waiting to re-execute the first transaction in the commit phase of the first transaction, wherein a commit order of the first transaction in the commit phase is first.
4. The method according to claim 1, wherein a transaction execution window is preset in the first node, and the transactions are transactions that are currently included in the transaction execution window and arranged in a submission order, wherein the first transaction is currently located at a position after a first position in the transaction execution window.
5. The method of claim 1, wherein the at least one predetermined operation comprises at least one type of predetermined operation.
6. A method for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined submission order including a first transaction, the first transaction order includes at least one predetermined operation, the predetermined operation corresponds to a first operation when a predetermined condition is satisfied, and a current submission order of the first transaction is located at a first position, the first transaction has been previously executed before the submission order changes to the first position, and at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log are currently recorded in a first storage space corresponding to the first transaction, the log corresponds to the first operation in the corresponding predetermined operation, and the method is executed at a first node in the blockchain, and includes:
acquiring the at least one log and the recording sequence of the at least one log;
on the basis of the recording sequence of the at least one log, sequentially judging whether a preset condition corresponding to the log is met or not for each log;
and in the case that the preset condition corresponding to the log is judged not to be satisfied, re-executing the first transaction and submitting the first transaction.
7. The method according to claim 6, wherein the method further comprises, in a case where it is determined that the respective predetermined conditions corresponding to the at least one log are satisfied, sequentially performing at least one first operation corresponding to the at least one log, respectively, based on a recording order of the at least one log, and submitting the first transaction.
8. The method of claim 6, wherein in the first transaction, the predetermined operation corresponds to a second operation if the predetermined condition is not satisfied, wherein, in the event that it is determined that the predetermined condition corresponding to the log is not satisfied, re-executing and committing the first transaction comprises, upon re-executing the predetermined operation corresponding to the log, executing the second operation corresponding to the predetermined operation.
9. The method according to claim 6, wherein a transaction execution window is preset in the first node, and the transactions are transactions that are currently included in the transaction execution window and arranged in a submission order, wherein the first transaction is currently located at a first position in the transaction execution window.
10. The method according to any one of claims 6 to 9, wherein the first predetermined operation is a transfer operation from the first account to a second account, the first predetermined operation corresponding to an operation to transfer a first amount from the first account to the second account if a predetermined condition is met.
11. The method of claim 10, wherein the predetermined condition is that the balance of the first account is greater than or equal to the first amount.
12. An apparatus for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined commit order including a first transaction, the order in the first transaction includes at least one predetermined operation, the predetermined operation corresponds to the first operation when a predetermined condition is satisfied, and a current commit order of the first transaction is located at a position after the first bit, the apparatus being disposed in a first node in the blockchain, comprising:
a recording unit configured to, when a first predetermined operation out of the at least one predetermined operation is performed, record a first log in a first storage space corresponding to a first transaction, and record, in the first storage space, a recording order of the first log in logs already recorded in the first storage space, the first log corresponding to the first operation out of the first predetermined operation; and
and the execution unit is configured to skip the first predetermined operation and continue to execute the operation in the first transaction after the first predetermined operation.
13. The apparatus according to claim 12, wherein a first operation of the first predetermined operations includes a write operation on a first variable, and a read operation on the first variable is included after the first predetermined operation in the first transaction, the apparatus further comprising a marking unit configured to, when the read operation is executed, mark in a second storage space corresponding to the first transaction in a case where it is determined that the first log is recorded in the first storage space to indicate that the first transaction needs to be re-executed in a commit stage thereof, wherein a commit order of the first transaction in the commit stage is first.
14. The apparatus according to claim 12, wherein a first operation of the first predetermined operations includes a write operation on a first variable, and a read operation on the first variable is included after the first predetermined operation in the first transaction, the apparatus further comprising a waiting unit configured to, when the read operation is performed, wait in a case where it is determined that the first log is recorded in the first storage space until the first transaction reaches a commit stage, and stop waiting until the first transaction reaches the commit stage, to re-execute the first transaction in the commit stage of the first transaction, wherein a commit order of the first transaction in the commit stage is first.
15. The apparatus according to claim 12, wherein a transaction execution window is preset in the first node, and the transactions are transactions that are currently included in the transaction execution window and arranged in a submission order, and the first transaction is currently located at a position after a first position in the transaction execution window.
16. The apparatus of claim 12, wherein the at least one predetermined operation comprises at least one type of predetermined operation.
17. An apparatus for concurrently executing a plurality of transactions in a blockchain, wherein the plurality of transactions have a predetermined commit order including a first transaction, the first transaction order includes at least one predetermined operation, the predetermined operation corresponds to a first operation when a predetermined condition is satisfied, and a current commit order of the first transaction is located at a first position, the first transaction has been previously executed before the commit order changes to the first position, and at least one log corresponding to the at least one predetermined operation and a recording order of the at least one log are currently recorded in a first storage space corresponding to the first transaction, the log corresponds to the first operation among the respective predetermined operations, the apparatus is disposed in a first node in the blockchain, and includes:
an acquisition unit configured to acquire the at least one log and a recording order of the at least one log;
a judging unit configured to judge, for each log in turn, whether a predetermined condition corresponding to the log is satisfied based on a recording order of the at least one log;
and the re-execution unit is configured to re-execute the first transaction and submit the first transaction in the case that the preset condition corresponding to the log is judged not to be satisfied.
18. The apparatus according to claim 17, wherein the apparatus further comprises a submitting unit configured to, in a case where it is determined that the respective predetermined conditions corresponding to the respective at least one log are satisfied, sequentially perform at least one first operation corresponding to the respective at least one log based on a recording order of the respective at least one log, and submit the first transaction.
19. The apparatus according to claim 17, wherein in the first transaction, the predetermined operation corresponds to a second operation if a predetermined condition is not satisfied, wherein in a case where it is determined that the predetermined condition corresponding to the log is not satisfied, the re-execution unit is further configured to, when the predetermined operation corresponding to the log is re-executed, execute the second operation corresponding to the predetermined operation.
20. The apparatus according to claim 17, wherein a transaction execution window is preset in the first node, and the transactions are transactions that are currently included in the transaction execution window and arranged in a submission order, and the first transaction is currently located at a first position in the transaction execution window.
21. The apparatus of any one of claims 12 to 20, wherein the first predetermined action is a transfer operation from the first account to a second account, the first predetermined action corresponding to an operation to transfer a first amount from the first account to the second account if a predetermined condition is met.
22. The apparatus of claim 21, wherein the predetermined condition is that the balance of the first account is greater than or equal to the first amount.
23. A computer-readable storage medium, on which a computer program is stored which, when executed in a computer, causes the computer to carry out the method of any one of claims 1-11.
24. A computing device comprising a memory and a processor, wherein the memory has stored therein executable code that, when executed by the processor, performs the method of any of claims 1-11.
CN201910939502.3A 2019-09-30 2019-09-30 Method and apparatus for concurrently executing transactions in a blockchain Active CN110706108B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910939502.3A CN110706108B (en) 2019-09-30 2019-09-30 Method and apparatus for concurrently executing transactions in a blockchain

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910939502.3A CN110706108B (en) 2019-09-30 2019-09-30 Method and apparatus for concurrently executing transactions in a blockchain

Publications (2)

Publication Number Publication Date
CN110706108A CN110706108A (en) 2020-01-17
CN110706108B true CN110706108B (en) 2021-08-03

Family

ID=69197561

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910939502.3A Active CN110706108B (en) 2019-09-30 2019-09-30 Method and apparatus for concurrently executing transactions in a blockchain

Country Status (1)

Country Link
CN (1) CN110706108B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112991061B (en) * 2020-10-28 2023-06-09 支付宝(杭州)信息技术有限公司 Method and apparatus for concurrently executing transactions in blockchain
CN112199186B (en) 2020-12-07 2021-03-02 腾讯科技(深圳)有限公司 Data processing method, device, equipment and storage medium based on intelligent contract

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US10255108B2 (en) * 2016-01-26 2019-04-09 International Business Machines Corporation Parallel execution of blockchain transactions
CN107688999B (en) * 2017-08-11 2020-11-13 杭州溪塔科技有限公司 Block chain-based parallel transaction execution method
JP6883110B2 (en) * 2018-12-19 2021-06-09 アドバンスド ニュー テクノロジーズ カンパニー リミテッド Data isolation within the blockchain network
CN109784930B (en) * 2019-02-18 2023-07-18 深圳市迅雷网络技术有限公司 A method, device, electronic device and medium for processing blockchain transaction data

Also Published As

Publication number Publication date
CN110706108A (en) 2020-01-17

Similar Documents

Publication Publication Date Title
US9619430B2 (en) Active non-volatile memory post-processing
CN110706101B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN113743950B (en) Method, node and blockchain system for performing transactions in blockchain system
CN110675255B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN110648124B (en) Method and apparatus for concurrently executing transactions in a blockchain
EP3961431B1 (en) Method and apparatus for grouping transactions that need to be serially executed based on a sequence of transactions in one block of a blockchain
CN111754350B (en) Method and device for parallelly acquiring serial numbers of transaction access variables in block chain
CN113743943B (en) Method for executing transaction in block chain, main node and slave node
CN112001797B (en) Method and device for grouping transactions in blockchain
CN110706108B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN115760405A (en) Transaction execution method, device, computer equipment and medium
CN113163011A (en) Method, system, device and storage medium for modifying data in block chain
CN114564500A (en) Method and system for implementing structured data storage and query in block chain system
CN111767337B (en) Block verification method, device and equipment
US20120059997A1 (en) Apparatus and method for detecting data race
CN113744062B (en) Method for performing transactions in a blockchain, blockchain node and blockchain
CN115237444A (en) Concurrent control method, device and equipment based on version number and storage medium
CN110689344B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN116756237A (en) Transaction data processing method, device, system, application system and big data platform
CN106055322A (en) Flow scheduling method and device
CN112733499A (en) Serial number generation method and device
CN113326266A (en) Data synchronization method and device based on table structure relationship
CN112561695B (en) Method and apparatus for concurrently executing transactions in a blockchain
CN109271277A (en) Access method, device and system after database delay machine
CN119760180A (en) Array element processing method and device, storage medium and electronic device

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
REG Reference to a national code

Ref country code: HK

Ref legal event code: DE

Ref document number: 40021006

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right

Effective date of registration: 20240929

Address after: Room 803, floor 8, No. 618 Wai Road, Huangpu District, Shanghai 200010

Patentee after: Ant blockchain Technology (Shanghai) Co.,Ltd.

Country or region after: China

Address before: 310000 801-11 section B, 8th floor, 556 Xixi Road, Xihu District, Hangzhou City, Zhejiang Province

Patentee before: Alipay (Hangzhou) Information Technology Co.,Ltd.

Country or region before: China

TR01 Transfer of patent right