CN112508574A - Block chain parallel transaction execution method and device and electronic equipment - Google Patents

Block chain parallel transaction execution method and device and electronic equipment Download PDF

Info

Publication number
CN112508574A
CN112508574A CN202110145817.8A CN202110145817A CN112508574A CN 112508574 A CN112508574 A CN 112508574A CN 202110145817 A CN202110145817 A CN 202110145817A CN 112508574 A CN112508574 A CN 112508574A
Authority
CN
China
Prior art keywords
transaction
dependency
bucket
effective
intelligent contract
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110145817.8A
Other languages
Chinese (zh)
Inventor
张建钢
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Holographic Zhixin Technology Co ltd
Original Assignee
Beijing Holographic Zhixin 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 Holographic Zhixin Technology Co ltd filed Critical Beijing Holographic Zhixin Technology Co ltd
Priority to CN202110145817.8A priority Critical patent/CN112508574A/en
Publication of CN112508574A publication Critical patent/CN112508574A/en
Pending legal-status Critical Current

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
    • G06Q20/00Payment architectures, schemes or protocols
    • G06Q20/38Payment protocols; Details thereof
    • G06Q20/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3829Payment protocols; Details thereof insuring higher security of transaction involving key management
    • 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/382Payment protocols; Details thereof insuring higher security of transaction
    • G06Q20/3825Use of electronic signatures

Landscapes

  • Business, Economics & Management (AREA)
  • Engineering & Computer Science (AREA)
  • Accounting & Taxation (AREA)
  • Computer Security & Cryptography (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • General Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Stored Programmes (AREA)

Abstract

The invention provides a block chain parallel transaction execution method, a block chain parallel transaction execution device and electronic equipment. Compared with the mode that the front block link protocol stack executes all transactions in sequence, the mode of the invention can effectively save the time required by executing the transactions during block generation and verification, thereby improving the concurrency capability of the block link, reducing the time delay of the block link and improving the overall performance of the block link protocol stack.

Description

Block chain parallel transaction execution method and device and electronic equipment
Technical Field
The present invention relates to the field of blockchain technology, and more particularly to the field of transaction execution in block generation and block verification.
Background
When generating a block, a node on the blockchain network needs to select and execute a group of transactions in sequence according to a deterministic sequence to achieve a new world state, and the node can generate the block to participate in consensus. Similarly, when verifying a block, the blockchain node needs to execute a set of transactions included in the block in sequence in the same deterministic order and achieve a new world state so that the block can be verified and further participate in consensus.
Because transactions are performed sequentially, to increase the block extraction speed, the number of transactions that each block can contain may be very limited, which seriously affects performance such as concurrency capability of the block chain. This problem is even more pronounced when performing transactions that are logically complex and time consuming.
Disclosure of Invention
In order to solve at least one of the above technical problems, the present invention provides a method, an apparatus, an electronic device and a readable storage medium for parallel transaction execution of a blockchain.
In a first aspect of the present invention, a method for performing parallel transactions of a blockchain is provided, including:
obtaining an effective dependency relationship of each transaction;
allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction;
the transactions in each transaction bucket are executed in parallel.
Optionally, obtaining valid dependencies for each transaction comprises:
obtaining the effective dependency relationship of the target intelligent contract of each transaction; and/or obtaining valid dependencies for each transaction statement.
The method comprises the steps that an effective dependency relationship of a target intelligent contract of each transaction is preset, and the effective dependency relationship of the target intelligent contract of each transaction is directly obtained to serve as the effective dependency relationship of the transaction; or, defining that each transaction needs to declare an effective dependency relationship, and taking the effective dependency relationship of the transaction declaration as the effective dependency relationship of the transaction; or the effective dependency relationship of the target intelligent contract of each transaction is preset, the effective dependency relationship needs to be declared for each transaction, and the union of the effective dependency relationship of the target intelligent contract of the transaction and the effective dependency relationship of the transaction declaration is used as the effective dependency relationship of the transaction. In the embodiment of the invention, the effective dependency relationship is expressed by one metadata, and the metadata comprises three value taking conditions of unset, irrelevant and at least one address.
Optionally, obtaining valid dependencies for each transaction comprises:
acquiring the dependency relationship and dependency resolution of a target intelligent contract of each transaction;
acquiring the dependency relationship and dependency resolution of each transaction statement;
and determining the effective dependency relationship of each transaction according to the dependency relationship and the dependency resolution of the target intelligent contract of each transaction and the dependency relationship and the dependency resolution of each transaction statement.
Optionally, determining the valid dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction declaration includes:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not unset, calculating a union of the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement, and subtracting the explicit dependence resolution of the target intelligent contract of the transaction and the explicit dependence resolution of the transaction statement from the union to obtain the effective dependency of the transaction.
Where explicit dependency resolution refers to dependency resolution that includes one or more addresses.
Optionally, determining the valid dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction declaration includes:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not set, determining that the effective dependency of the transaction is not set;
for any transaction in each transaction, when one of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement is not set, subtracting the explicit dependency resolution of the target intelligent contract of the any transaction and the explicit dependency resolution of the any transaction statement from the other of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement to obtain the effective dependency of the any transaction.
Where explicit dependency resolution refers to dependency resolution that includes one or more addresses.
Optionally, allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction, including:
for any transaction in said each transaction, assigning a separate transaction bucket for said any transaction when the valid dependencies of said any transaction are irrelevant.
Optionally, allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction, including:
for any transaction in each transaction, when the effective dependency of the transaction is not set, allocating the transaction to a transaction bucket for storing at least one transaction of which the effective dependency is not set.
For any transaction in each transaction, when the effective dependency of the transaction is one or more addresses, the transaction is allocated to a transaction bucket for storing transactions with the same effective dependency.
Optionally, allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction, including:
for any transaction in each transaction, when the effective dependency of the transaction is not set or when the effective dependency of the transaction is one or more addresses, allocating the transaction to a transaction bucket for storing at least one transaction for which the effective dependency is not irrelevant.
Optionally, the method further comprises:
when a transaction bucket for allocation does not exist, a corresponding transaction bucket is created.
Optionally, executing the transactions in each transaction bucket in parallel comprises:
one thread is created for each transaction bucket, and the respective threads execute transactions in each transaction bucket in parallel.
Optionally, executing the transactions in each transaction bucket in parallel comprises:
creating a plurality of threads, wherein each thread corresponds to at least one transaction bucket for storing transactions with irrelevant effective dependency relationships, and/or each thread corresponds to at least one transaction bucket for storing transactions with the same effective dependency relationships;
the respective threads execute transactions in a corresponding plurality of transaction buckets in parallel.
Optionally, after obtaining the valid dependency relationship of each transaction, the method further includes:
and updating the effective dependency relationship to the world state data of the block chain network.
Optionally, after executing the transaction in each transaction bucket, the method further includes:
judging whether the dependency relationship used when the transaction in each transaction bucket is executed is consistent with the effective dependency relationship; if yes, determining that the transaction is successfully executed; otherwise, the transaction execution is determined to have failed.
Optionally, after determining that the transaction execution fails, the method further includes:
and if the dependency relationship and/or the dependency resolution of the target intelligent contract are determined to have error to cause the transaction execution failure, correcting the dependency relationship and/or the dependency resolution of the target intelligent contract, and if the dependency resolution of the transaction statement is determined to cause the transaction execution failure, executing a processing flow for punishing a transaction initiator.
Optionally, when the block is generated or when the block is verified, obtaining the effective dependency relationship of each transaction, allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction, and executing the transactions in each transaction bucket in parallel.
In a second aspect of the present invention, a block chain parallel transaction executing apparatus is provided, including:
the effective dependency relationship acquisition module is used for acquiring the effective dependency relationship of each transaction;
the transaction bucket distribution module is used for distributing a transaction bucket for each transaction according to the effective dependency relationship of each transaction;
and the transaction execution module is used for executing the transactions in each transaction bucket in parallel.
Optionally, the effective dependency relationship obtaining module is specifically configured to:
obtaining the effective dependency relationship of the target intelligent contract of each transaction; and/or obtaining valid dependencies for each transaction statement.
Optionally, the effective dependency relationship obtaining module is specifically configured to:
acquiring the dependency relationship and dependency resolution of a target intelligent contract of each transaction;
acquiring the dependency relationship and dependency resolution of each transaction statement;
and determining the effective dependency relationship of each transaction according to the dependency relationship and the dependency resolution of the target intelligent contract of each transaction and the dependency relationship and the dependency resolution of each transaction statement.
Optionally, the effective dependency obtaining module is configured to, when determining the effective dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction statement, specifically:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not unset, calculating a union of the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement, and subtracting the explicit dependence resolution of the target intelligent contract of the transaction and the explicit dependence resolution of the transaction statement from the union to obtain the effective dependency of the transaction.
Optionally, the effective dependency obtaining module is configured to, when determining the effective dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction statement, specifically:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not set, determining that the effective dependency of the transaction is not set;
for any transaction in each transaction, when one of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement is not set, subtracting the explicit dependency resolution of the target intelligent contract of the any transaction and the explicit dependency resolution of the any transaction statement from the other of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement to obtain the effective dependency of the any transaction.
Optionally, the transaction bucket allocation module is specifically configured to:
for any transaction in said each transaction, assigning a separate transaction bucket for said any transaction when the valid dependencies of said any transaction are irrelevant.
Optionally, the transaction bucket allocation module is specifically configured to:
for any transaction in each transaction, when the effective dependency of the transaction is not set, allocating the transaction to a transaction bucket for storing at least one transaction of which the effective dependency is not set.
For any transaction in each transaction, when the effective dependency of the transaction is one or more addresses, the transaction is allocated to a transaction bucket for storing transactions with the same effective dependency.
Optionally, the transaction bucket allocation module is further configured to:
when a transaction bucket for allocation does not exist, a corresponding transaction bucket is created.
Optionally, the transaction execution module is specifically configured to:
one thread is created for each transaction bucket, and the respective threads execute transactions in each transaction bucket in parallel.
Optionally, the transaction execution module is specifically configured to:
creating a plurality of threads, wherein each thread corresponds to at least one transaction bucket for storing transactions with irrelevant effective dependency relationships, and/or each thread corresponds to at least one transaction bucket for storing transactions with the same effective dependency relationships;
the respective threads execute transactions in a corresponding plurality of transaction buckets in parallel.
Optionally, the apparatus further comprises:
and the state data updating module is used for updating the effective dependency relationship to the world state data of the block chain network.
Optionally, the transaction execution checking module is configured to determine whether a dependency used in executing the transaction in each transaction bucket is consistent with the valid dependency; if yes, determining that the transaction is successfully executed; otherwise, the transaction execution is determined to have failed.
Optionally, the transaction execution verification module is further configured to:
after the transaction execution failure is determined, if the dependency relationship and/or the dependency resolution of the target intelligent contract are determined to have the error to cause the transaction execution failure, the dependency relationship and/or the dependency resolution of the target intelligent contract are corrected, and if the dependency resolution of the transaction statement is determined to cause the transaction execution failure, a processing flow punishing a transaction initiator is executed.
In a third aspect of the invention, there is provided an electronic device comprising a memory for storing computer instructions for execution by a processor to implement the method according to the first aspect of the invention.
In a fourth aspect of the invention, there is provided a readable storage medium having stored thereon computer instructions which, when executed by a processor, implement the method of the first aspect of the invention.
The invention relates to a method for executing intelligent contract transaction on a block chain. When generating and verifying the block, the method carries out the bucket (transaction bucket) to the transaction to be executed according to the dependency relationship of the intelligent contract and the transaction. The transactions in different transaction buckets have no dependency relationship with each other, that is, any two transactions belonging to different transaction buckets will not read and write the same "state". In this way, a transaction execution thread may be created for each transaction bucket. The transactions in the same transaction bucket are executed in sequence by the corresponding transaction execution threads, but the transactions belonging to different transaction buckets are executed in parallel by the transaction execution threads. The term "thread" as used herein refers to a (or a group of the same) program control flow that is available for operating system scheduling and CPU execution, and does not necessarily correspond to an (or a group of) operating system threads or processes in an implementation.
The dependency relationship can be obtained and updated in the modes of active declaration when intelligent contracts are deployed or transactions are submitted, active discovery by code analysis of a blockchain protocol stack, passive discovery when transactions are executed and the like. The scope of action of the dependency relationship may be contract level or transaction level. Contract level dependencies, applicable to all business transactions facing the intelligent contract, are recorded into the "world state". Transaction-level dependencies apply only to current transactions. The transaction level dependency relationship has higher priority.
Intelligent contracts on a blockchain network are often independent of each other. On a block chain network consisting of block chain link points configured with a multi-core CPU, the parallel execution method can effectively shorten the transaction execution time during block generation and verification, thereby saving the time of the whole block consensus whole process and improving the performance of the whole block chain.
Drawings
The accompanying drawings, which are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate exemplary embodiments of the invention and together with the description serve to explain the principles of the invention.
FIG. 1 is a transaction bucketing and parallel execution example of the present invention.
Detailed Description
The present invention will be described in further detail with reference to the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are for purposes of illustration only and are not to be construed as limitations of the invention. It should be noted that, for convenience of description, only the portions related to the present invention are shown in the drawings.
In addition, the embodiments of the present invention and the features of the embodiments may be combined with each other without conflict. The following detailed description will be made in conjunction with embodiments with reference to the accompanying drawings.
A block chain protocol stack executes transactions to enter a block in sequence according to a deterministic sequence when generating the block to achieve a new world state and to be added to the new block; when the block is verified, the transactions in the block are sequentially executed according to the same deterministic sequence to achieve a new world state and the new world state is compared with the world state statement in the block.
Unlike the above-described blockchain protocol stack, another blockchain protocol stack "prefixes" the actual execution of the transaction (proposal), and incorporates the results of reading and writing the state and the signature of each endorsement node (endorser) into the actual transaction. In generating and verifying the tiles, the "execution" of these transactions at the ordering node (orderer) and the committer node (committer) simply "verifies" the signatures of the various endorsement nodes contained within each transaction, which is typically faster than the actual transaction execution. However, if there are many endorsement nodes for a transaction, it may take a long time to verify the signatures of these endorsement nodes.
Since transactions are performed sequentially when generating and verifying tiles, to increase the speed of tile extraction and consensus, the number of transactions that each tile can contain may be very limited, which seriously affects performance such as concurrency capability of the tile chain. This problem is even more pronounced if the transaction is a transaction that is complex in execution logic and takes a long time.
The parallel transaction execution method provided by the embodiment of the invention comprises the following three aspects:
1. dependency relationships and dependency resolution.
The invention introduces two new optional metadata in the deployment transaction of the intelligent contract and the business transaction of submitting the execution of the intelligent contract, namely dependency (deprel) and dependency release (deprm). The former supports an intelligent contract (at deployment time) or a business transaction (at submission time) to declare its dependency relationship by explicitly setting default, and the latter supports an intelligent contract or a business transaction to explicitly release its dependency that can be inherited.
The dependency (deprel) and de-dependency (deprm) values are unset ("undef"), not relevant ("n/a"), or relevant, the latter being represented by a list of a set of smart contract addresses (or user addresses).
If an intelligent contract is completely independent of other intelligent contracts, or if a business transaction has no other dependency than the dependency inheriting the target intelligent contract, its deprel value should be set to irrelevant ("n/a").
If an intelligent contract has no default set at deployment, the blockchain protocol stack sets its dependency to unset ("undef"). If a business transaction is submitted with default and its dependency list of target smart contracts is unset ("undef"), the blockchain protocol stack sets its dependency list to unset ("undef").
A business transaction's effective dependency (depeff) is the union of its target intelligent contract's (or target user's) dependency and its own dependency, but culls its explicitly resolved dependency.
For example, if the intelligent contract a declares a dependency relationship (deprel) as "0 x1 … 1", "0 x2 … 2", "0 x3 … 3" at the time of deployment, which indicates that there are three dependencies, its intelligent contract addresses are 0x1 … 1 and 0x2.. 2 and 0x3 … 3, respectively. If the business transaction T whose target dumb contract a declares its dependency (deprel) to be "0 x4 … 4" and declares its dependency release (deprm) to be "0 x1 … 1" at the time of commit, the effective dependency (depeff) of the business transaction T is "0 x2 … 2", "0 x3 … 3", "0 x4 … 4".
2. And (5) establishing a dependency relationship.
As shown in fig. 1, a blockchain protocol stack has an automated or manual, so-called contract deployment module (block 100) that receives and executes deployment transactions to complete the deployment of new intelligent contracts at various nodes on the blockchain network. The invention adds new capability to the module, namely capability of collecting and discovering dependency relationship, which is specifically expressed as: the dependencies and dependency release settings are actively discovered by checking the dependency (deprel) and dependency release (deprm) settings in the deployment transaction, while optionally, code that analyzes the new smart contract, if possible. And removing the union of the two dependency disadvantages (deprem) from the union of the two dependencies (deprel) to obtain the effective dependency (depeff) of the intelligent contract and record the effective dependency into a contract dependency state library (block 101 in fig. 1, step a).
Also as shown in fig. 1, a blockchain protocol stack has a so-called state collection module (block 109) to collect new world states formed after the transaction is executed. The invention adds new capability to the module, namely analyzes the collected state read-write operation after each parallel execution transaction execution thread ( blocks 106, 107 and 108) completes the transaction execution, and judges the authenticity of the effective dependency relationship depended by the transaction bucket division module (block 102). If a transaction depends on a dependency that has not been discovered, the transaction will fail, and the valid dependencies of its target smart contract will be updated accordingly and recorded in the contract dependency state library (block 101, step (5)).
Contracts rely on state libraries, which are part of the world state of a blockchain network.
3. Barrel separation and parallel processing.
When the block is generated and verified, the transaction is divided into buckets based on the effective dependence relationship of each transaction, and then the transactions without the effective dependence relationship are processed in parallel, so that the performance of a block chain is improved.
The principle of barrel separation is as follows:
(1) an effective dependency is an unrelated (n/a) transaction, which can monopolize the bucket alone to achieve the best concurrency performance.
(2) An active dependency is an unset ("undef") transaction that is all allocated into the same transaction bucket for compatibility.
(3) Each unique valid dependency, if it is neither set (undef) nor irrelevant (n/a), allocates a separate transaction bucket.
The concurrency principle is as follows:
(1) each transaction bucket corresponds to a transaction execution thread (shown in blocks 106, 107, 108).
(2) If the number of transaction buckets with irrelevant ("n/a") valid dependencies or the number of unique valid dependencies is too large, it can be considered that a transaction execution thread is shared by a plurality of transaction buckets to control the number of concurrent threads (the maximum number of concurrent threads can be set).
Based on the above bucket-dividing principle, a set of transactions is given when block generation and block verification are performed, and the parallel processing flow of the invention is as follows:
(1) for each transaction, based on the address of the target intelligent contract, the transaction bucket partitioning module (block 102) queries the contract state dependency base (block 101) to obtain the effective dependency relationship of the target intelligent contract, and eliminates the dependency resolution possibly declared by the transaction itself to obtain the effective dependency relationship of the transaction.
(2) If the valid dependency does not have a corresponding transaction bucket (as shown in blocks 103, 104, 105), a transaction bucket is created. And distributing the transaction to a transaction bucket corresponding to the effective dependency relationship.
(3) The concurrent thread, i.e., the transaction execution thread (as shown in blocks 106, 107, and 108), corresponding to each transaction bucket sequentially executes the transactions in the transaction bucket according to a predetermined sequence, and records the status read/write operation of each transaction.
(4) The state aggregation module (block 109) collects the state read and write status of each completed transaction after each transaction execution thread completes execution (or time out) of the transaction in its transaction bucket.
(5) The state aggregation module (block 109) analyzes the actual dependencies used for the state read and write for each transaction. If the actual dependency is different from the valid dependency determined at the time of the binning, i.e., a dependency violation is determined, the transaction is processed as a failure. If the violations are due to errors in the valid dependencies of the target intelligent contract, the valid dependencies of the intelligent contract are modified and the contract dependency state library is updated. If the violations are due to explicit release of dependency (deprem) imposed by the originator of the business transaction, the originator should be penalized accordingly, such as a fine, a time limit, or an ever-denial of service, etc.
When a group of transactions need to be executed in block generation and verification, the transaction execution method and the transaction execution system distribute the transactions to transaction execution threads which are executed in parallel based on the effective dependency relationship of each transaction, and realize a parallel execution mode of irrelevant transactions.
It should be understood that the various techniques described herein may be implemented in connection with hardware or software or, alternatively, with a combination of both. Thus, the methods and apparatus of the present invention, or certain aspects or portions thereof, may take the form of program code (i.e., instructions) embodied in tangible media, such as floppy diskettes, CD-ROMs, hard drives, or any other machine-readable storage medium, wherein, when the program is loaded into and executed by a machine, such as a computer, the machine becomes an apparatus for practicing the invention.
In the case of program code execution on programmable computers, the computing device will generally include a processor, a storage medium readable by the processor (including volatile and non-volatile memory and/or storage elements), at least one input device, and at least one output device. Wherein the memory is configured to store program code; the processor is configured to perform the various methods of the present invention according to instructions in the program code stored in the memory.
By way of example, and not limitation, computer readable media may comprise computer storage media and communication media. Computer-readable media includes both computer storage media and communication media. Computer storage media store information such as computer readable instructions, data structures, program modules or other data. Communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media. Combinations of any of the above are also included within the scope of computer readable media.
Those skilled in the art will appreciate that the modules or units or components of the apparatus in the examples invented herein may be arranged in an apparatus as described in this embodiment or alternatively may be located in one or more apparatuses different from the apparatus in this example. The modules in the foregoing examples may be combined into one module or may be further divided into multiple sub-modules.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features of the invention in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so invented, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature of the invention in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Furthermore, those skilled in the art will appreciate that while some embodiments described herein include some features included in other embodiments, rather than other features, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the claims, any of the claimed embodiments may be used in any combination.
While the invention has been described with respect to a limited number of embodiments, those skilled in the art, having benefit of this description, will appreciate that other embodiments can be devised which do not depart from the scope of the invention as described herein. Furthermore, it should be noted that the language used in the specification has been principally selected for readability and instructional purposes, and may not have been selected to delineate or circumscribe the inventive subject matter. Accordingly, many modifications and variations will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the appended claims. The present invention is to be considered as illustrative and not restrictive in character, with the scope of the invention being indicated by the appended claims.

Claims (28)

1. A method for performing parallel transactions in a blockchain, comprising:
obtaining an effective dependency relationship of each transaction;
allocating a transaction bucket for each transaction according to the effective dependency relationship of each transaction;
the transactions in each transaction bucket are executed in parallel.
2. The method of claim 1, wherein obtaining valid dependencies for each transaction comprises:
obtaining the effective dependency relationship of the target intelligent contract of each transaction; and/or obtaining valid dependencies for each transaction statement.
3. The method of claim 1, wherein obtaining valid dependencies for each transaction comprises:
acquiring the dependency relationship and dependency resolution of a target intelligent contract of each transaction;
acquiring the dependency relationship and dependency resolution of each transaction statement;
and determining the effective dependency relationship of each transaction according to the dependency relationship and the dependency resolution of the target intelligent contract of each transaction and the dependency relationship and the dependency resolution of each transaction statement.
4. The method of claim 3, wherein determining valid dependencies for each transaction based on the dependencies and dependency disassemblies of the target smart contract for each transaction and the dependencies and dependency disassemblies declared for each transaction comprises:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not unset, calculating a union of the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement, and subtracting the explicit dependence resolution of the target intelligent contract of the transaction and the explicit dependence resolution of the transaction from the union to obtain the effective dependency of the transaction.
5. The method of claim 3, wherein determining valid dependencies for each transaction based on the dependencies and dependency disassemblies of the target smart contract for each transaction and the dependencies and dependency disassemblies declared for each transaction comprises:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not set, determining that the effective dependency of the transaction is not set;
for any transaction in each transaction, when one of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement is not set, subtracting the explicit dependency resolution of the target intelligent contract of the any transaction and the explicit dependency resolution of the any transaction statement from the other of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement to obtain the effective dependency of the any transaction.
6. The method of claim 1, wherein allocating a transaction bucket for each transaction based on the valid dependencies for said each transaction comprises:
for any transaction in said each transaction, assigning a separate transaction bucket for said any transaction when the valid dependencies of said any transaction are irrelevant.
7. The method of claim 1, wherein allocating a transaction bucket for each transaction based on the valid dependencies for said each transaction comprises:
for any transaction in each transaction, when the effective dependency of the transaction is not set, allocating the transaction to a transaction bucket for storing at least one transaction of which the effective dependency is not set;
for any transaction in each transaction, when the effective dependency of the transaction is one or more addresses, the transaction is allocated to a transaction bucket for storing transactions with the same effective dependency.
8. The method of claim 6 or 7, wherein the method further comprises:
when a transaction bucket for allocation does not exist, a corresponding transaction bucket is created.
9. The method of claim 1, wherein performing transactions in each transaction bucket in parallel comprises:
one thread is created for each transaction bucket, and the respective threads execute transactions in each transaction bucket in parallel.
10. The method of claim 1, wherein performing transactions in each transaction bucket in parallel comprises:
creating a plurality of threads, wherein each thread corresponds to at least one transaction bucket for storing transactions with irrelevant effective dependency relationships, and/or each thread corresponds to at least one transaction bucket for storing transactions with the same effective dependency relationships;
the respective threads execute transactions in a corresponding plurality of transaction buckets in parallel.
11. The method of claim 1, after obtaining valid dependencies for each transaction, further comprising:
and updating the effective dependency relationship to the world state data of the block chain network.
12. The method of claim 1, wherein after performing the transaction in each transaction bucket, further comprising:
judging whether the dependency relationship used when the transaction in each transaction bucket is executed is consistent with the effective dependency relationship; if yes, determining that the transaction is successfully executed; otherwise, the transaction execution is determined to have failed.
13. The method of claim 12, wherein after determining that the transaction has failed to execute, further comprising:
and if the dependency relationship and/or the dependency resolution of the target intelligent contract are determined to have error to cause the transaction execution failure, correcting the dependency relationship and/or the dependency resolution of the target intelligent contract, and if the dependency resolution of the transaction statement is determined to cause the transaction execution failure, executing a processing flow for punishing a transaction initiator.
14. The method of claim 1,
when the block is generated or verified, obtaining the effective dependency relationship of each transaction, distributing a transaction bucket for each transaction according to the effective dependency relationship of each transaction, and executing the transactions in each transaction bucket in parallel.
15. A blockchain parallel transaction execution apparatus, comprising:
the effective dependency relationship acquisition module is used for acquiring the effective dependency relationship of each transaction;
the transaction bucket distribution module is used for distributing a transaction bucket for each transaction according to the effective dependency relationship of each transaction;
and the transaction execution module is used for executing the transactions in each transaction bucket in parallel.
16. The apparatus of claim 15, wherein the effective dependency acquisition module is specifically configured to:
acquiring the dependency relationship and dependency resolution of a target intelligent contract of each transaction;
acquiring the dependency relationship and dependency resolution of each transaction statement;
and determining the effective dependency relationship of each transaction according to the dependency relationship and the dependency resolution of the target intelligent contract of each transaction and the dependency relationship and the dependency resolution of each transaction statement.
17. The apparatus as claimed in claim 16, wherein the effective dependency obtaining module is configured to, when determining the effective dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction declaration, specifically:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not unset, calculating a union of the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement, and subtracting the explicit dependence resolution of the target intelligent contract of the transaction and the explicit dependence resolution of the transaction statement from the union to obtain the effective dependency of the transaction.
18. The apparatus as claimed in claim 16, wherein the effective dependency obtaining module is configured to, when determining the effective dependency of each transaction according to the dependency and the dependency resolution of the target intelligent contract of each transaction and the dependency resolution of each transaction declaration, specifically:
for any transaction in each transaction, when the dependency of the target intelligent contract of the transaction and the dependency of the transaction statement are not set, determining that the effective dependency of the transaction is not set;
for any transaction in each transaction, when one of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement is not set, subtracting the explicit dependency resolution of the target intelligent contract of the any transaction and the explicit dependency resolution of the any transaction statement from the other of the dependency of the target intelligent contract of the any transaction and the dependency of the any transaction statement to obtain the effective dependency of the any transaction.
19. The apparatus of claim 15, wherein the transaction bucket allocation module is specifically configured to:
for any transaction in said each transaction, assigning a separate transaction bucket for said any transaction when the valid dependencies of said any transaction are irrelevant.
20. The apparatus of claim 15, wherein the transaction bucket allocation module is specifically configured to:
for any transaction in each transaction, when the effective dependency of the transaction is not set, allocating the transaction to a transaction bucket for storing at least one transaction of which the effective dependency is not set;
for any transaction in each transaction, when the effective dependency of the transaction is one or more addresses, the transaction is allocated to a transaction bucket for storing transactions with the same effective dependency.
21. The apparatus of claim 19 or 20, wherein the transaction bucket allocation module is further to:
when a transaction bucket for allocation does not exist, a corresponding transaction bucket is created.
22. The apparatus of claim 15, wherein the transaction execution module is specifically configured to:
one thread is created for each transaction bucket, and the respective threads execute transactions in each transaction bucket in parallel.
23. The apparatus of claim 15, wherein the transaction execution module is specifically configured to:
creating a plurality of threads, wherein each thread corresponds to at least one transaction bucket for storing transactions with irrelevant effective dependency relationships, and/or each thread corresponds to at least one transaction bucket for storing transactions with the same effective dependency relationships;
the respective threads execute transactions in a corresponding plurality of transaction buckets in parallel.
24. The apparatus of claim 15, further comprising:
and the state data updating module is used for updating the effective dependency relationship to the world state data of the block chain network.
25. The apparatus of claim 15, further comprising:
the transaction execution checking module is used for judging whether the dependency used in the execution of the transaction in each transaction bucket is consistent with the effective dependency or not; if yes, determining that the transaction is successfully executed; otherwise, the transaction execution is determined to have failed.
26. The apparatus of claim 25, wherein the transaction execution verification module is further to:
after the transaction execution failure is determined, if the dependency relationship and/or the dependency resolution of the target intelligent contract are determined to have the error to cause the transaction execution failure, the dependency relationship and/or the dependency resolution of the target intelligent contract are corrected, and if the dependency resolution of the transaction statement is determined to cause the transaction execution failure, a processing flow for punishing a transaction initiator is executed.
27. An electronic device comprising a memory and a processor, the memory for storing computer instructions, wherein the computer instructions are executable by the processor to implement the method of any one of claims 1-14.
28. A readable storage medium having stored thereon computer instructions, which when executed by a processor, implement the method of any one of claims 1-14.
CN202110145817.8A 2021-02-03 2021-02-03 Block chain parallel transaction execution method and device and electronic equipment Pending CN112508574A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110145817.8A CN112508574A (en) 2021-02-03 2021-02-03 Block chain parallel transaction execution method and device and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110145817.8A CN112508574A (en) 2021-02-03 2021-02-03 Block chain parallel transaction execution method and device and electronic equipment

Publications (1)

Publication Number Publication Date
CN112508574A true CN112508574A (en) 2021-03-16

Family

ID=74952522

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110145817.8A Pending CN112508574A (en) 2021-02-03 2021-02-03 Block chain parallel transaction execution method and device and electronic equipment

Country Status (1)

Country Link
CN (1) CN112508574A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024007690A1 (en) * 2022-07-08 2024-01-11 腾讯科技(深圳)有限公司 Blockchain-based transaction processing method, apparatus and device, and computer-readable storage medium and computer program product

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106980649A (en) * 2017-02-28 2017-07-25 阿里巴巴集团控股有限公司 The method and apparatus and business subclass for writing block chain business datum determine method
US20170212781A1 (en) * 2016-01-26 2017-07-27 International Business Machines Corporation Parallel execution of blockchain transactions
CN107688999A (en) * 2017-08-11 2018-02-13 杭州秘猿科技有限公司 A kind of parallel transaction based on block chain performs method
CN108564470A (en) * 2018-04-17 2018-09-21 北京天德科技有限公司 The transaction distribution method of block is built in a kind of block chain parallel
CN110135985A (en) * 2019-04-04 2019-08-16 杭州抖音科技有限公司 A kind of parallel execution method and system traded on block chain
CN110532038A (en) * 2019-08-19 2019-12-03 杭州趣链科技有限公司 A kind of parallel execution method based on Java intelligence contract
CN110728578A (en) * 2019-09-29 2020-01-24 南京金宁汇科技有限公司 Parallel execution method, system and storage medium for block chain transaction
CN110968437A (en) * 2019-11-27 2020-04-07 杭州趣链科技有限公司 Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
CN112037061A (en) * 2020-08-31 2020-12-04 深圳前海微众银行股份有限公司 Processing method and device for transactions in block chain, electronic equipment and storage medium
CN112150163A (en) * 2020-11-26 2020-12-29 北京微芯区块链与边缘计算研究院 Block chain contract transaction parallel execution method and device

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20170212781A1 (en) * 2016-01-26 2017-07-27 International Business Machines Corporation Parallel execution of blockchain transactions
CN106980649A (en) * 2017-02-28 2017-07-25 阿里巴巴集团控股有限公司 The method and apparatus and business subclass for writing block chain business datum determine method
CN107688999A (en) * 2017-08-11 2018-02-13 杭州秘猿科技有限公司 A kind of parallel transaction based on block chain performs method
CN108564470A (en) * 2018-04-17 2018-09-21 北京天德科技有限公司 The transaction distribution method of block is built in a kind of block chain parallel
CN110135985A (en) * 2019-04-04 2019-08-16 杭州抖音科技有限公司 A kind of parallel execution method and system traded on block chain
CN110532038A (en) * 2019-08-19 2019-12-03 杭州趣链科技有限公司 A kind of parallel execution method based on Java intelligence contract
CN110728578A (en) * 2019-09-29 2020-01-24 南京金宁汇科技有限公司 Parallel execution method, system and storage medium for block chain transaction
CN110968437A (en) * 2019-11-27 2020-04-07 杭州趣链科技有限公司 Method, device, equipment and medium for parallel execution of single contract based on Java intelligent contract
CN112037061A (en) * 2020-08-31 2020-12-04 深圳前海微众银行股份有限公司 Processing method and device for transactions in block chain, electronic equipment and storage medium
CN112150163A (en) * 2020-11-26 2020-12-29 北京微芯区块链与边缘计算研究院 Block chain contract transaction parallel execution method and device

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2024007690A1 (en) * 2022-07-08 2024-01-11 腾讯科技(深圳)有限公司 Blockchain-based transaction processing method, apparatus and device, and computer-readable storage medium and computer program product

Similar Documents

Publication Publication Date Title
US9830194B2 (en) Migrating processes operating on one platform to another platform in a multi-platform system
US11500626B2 (en) Intelligent automatic merging of source control queue items
CN111882435B (en) Method and device for executing transaction in block chain
EP2454666B1 (en) Fault tolerant batch processing
KR100950814B1 (en) System and method to accelerate identification of hardware platform classes
CN105190536B (en) It is a kind of for verifying the system and method for operation
CN111932257B (en) Block chain parallelization processing method and device
WO2024119763A1 (en) Computing power scheduling method for container cluster, and related apparatus
WO2024120205A1 (en) Method and apparatus for optimizing application performance, electronic device, and storage medium
US11100047B2 (en) Method, device and computer program product for deleting snapshots
CA3147339C (en) Method and device for writing blockchain data in parallel, computer equipment and storage medium thereof
CN111125040A (en) Method, apparatus and storage medium for managing redo log
US11399071B2 (en) Program operation system and program operation method
EP3731454A2 (en) Method and apparatus for continuous delivery of permissioned blockchain application
CN115242598A (en) Cloud operating system deployment method and device
JP5845810B2 (en) Efficient partial computation for parallel analysis of software in distributed computing environments
CN112508574A (en) Block chain parallel transaction execution method and device and electronic equipment
US11983168B2 (en) Block verification method, apparatus and device
JP2011192049A (en) Virtual machine system, automatic migration method, and automatic migration program
WO2021129005A1 (en) Blockchain state change-based transaction tracking method and device
CN114356768A (en) Method and device for reducing transaction read-write conflict through placeholder
CN113821157B (en) Local disk mounting method, device, equipment and storage medium
CN109359093A (en) A kind of rule file update method and system
CN111371818A (en) Data request verification method, device and equipment
US11914603B2 (en) Data layout model generation system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20210316

RJ01 Rejection of invention patent application after publication