CN113034142B - Transaction data processing method and device and computer equipment - Google Patents

Transaction data processing method and device and computer equipment Download PDF

Info

Publication number
CN113034142B
CN113034142B CN202110442672.8A CN202110442672A CN113034142B CN 113034142 B CN113034142 B CN 113034142B CN 202110442672 A CN202110442672 A CN 202110442672A CN 113034142 B CN113034142 B CN 113034142B
Authority
CN
China
Prior art keywords
transaction
service
transaction service
services
data set
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
CN202110442672.8A
Other languages
Chinese (zh)
Other versions
CN113034142A (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.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen 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 Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN202110442672.8A priority Critical patent/CN113034142B/en
Publication of CN113034142A publication Critical patent/CN113034142A/en
Application granted granted Critical
Publication of CN113034142B publication Critical patent/CN113034142B/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
    • 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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/20Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
    • G06F16/27Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/64Protecting data integrity, e.g. using checksums, certificates or signatures

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Business, Economics & Management (AREA)
  • Computer Security & Cryptography (AREA)
  • Physics & Mathematics (AREA)
  • Accounting & Taxation (AREA)
  • Databases & Information Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Business, Economics & Management (AREA)
  • Computing Systems (AREA)
  • Finance (AREA)
  • Strategic Management (AREA)
  • Data Mining & Analysis (AREA)
  • Health & Medical Sciences (AREA)
  • Bioethics (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Hardware Design (AREA)
  • Software Systems (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a transaction data processing method, a device and computer equipment, wherein the method comprises the following steps: acquiring a first transaction service from N transaction services to be packaged; performing conflict detection on the first transaction service based on the transaction execution sequence of the first transaction service, the read data set corresponding to the first transaction service and a conflict detection condition; if the transaction service meeting the conflict detection condition exists, taking the transaction service meeting the conflict detection condition as a forward dependent service, and recording a service dependency relationship between the first transaction service and the forward dependent service; and constructing directed acyclic graphs associated with the N transaction services based on the recorded service dependency relationship, and sending the packaged proposed blocks carrying the directed acyclic graphs to a second node, so that the second node executes the N transaction services in series or in parallel based on the directed acyclic graphs in the proposed blocks. By adopting the method and the device, the transaction service can be executed in parallel, and the throughput of the block chain can be improved.

Description

Transaction data processing method and device and computer equipment
The present application is a divisional application of the chinese patent application filed on 29/01/29/2021 under the name of "a transaction data processing method, apparatus and computer device" by the chinese patent office under the application number 202110122558.7, the entire contents of which are incorporated herein by reference.
Technical Field
The present application relates to the field of computer technologies, and in particular, to a transaction data processing method and apparatus, and a computer device.
Background
A block may be composed of multiple transaction services, and before the block is written into the block chain by the packaging node, the block needs to be identified by the common nodes in the common network, that is, the common nodes are needed to perform transaction verification on each transaction service in the block.
It can be understood that when the consensus nodes perform transaction verification on the transaction services in the block, the transaction services (e.g., transaction service 1, transaction service 2, and transaction service 3) often need to be executed serially according to the transaction execution sequence of the transaction services. For example, each consensus node needs to execute transaction service 1 before transaction service 2 can be executed, and can continue to execute transaction service 3 after transaction service 2 is executed. Therefore, when the common identification nodes traverse and execute the transaction services in the block according to the transaction execution sequence, longer service execution time is inevitably consumed, so that the execution efficiency of the transaction services is reduced, and the common identification performance of the common identification nodes is reduced, so that the throughput of the block chain is reduced.
Disclosure of Invention
The embodiment of the application provides a transaction data processing method, a transaction data processing device and computer equipment, which can realize parallel execution of transaction services and improve the throughput of a block chain.
One aspect of the embodiments of the present application provides a transaction data processing method, including:
acquiring a first transaction service from N transaction services to be packaged, and acquiring a read data set corresponding to the first transaction service; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
determining a transaction execution sequence of the first transaction service in the N transaction services, and performing conflict detection on the first transaction service based on the transaction execution sequence, a read data set corresponding to the first transaction service and a conflict detection condition to obtain a conflict detection result;
if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the N transaction services, taking the transaction service meeting the conflict detection condition as a forward dependent service associated with the first transaction service, and recording a service dependency relationship between the first transaction service and the forward dependent service;
constructing a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, packaging the directed acyclic graph and the N transaction services to obtain an offer block carrying the directed acyclic graph, and sending the offer block to a second node so that the second node executes the N transaction services in series or in parallel based on the service dependency relationship indicated by the directed acyclic graph in the offer block; the second node belongs to a consensus node in the blockchain network to which the first node belongs.
An aspect of an embodiment of the present application provides a transaction data processing apparatus, including:
the first obtaining module is used for obtaining a first transaction service from the N transaction services to be packaged and obtaining a read data set corresponding to the first transaction service; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
the conflict detection module is used for determining a transaction execution sequence of the first transaction service in the N transaction services, and performing conflict detection on the first transaction service based on the transaction execution sequence, the read data set corresponding to the first transaction service and a conflict detection condition to obtain a conflict detection result;
the dependency recording module is used for taking the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service and recording a service dependency relationship between the first transaction service and the forward dependency service if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the N transaction services;
the block sending module is used for constructing a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, packaging the directed acyclic graph and the N transaction services to obtain an proposed block carrying the directed acyclic graph, and sending the proposed block to the second node so that the second node executes the N transaction services in series or in parallel based on the service dependency relationship indicated by the directed acyclic graph in the proposed block; the second node belongs to a consensus node in the blockchain network to which the first node belongs.
The first transaction service is to-be-executed transaction service acquired from the N transaction services, and a transaction read cache corresponding to the first transaction service comprises a read data set corresponding to the first transaction service;
the collision detection module includes:
the sequence determining unit is used for acquiring a transaction identifier configured for each transaction service in the N transaction services, determining the identifier position of the transaction identifier of the first transaction service in the transaction identifiers of the N transaction services, and determining the transaction execution sequence of the first transaction service based on the identifier position;
the transaction searching unit is used for searching the transaction services with the transaction execution sequence earlier than that of the first transaction service in the N transaction services and taking the searched transaction services as the preamble transaction services associated with the first transaction service; the preamble transaction service is an executed transaction service acquired from the N transaction services;
the write set acquisition unit is used for acquiring a transaction write cache of the preorder transaction service and acquiring a write data set corresponding to the preorder transaction service from the transaction write cache;
and the conflict detection unit is used for carrying out conflict detection on the first transaction service based on the write data set corresponding to the preorder transaction service, the read data set corresponding to the first transaction service and the conflict detection condition to obtain a conflict detection result.
Wherein, the device still includes:
the second acquisition module is used for acquiring a first transaction service from the N transaction services, executing the first transaction service based on a read data set corresponding to the first transaction service to obtain a first service execution result of the first transaction service, adding the first service execution result to a first transaction write cache of the first transaction service, and constructing a write data set corresponding to the first transaction service based on data stored in the first transaction write cache; the transaction execution sequence of the first transaction service is earlier than that of the first transaction service, and the first transaction service is used as a preamble transaction service of the first transaction service.
Wherein, the conflict detection unit includes:
the data comparison subunit is used for comparing the character string of the read data set corresponding to the first transaction service with the character string of the write data set corresponding to the preorder transaction service to obtain a character string comparison result;
the first comparison subunit is used for determining the pre-order transaction service with the overlapped character string as a target pre-order transaction service meeting the conflict detection condition if the character string comparison result indicates that the overlapped character string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the pre-order transaction service;
the field determining subunit is used for adding the transaction index value of the first transaction service to an initial transaction subfield corresponding to a history key field of a target preamble transaction service to obtain a target transaction subfield of the target preamble transaction service, and performing incremental processing on the dependence number in a transaction parent field of the first transaction service in the target key field of the first transaction service to obtain an incremental transaction parent field;
and the result determining subunit is used for taking the target transaction subfield of the target preamble transaction service and the increased transaction parent field as a conflict detection result associated with the first transaction service.
Wherein, the conflict detection unit further comprises:
the second comparison subunit is used for determining the preorder transaction service as the transaction service which does not meet the conflict detection condition if the character string comparison result indicates that no overlapping character string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preorder transaction service, setting the dependency number in the transaction parent field of the first transaction service as a target threshold value in the target key field of the first transaction service based on the transaction service which does not meet the conflict detection condition, adding the first transaction service to the parallel transaction data set to which the first transaction service belongs based on the target threshold value, and acquiring a second transaction service for updating the first transaction service from the N transaction services; the transaction execution sequence of the second transaction service is later than that of the first transaction service; the dependency number of each transaction service in the parallel transaction data set is a target threshold, a parallel dependency relationship exists between each transaction service in the parallel transaction data set, and the parallel dependency relationship is used for updating the service dependency relationship.
The business dependency relationship comprises a serial dependency relationship and a parallel dependency relationship; the parallel dependency relationship is determined by the transaction service in the parallel transaction data set to which the first transaction service belongs; the serial dependency is determined by a forward dependency associated with the first transaction;
the block transmission module includes:
the first acquisition unit is used for selecting the transaction service corresponding to the transaction parent field carrying the target threshold value from the N transaction services based on the parallel dependency relationship in the recorded service dependency relationship, and taking the selected transaction service as a first connection service; the first connection service comprises a first transaction service;
a second obtaining unit, configured to obtain, based on a serial dependency relationship in the recorded service dependency relationships, a sub-transaction list associated with the first connection service from a target transaction subfield of the first connection service; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N;
and the acyclic graph constructing unit is used for constructing and obtaining a directed acyclic graph associated with the N transaction services based on the first connection services and the M second connection services, packaging the directed acyclic graph and the N transaction services to obtain an proposal block carrying the directed acyclic graph, and sending the proposal block to the second node.
Wherein, the device still includes:
and the contract calling module is used for acquiring an intelligent contract for executing the first transaction service based on a contract calling address and a contract name in the read data set corresponding to the first transaction service, calling the intelligent contract to execute the first transaction service to obtain a transaction service execution result corresponding to the first transaction service, adding the transaction service execution result to a transaction write cache of the first transaction service, and constructing a write data set corresponding to the first transaction service based on data stored in the transaction write cache.
One aspect of the embodiments of the present application provides a transaction data processing method, including:
receiving an proposed block which is sent by a first node and carries a directed acyclic graph; the directed acyclic graph is constructed based on business dependency relations among the N transaction businesses in the proposal block; the business dependency relationship is determined by the first transaction business and the forward dependency business related to the first transaction business after the first transaction business is obtained from the N transaction businesses; the forward dependency service is obtained by performing conflict detection on the first transaction service based on a transaction execution sequence of the first transaction service in the N transaction services, a read data set corresponding to the first transaction service and a conflict detection condition; the first node belongs to a packing node in a blockchain network to which the second node belongs; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
based on a business dependency relationship indicated by a directed acyclic graph, selecting a transaction business meeting a transaction execution condition from N transaction businesses, taking the selected transaction business as a first connection business, and acquiring a sub-transaction list associated with the first connection business; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N; the first connection service comprises a first transaction service;
and constructing an auxiliary acyclic graph associated with the N transaction services in the proposal block based on the first connection service and the M second connection services, and carrying out legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
An aspect of an embodiment of the present application provides a transaction data processing apparatus, including:
the block receiving module is used for receiving an proposed block which is sent by a first node and carries a directed acyclic graph; the directed acyclic graph is constructed based on business dependency relations among the N transaction businesses in the proposal block; the business dependency relationship is determined by the first transaction business and the forward dependency business related to the first transaction business after the first transaction business is obtained from the N transaction businesses; the forward dependency service is obtained by performing conflict detection on the first transaction service based on a transaction execution sequence of the first transaction service in the N transaction services, a read data set corresponding to the first transaction service and a conflict detection condition; the first node belongs to a packing node in a blockchain network to which the second node belongs; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
the transaction selection module is used for selecting transaction services meeting transaction execution conditions from the N transaction services based on the service dependency relationship indicated by the directed acyclic graph, taking the selected transaction services as first connection services, and acquiring a sub-transaction list associated with the first connection services; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N;
and the legal verification module is used for constructing an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first connection service and the M second connection services, and carrying out legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
Wherein, the legal verification module includes:
the first execution unit is used for respectively transmitting the first connection service and the M second connection services to a transaction execution coroutine pool associated with the transaction coordinator through the transaction coordinator, taking the coroutine in an idle state as a first coroutine when the coroutine in the idle state exists in the transaction execution coroutine pool, and executing the first connection service through the first coroutine when the business state of the first coroutine is a working state to obtain a first transaction execution result corresponding to the first connection service;
the transaction determining unit is used for carrying out descending processing on the dependent quantity of the transaction parent field of each second connection service in the M second connection services based on the first transaction execution result, and taking each second connection service subjected to descending processing as a service to be processed respectively;
the service determining unit is used for searching the service to be processed, the dependency number of the transaction parent field of which reaches the target threshold value in the transaction executing condition, from each service to be processed, and taking the searched service to be processed as the backward dependency service associated with the first connection service;
the second execution unit is used for taking the coroutine in an idle state as a second coroutine in the transaction execution coroutine pool, executing backward dependent services through the second coroutine when the service state of the second coroutine is a working state, obtaining a second transaction execution result corresponding to the backward dependent services, and obtaining a second transaction execution result corresponding to each service to be processed until each service to be processed is executed;
and the legal verification unit is used for constructing auxiliary acyclic graphs associated with the N transaction services in the proposed block based on the first transaction execution result and the second transaction execution result corresponding to each service to be processed, and carrying out legal verification on the directed acyclic graph based on the auxiliary acyclic graphs.
Wherein, the legal verification module also includes:
the coroutine releasing unit is used for releasing the first coroutine in a work queue of the transaction execution coroutine pool based on the first transaction execution result;
and the state switching unit is used for switching the service state of the first coroutine from the working state to an idle state and adding the first coroutine in the idle state to an idle queue corresponding to the transaction execution coroutine pool.
Wherein, the legal verification unit includes:
the first determining subunit is configured to, when the first transaction execution result and the second transaction execution result corresponding to each service to be processed are combined, write the first transaction execution result into a first transaction write cache of the first connection service, and use data written into the first transaction write cache as a first write data set of the first connection service;
the second determining subunit is configured to obtain an ith transaction execution result in a traversal manner in a second transaction execution result corresponding to each service to be processed, write the ith transaction execution result into a second transaction write cache of the ith service to be processed, use data written into the second transaction write cache of the ith service to be processed as a second write data set of the ith service to be processed, obtain a second read data set corresponding to the ith service to be processed in a transaction read cache of the ith service to be processed, and obtain a second read data set of each service to be processed until each service to be processed is executed; i is a non-negative integer less than or equal to M;
an auxiliary construction subunit, configured to construct an auxiliary acyclic graph associated with the N transaction services based on the first write data set of the first connection service and the second read data set of each service to be processed;
and the legality determining subunit is used for performing similar comparison on the auxiliary acyclic graph and the directed acyclic graph to obtain a similar comparison result, and determining the legality of the directed acyclic graph based on the similar comparison result.
Wherein, the legal verification module also includes:
and the node deleting unit is used for calling a consensus committee contract for maintaining the consensus node list when the directed acyclic graph is determined not to have the legality, acquiring the consensus node list through the consensus committee contract, and deleting the node identification of the first node in the consensus node list.
An aspect of an embodiment of the present application provides a computer device, including: a processor and a memory;
the processor is connected with the memory, wherein the memory is used for storing a computer program, and the computer program causes the computer device to execute the method provided by the embodiment of the application when being executed by the processor.
An aspect of the embodiments of the present application provides a computer-readable storage medium, which stores a computer program, where the computer program is adapted to be loaded and executed by a processor, so as to enable a computer device having the processor to execute the method provided by the embodiments of the present application.
An aspect of an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions stored in a computer-readable storage medium. The processor of the computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions to cause the computer device to execute the method provided by the embodiment of the application.
In this embodiment of the present application, a first node (i.e., a packing node) having a block packing function may use a currently acquired transaction service to be executed as a first transaction service from N transaction services to be packed, and may acquire a read data set corresponding to the first transaction service. The first transaction service may be a transaction service other than the first transaction service among N transaction services, where N may be a positive integer. Further, the first node may determine a transaction execution order of the first transaction service among the N transaction services, and further may perform collision detection on the first transaction service based on the transaction execution order, the read data set corresponding to the first transaction service, and the collision detection condition to obtain a collision detection result. Further, if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the N transaction services, the first node may use the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service, and further record a service dependency relationship between the first transaction service and the forward dependency service, so that a service dependency relationship between each transaction service and its respective forward dependency service may be obtained. Further, the first node may construct a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, and may package the directed acyclic graph and the N transaction services to obtain an offered block carrying the directed acyclic graph, and send the offered block to the second node (i.e., a consensus node in a block chain network to which the packaged node belongs), so that the second node may execute the N transaction services in parallel and in series based on the service dependency relationship indicated by the directed acyclic graph in the offered block. Therefore, in the embodiment of the present application, a first node (i.e., a packaging node) may serially execute N transaction services to be packaged according to a transaction execution sequence, and may determine a service dependency relationship between N transaction services in the same block according to a read data set and a write data set of each transaction service recorded in a process of serially executing each transaction service, and further obtain an proposed block carrying a directed acyclic graph after constructing and obtaining a directed acyclic graph according to the service dependency relationships, which may ensure as much as possible that other common nodes (i.e., second nodes) in a block chain network to which the first node belongs may quickly parallel and serially connect the N transaction services in the proposed block based on the service dependency relationship indicated by the directed acyclic graph, and obviously, the N transaction service strings may be reasonably combined through a directed acyclic graph obtained by the second node, therefore, under the condition of small transaction conflict amount, most transaction services in the N transaction services can be executed in parallel as much as possible, so that the consensus performance of the consensus nodes in the block chain network can be improved, and the throughput of the block chain can be effectively improved.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a schematic block link point system according to an embodiment of the present disclosure;
fig. 2 is a schematic view of a scenario for performing data interaction according to an embodiment of the present application;
FIG. 3 is a schematic flow chart diagram illustrating a transaction data processing method according to an embodiment of the present disclosure;
fig. 4 is a schematic view of a scenario for performing collision detection according to an embodiment of the present application;
fig. 5 is a schematic flowchart illustrating a process of performing conflict detection on a transaction service according to an embodiment of the present application;
FIG. 6 is a schematic diagram of a scenario for constructing a directed acyclic graph according to an embodiment of the present disclosure;
fig. 7 is a schematic view of a scenario for processing a transaction service according to an embodiment of the present application;
FIG. 8 is a schematic flow chart diagram illustrating a transaction data processing method according to an embodiment of the present disclosure;
fig. 9 is a schematic view of a scenario for acquiring a transaction service according to an embodiment of the present application;
fig. 10 is a schematic view of a scenario of scheduling transaction services according to an embodiment of the present application;
FIG. 11 is a schematic diagram of a scenario for performing transaction services serially and in parallel according to an embodiment of the present disclosure;
fig. 12 is a schematic structural diagram of a transaction data processing device according to an embodiment of the present application;
fig. 13 is a schematic structural diagram of a transaction data processing device according to an embodiment of the present application;
fig. 14 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
Specifically, please refer to fig. 1, in which fig. 1 is a schematic structural diagram of a block link point system according to an embodiment of the present disclosure. The block chain is a novel application mode of computer technologies such as distributed data storage, point-to-point transmission, a consensus mechanism and an encryption algorithm, and is mainly used for sorting data according to a time sequence and encrypting the data into an account book, so that the data cannot be falsified or forged, and meanwhile, the data can be verified, stored and updated. The blockchain is essentially a decentralized database, each node in the database stores an identical blockchain, and the blockchain network includes a consensus node, which is responsible for the consensus of the blockchain network.
It is understood that a Block (Block) is a data packet carrying transaction data (i.e., transaction traffic) over a blockchain network, and is a data structure that is tagged with a timestamp and a hash value of a previous Block, which verifies and determines the transaction in the Block via a consensus mechanism of the network.
It is understood that the blockchain system may include intelligent contracts, which may be understood in the blockchain system as code that nodes (including common nodes) of the blockchain can understand and execute, and may execute any logic and obtain a result. It should be understood that one or more intelligent contracts may be included in the block chain, and these intelligent contracts may be distinguished by identification numbers (IDs) or names, and the transaction service request may carry the identification numbers or names of the intelligent contracts, so as to specify the intelligent contracts that the block chain needs to run.
The blockchain link point system as shown in fig. 1 may correspond to a blockchain network, which may include, but is not limited to, a blockchain network corresponding to a federation chain. The blockchain node system refers to a system for sharing data between blockchain link points and blockchain nodes, and the blockchain link point system may include a plurality of nodes, where the plurality of nodes may specifically include node 10a, node 10b, node 10 c.
Each node may receive input information during normal operation and maintain shared data within the block-node system based on the received input information. In order to ensure information intercommunication in the block link point system, information connection can exist between each node in the block link point system, and information transmission can be carried out between the nodes through the information connection. For example, when any node in the blockchain node system receives input information, other nodes in the blockchain node system acquire the input information according to a consensus algorithm, and store the input information as data in shared data, so that the data stored in all nodes in the blockchain node system are consistent.
It should be understood that the information connection is not limited to the connection manner, and may be directly or indirectly connected through a wired communication manner, may be directly or indirectly connected through a wireless communication manner, and may also be connected through other connection manners, which is not limited herein.
It can be understood that the blockchain network may implement information connection between nodes based on node identifiers, each node in the blockchain node system has a node identifier corresponding thereto, and each node in the blockchain node system may store node identifiers of other nodes in the blockchain node system, so as to broadcast a generated block to other nodes in the blockchain node system according to the node identifiers of other nodes in the subsequent process. Each node may maintain a node identifier list as shown in the following table, and store the node name and the node identifier in the node identifier list correspondingly.
TABLE 1
Node name Node identification
Node 1 117.114.151.174
Node 2 117.116.189.145
... ...
Node J 119.123.789.258
The node identifier may be an IP (Internet Protocol ) address and any other information that can be used to identify a node in the blockchain network, and table 1 only illustrates the IP address as an example. For example, node 1 (e.g., node 1 may be node 10a shown in fig. 1) may send information (e.g., a chunk) to node 2 (e.g., node 2 may be node 10b shown in fig. 1) via node identification 117.116.189.145, and node 2 may determine that the information was sent by node 1 via node identification 117.114.151.174.
It is understood that the transaction data processing method provided by the embodiment of the present application can be executed by a computer device, including but not limited to a terminal or a server. The server may be an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, or a cloud server providing basic cloud computing services such as cloud service, a cloud database, cloud computing, a cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, big data and artificial intelligence platform. The terminal may be a mobile phone, a tablet computer, a notebook computer, a palm computer, an intelligent sound, a mobile internet device (MID, a Point Of sale) machine, a wearable device (e.g., an intelligent watch, an intelligent bracelet, etc.), and the like.
It should be understood that in the blockchain, before a block (i.e. a proposed block, a block to be uplink) is uplink, the block must pass through a common node in the blockchain network for common identification, and the block is added to the blockchain after the common identification is passed. It will be appreciated that when blockchains are used in some scenarios of government or commercial establishments, not all participating nodes in the blockchain (i.e., the blockchain link points in the above-described blockchain node system) have sufficient resources and necessity to be consensus nodes of the blockchain. For example, in the block-linked node system shown in fig. 1, the node 10a, the node 10b, and the node 10c may be considered as common nodes in the block-linked node system, where the node 10a may be considered as a packing node for packing to generate a block, and the node 10b and the node 10c may be considered as common nodes participating in common.
It can be understood that, the packing node where the block chain is located (the packing node belongs to the consensus node) may send the newly generated block (i.e., the proposed block) to other consensus nodes in the block chain link point system where the packing node is located respectively according to the node identifiers of the other consensus nodes in the block chain link point system, the consensus nodes perform consensus on the newly generated block, and add the newly generated block to the block chain stored by the block chain after the consensus is successful.
It should be understood that the first node and the second node in the embodiments of the present application may be common nodes in a blockchain network. The first node may be a packing node in a blockchain network. Therefore, in the embodiment of the present application, the block chain nodes that perform the packaging processing on the transaction traffic may be collectively referred to as a first node (i.e., a packaging node, for example, the node 10a shown in fig. 1), and the block chain nodes that share the blocks obtained by the packaging processing may also be collectively referred to as a second node (i.e., a sharing node, for example, the node 10b and the node 10c shown in fig. 1).
For easy understanding, please refer to fig. 2, and fig. 2 is a schematic diagram of a scenario for performing data interaction according to an embodiment of the present application. The first node shown in fig. 2 may be the node 10a in the embodiment corresponding to fig. 1, and the second node shown in fig. 2 may be the node 10b in the embodiment corresponding to fig. 2. As shown in fig. 2, the first node may include N transaction services to be packaged, where the N transaction services may specifically include transaction 2a, transaction 2b, …, and transaction 2N. Wherein the transaction transactions (i.e., transaction 2a, transaction 2b, …, transaction 2n) may be arranged in transaction execution order. For example, as shown in FIG. 2, transaction execution order 1 for transaction 2a may be earlier than transaction execution order 2 for transaction 2b, transaction execution order 2 for transaction 2b may be earlier than transaction execution order 3 for transaction 2c (not shown), and so on, transaction execution order (n-1) for transaction 2(n-1) (not shown) may be earlier than transaction execution order n for transaction 2 n.
It is understood that the first node may traverse the N transaction transactions to obtain the transaction to be executed. For example, the first node may obtain a first transaction (e.g., transaction 2a) from the N transactions. Since the transaction execution sequence of the transaction 2a is the transaction execution sequence 1, the first node may obtain the read dataset 1 corresponding to the transaction 2a, and execute the transaction 2a directly based on the read dataset 1 corresponding to the transaction 2a to obtain the first service execution result of the transaction 2a, that is, the first node may obtain the conflict detection result (e.g., result 1) of the transaction 2a based on that the conflict detection does not need to be performed on the transaction 2 a.
It should be appreciated that after the first node has executed transaction 2a, transaction 2a will evolve to be a precursor transaction to other transaction transactions to be executed (e.g., transaction 2 b). Therefore, when the first node acquires a new transaction service to be executed (for example, the transaction 2b shown in fig. 2) from the N transaction services as the first transaction service, the read data set 2 corresponding to the transaction 2b may be acquired, and the transaction execution order of the transaction 2b may be determined to be the transaction execution order 2 in the N transaction services, and then collision detection may be performed on the transaction 2b (for example, whether an overlapping character string exists between the transaction 2b and a preceding transaction service (for example, the transaction 2a) of the transaction 2b may be determined) based on the read data set 2, the transaction execution order 2, and the collision detection condition, so as to obtain a collision detection result (for example, the result 2) of the transaction 2 b.
Further, the first node may determine forward dependent traffic associated with transaction 2b based on result 2. For example, assuming that there is an overlapping string between the transaction 2a (i.e., the preceding transaction service of the transaction 2b) and the transaction 2b, the first node may determine the transaction 2a as the forward dependent service associated with the transaction 2b based on the result 2, and record the service dependency relationship between the transaction 2b and the forward dependent service (i.e., the transaction 2 a).
It should be appreciated that after the first node has executed transaction 2b, transaction 2b will evolve to be a precursor transaction to other transactions to be executed (e.g., transaction 2c, not shown in the figure). Similarly, the first node may further continue to acquire another transaction service to be executed (e.g., transaction 2c) from the N transaction services as a new first transaction service (this new first transaction service may be referred to as a second transaction service in this embodiment), acquire the read data set 3 corresponding to the transaction 2c, determine the transaction execution order 3 of the transaction 2c in the N transaction services, and perform conflict detection on the transaction 2c based on the read data set 3, the transaction execution order 3, and a conflict detection condition (for example, it may be determined whether there is an overlapping character string between the transaction 2c and the transaction service of the transaction 2c (e.g., the transaction 2a and the transaction 2b described above), so as to obtain a conflict detection result (e.g., result 3) of the transaction 2 c.
Further, the first node may determine forward dependent traffic associated with transaction 2c based on result 3. For example, assuming that there is an overlapping string between the transaction 2c and the preceding transaction services of the transaction 2c (e.g., the transaction 2a and the transaction 2b), the first node may regard the transaction 2a and the transaction 2b as the forward dependent services associated with the transaction 2c and record the service dependency relationship between the transaction 2c and the forward dependent services (i.e., the transaction 2a and the transaction 2b) based on the result 3.
By analogy, the first node may further traverse the acquired other to-be-executed transaction services (e.g., transaction 2d, …, transaction 2N) from the N transaction services to be respectively used as first transaction services to perform conflict detection on the transactions 2d, …, and transaction 2N, respectively, and further may determine, based on a conflict detection result (e.g., result 4, …, and result N) of each transaction service, a forward dependency service associated with each transaction service, and further may record a service dependency relationship between the other to-be-executed transaction services (e.g., transaction 2d, …, transaction 2N) and the forward dependency service associated therewith.
The method and the device for processing the transaction data have the advantages that the number of dependencies corresponding to the transaction parent field of the currently executed first transaction service can be increased when the conflict detection result indicates that the forward dependency service associated with the currently executed first transaction service exists.
Optionally, when the conflict detection result indicates that there is no forward dependency service associated with the currently executed first transaction service, the embodiment of the present application may further set, in the target key field of the currently executed first transaction service, the dependency number corresponding to the transaction parent field of the currently executed first transaction service to be a target threshold (for example, set to 0), which means that the currently executed first transaction service is not dependent on each preceding transaction service whose transaction execution sequence is before it. At this time, the first node may further acquire a second transaction service for updating the first transaction service (for example, the above-mentioned transaction 2b) from the N transaction services. For example, the second transaction service may be transaction 2c, which is executed later than transaction 2 b.
Further, the first node may construct a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, package the directed acyclic graph and the N transaction services to obtain an offer block including the directed acyclic graph, and send the offer block including the directed acyclic graph to the second node. Therefore, when receiving an proposed block carrying a directed acyclic graph sent by a first node, a second node may obtain a first connection service meeting a transaction execution condition based on a service dependency relationship indicated by the directed acyclic graph in the proposed block, obtain M second connection services in a sub-transaction list associated with the first connection service, obtain a first write data set of the first connection service and a second read data set of each second connection service in the M second connection services, construct an auxiliary acyclic graph associated with N transaction services based on the first write data set and the second read data set, and further perform validation on the directed acyclic graph received from the first node based on the auxiliary acyclic graph constructed at the second node to obtain a validation result. The first connection service includes a first transaction service (i.e., transaction 2a), where M may be a non-negative integer smaller than N.
The second node may execute the first connection service and the M second connection services in series, may execute the first connection service satisfying the transaction execution condition in parallel, and may execute the M second connection services in parallel, so that the N transaction services in the proposed block are executed in the second node in a manner of combining serial and parallel, which may save computation and memory consumption in the second node, thereby improving the execution efficiency of the second node on the transaction services, and further improving the performance of the block chain. In addition, the execution results of the N transaction services in the proposed block can be kept consistent in all block chain nodes by carrying out legal verification on the directed acyclic graph through the auxiliary acyclic graph.
For example, the following description of the embodiments corresponding to fig. 3 to fig. 11 may be referred to, where the specific process of the first node constructing the directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, and the specific process of the second node executing the N transaction services in parallel or in series based on the service dependency relationship indicated by the directed acyclic graph.
Further, please refer to fig. 3, wherein fig. 3 is a schematic flow chart of a transaction data processing method according to an embodiment of the present application. The method may be performed by a first node (e.g., block chain node 10a shown in fig. 1, described above), may be performed by a second node (e.g., block chain node 10b shown in fig. 1, described above), or may be performed by both the first node and the second node. For ease of understanding, the present embodiment is described with the method being performed by the first node as an example. The transaction data processing method at least comprises the following steps S101-S104:
step S101, acquiring a first transaction service from N transaction services to be packaged, and acquiring a read data set corresponding to the first transaction service;
the first node may sequentially obtain the transaction services to be executed from the N transaction services to be packaged, and use the transaction services to be executed as first transaction services, where the first transaction services may be transaction services other than a first transaction service in the N transaction services, and where N may be a positive integer.
It should be understood that the read data set corresponding to the first transaction service is included in the transaction read cache corresponding to the first transaction service. Therefore, the first node may obtain the read data set corresponding to the first transaction service from the transaction read cache corresponding to the first transaction service, obtain an intelligent contract for executing the first transaction service based on the contract calling address and the contract name in the read data set corresponding to the first transaction service, call the intelligent contract to execute the first transaction service, obtain a transaction service execution result corresponding to the first transaction service, add the transaction service execution result to the transaction write cache of the first transaction service, and further construct a write data set corresponding to the first transaction service based on data stored in the transaction write cache.
It can be understood that the block cache of the N transaction services (i.e., the block cache of the proposed block described below) temporarily stores the transaction results of the N transaction services to be packaged (i.e., the first service execution result corresponding to the first transaction service and the transaction service execution result corresponding to the first transaction service), and based on the block cache, a transaction read cache and a transaction write cache corresponding to the N transaction services can be created, where one transaction service corresponds to one transaction write cache and one transaction read cache, a read data set corresponding to the transaction service is stored in the transaction read cache, and a write data set corresponding to the transaction service is stored in the transaction write cache.
It can be understood that the first node may obtain the first transaction service from the N transaction services, execute the first transaction service based on the read data set corresponding to the first transaction service, obtain a first service execution result of the first transaction service, add the first service execution result to the first transaction write cache of the first transaction service, and construct a write data set corresponding to the first transaction service based on data stored in the first transaction write cache. The transaction execution sequence of the first transaction service is earlier than that of the first transaction service, and the first transaction service is used as a preamble transaction service of the first transaction service.
Step S102, determining a transaction execution sequence of the first transaction service in the N transaction services, and performing conflict detection on the first transaction service based on the transaction execution sequence, a read data set corresponding to the first transaction service and a conflict detection condition to obtain a conflict detection result;
specifically, the first node may obtain a transaction identifier configured for each of the N transaction services, determine an identifier position of the transaction identifier of the first transaction service in the transaction identifiers of the N transaction services, and determine a transaction execution order of the first transaction service based on the identifier position. Further, the first node may search, among the N transaction services, a transaction service whose transaction execution order is earlier than that of the first transaction service, and use the searched transaction service as a preamble transaction service associated with the first transaction service. The preamble transaction service is an executed transaction service acquired from the N transaction services, and the first transaction service is a to-be-executed transaction service acquired from the N transaction services. Further, the first node may obtain a transaction write cache of the preamble transaction service, and obtain a write data set corresponding to the preamble transaction service from the transaction write cache. Further, the first node may perform conflict detection on the first transaction service based on the write data set corresponding to the preamble transaction service, the read data set corresponding to the first transaction service, and the conflict detection condition, so as to obtain a conflict detection result.
It is understood that, the embodiments of the present application may use a transaction service having a transaction execution order earlier than that of the first transaction service as a preceding transaction service associated with the first transaction service, and correspondingly, the embodiments of the present application may use the first transaction service as a subsequent transaction service associated with the preceding transaction service. It is to be understood that the number of preceding transaction services associated with a certain transaction service (e.g., the first transaction service) may be zero, one or more, and the number of subsequent transaction services associated with a certain transaction service (e.g., the first transaction service) may be zero, one or more, which is not limited in this application.
It can be understood that the first node may obtain a read data set corresponding to the preamble transaction service from a transaction read cache corresponding to the preamble transaction service, obtain an intelligent contract for executing the preamble transaction service based on a contract calling address and a contract name in the read data set corresponding to the preamble transaction service, call the intelligent contract to execute the preamble transaction service, obtain a preamble service execution result corresponding to the preamble transaction service, add the preamble service execution result to a transaction write cache of the preamble transaction service, and further may construct a write data set corresponding to the preamble transaction service based on data stored in the transaction write cache. The transaction write cache and the transaction read cache of the preamble transaction service are stored in the block cache corresponding to the proposed block.
For ease of understanding, please refer to fig. 4, and fig. 4 is a schematic diagram of a scenario for performing collision detection according to an embodiment of the present application. The N transaction services shown in fig. 4 may be transaction services to be packaged, where the N transaction services specifically include: transaction 1, …, transaction N-2, transaction N-1, and transaction N, where the N transaction transactions are arranged in transaction execution order.
The first node may configure a transaction identifier for each of the N transaction services according to the transaction timestamps of the N transaction services, and then determine a transaction execution sequence of the N transaction services based on an identifier position of the transaction identifier of each transaction service. For example, the transaction timestamp of transaction 1 may be time T1, …, the transaction timestamp of transaction N-2 may be time T (N-2), the transaction timestamp of transaction N-1 may be time T (N-1), and the transaction timestamp of transaction N may be time TN. Thus, transaction identification for transaction 1 may be "1", …, transaction identification for transaction N-2 may be "N-2", transaction identification for transaction N-1 may be "N-1", and transaction identification for transaction N may be "N".
After the transaction service of the previous transaction identifier is completed, the transaction service of the next transaction identifier is used as a new transaction service to be executed, and the transaction service of the previous transaction identifier is used as an executed transaction service. If the times T1, … and the time TN are arranged in time sequence, that is, the time T1 is earlier than the time TN, the transaction 2 with the transaction number "2" may be processed after the transaction 1 with the transaction number "1" is processed, and the transaction N with the transaction number "N" may be processed … after the transaction N-1 with the transaction number "N-1" is processed.
Alternatively, it may be understood that if the transaction services have the same transaction time stamp, the transaction services having the same transaction time stamp have the same transaction identifier, for example, the transaction time stamps of transaction 2 and transaction 3 may both be time T2, and the transaction identifiers of transaction 2 and transaction 3 may both be "2", which may indicate that transaction 2 and transaction 3 have the same transaction execution sequence in the N transaction services. It should be understood that the embodiment of the present application is described by taking the example that the transaction timestamps of the N transaction services are different.
As shown in fig. 4, when the transaction service to be executed acquired from the N transaction services is transaction N-1, that is, when transaction N-1 is taken as the first transaction service, transactions 1, … and transaction N-2, whose transaction execution order is earlier than that of the first transaction service, may be searched from the N transaction services, and then transaction 1, … and transaction N-2 are taken as the preceding transaction services associated with transaction N-1.
It can be understood that, based on the write data set corresponding to the preamble transaction service, the read data set corresponding to the first transaction service, and the conflict detection condition, the conflict detection is performed on the first transaction service, and a specific process of obtaining a conflict detection result may be described as follows: the first node may perform a string comparison between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service to obtain a string comparison result. Further, if the result of the string comparison indicates that an overlapping string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service, the first node may determine the preamble transaction service in which the overlapping string exists as a target preamble transaction service that satisfies the conflict detection condition. Further, the first node may add the transaction index value of the first transaction service to the initial transaction subfield corresponding to the history key field of the target preamble transaction service to obtain a target transaction subfield of the target preamble transaction service, and perform incremental processing on the dependency number in the transaction parent field of the first transaction service in the target key field of the first transaction service to obtain an incremental transaction parent field. Further, the first node may use the target transaction subfield and the incremented transaction parent field of the target preamble transaction traffic as a collision detection result associated with the first transaction traffic.
It is understood that the initial transaction subfield (or the target transaction subfield) corresponding to the history key field of the preamble transaction service may be used to record a sub-transaction list depending on the preamble transaction service, and the dependent number in the transaction parent field of the first transaction service may be used to record the number of preamble transaction services that the first transaction service needs to depend on.
Referring back to fig. 4, when transaction N-1 is used as a first transaction service, transaction 1, …, and transaction N-2 is used as a preamble transaction service associated with the first transaction service, transaction N-2 may be a preamble transaction service 4a, transaction 1 may be a preamble transaction service 4b, the first node may obtain a write data set 40a of preamble transaction service 4a and a write data set 40b of preamble transaction service 4b, compare the read data set and the write data set 40a of transaction N-1 to obtain a string comparison result 400a, and compare the read data set and the write data set 40b of transaction N-1 to obtain a string comparison result 400 b. The first node may determine whether there is an overlapping string between the read data set and the write data set (e.g., the write data set 40a and the write data set 40b) based on the string comparison result 400a and the string comparison result 400b, and further determine a target preamble transaction service that satisfies the collision detection condition, for example, when there is an overlapping string between the read data set and the write data set 40a, determine the preamble transaction service 4a (i.e., transaction N-2) corresponding to the write data set 40a as the target preamble transaction service that satisfies the collision detection condition.
Similarly, the first node may obtain the write data sets of the preceding transaction services (e.g., transaction 2, …, transaction N-3, not shown in the figure) except the preceding transaction service 4a and the preceding transaction service 4b in the preceding transaction services, and compare the read data sets corresponding to the first transaction service with the write data sets corresponding to the preceding transaction services (e.g., transaction 2, …, transaction N-3, not shown in the figure), where it is assumed that the transaction N-2 is the target preceding transaction service satisfying the conflict detection condition in the preceding transaction services.
It should be appreciated that when transaction N-2 is a transaction that satisfies the conflict detection condition, the first node adds the transaction index value for transaction N-1 (e.g., the transaction index value for transaction N-1 may be "N-1") to the transaction subfield of transaction N-2 (i.e., the initial transaction subfield), resulting in the transaction subfield with "N-1" added (i.e., the target transaction subfield), and increments the dependency number F in the transaction parent field of transaction N-1, resulting in an incremented dependency number (F + 1).
It is understood that the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service may be composed of one or more sets of KEY VALUE pairs (KEYs, VALUEs), i.e., KEYs, VALUEs, and the determination of the overlapping character strings between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service may be determined by whether the same KEY exists between the read data set and the write data set. If there is an overlapping character string (i.e. an overlapping key) between the read data set and the write data set, it indicates that the read data set corresponding to the first transaction service is changed by the preamble transaction service, and may indicate that the first transaction service uses the data changed by the preamble transaction service, and therefore, the first transaction service needs to be executed after the preamble transaction service.
For ease of understanding, please refer to fig. 5, fig. 5 is a schematic flowchart illustrating a collision detection for transaction services according to an embodiment of the present application. The current transaction shown in fig. 5 may be a transaction service to be executed (i.e., a first transaction service and a first transaction service) that is sequentially acquired by the first node from N transaction services according to the transaction identifier, where the N transaction services may be transaction 1, …, and transaction N in the embodiment corresponding to fig. 4.
It should be appreciated that in executing step S51, the first node may first obtain transaction 1 (i.e., the first transaction service) from the N transaction services, and then in executing step S52, determine that there is no preamble transaction (i.e., preamble transaction service) associated with transaction 1, and then execute step S56, ending the conflict detection for transaction 1.
It should be appreciated that when there is still transaction service to be executed in the N transaction services, the first node may continue to execute step S51, and when step S51 is executed, the first node may obtain transaction 2 (i.e., the first transaction service) from the N transaction services, and further when step S52 is executed, determine that transaction 1 is a preceding transaction associated with transaction 2. Thus, the first node may perform step S53 to determine whether there is an overlapping string (i.e., an overlapping key) in the read set (i.e., read data set) of transaction 2 and the write set (i.e., write data set) of transaction 1, and may further perform step S52 to determine that there is no preceding transaction associated with transaction 2 when there is no overlapping string in the read set of transaction 2 and the write set of transaction 1, and then perform step S56 to end the conflict detection for transaction 2.
It should be appreciated that when there is still transaction service to be executed in the N transaction services, the first node may continue to execute step S51, and when step S51 is executed, the first node may obtain transaction 3 (i.e., the first transaction service) from the N transaction services, and further when step S52 is executed, determine that transaction 2 is a preceding transaction associated with transaction 3. Therefore, the first node may perform step S53 to determine whether there is an overlapping character string in the read set of transaction 3 and the write set of transaction 2, and may further perform step S52 to determine that transaction 1 is a preceding transaction associated with transaction 3 when there is no overlapping character string in the read set of transaction 3 and the write set of transaction 2.
Further, the first node may perform step S53 to determine whether there is an overlapping character string in the read set of transaction 3 and the write set of transaction 1, and then may perform steps S54 and S55 when there is an overlapping character string in the read set of transaction 3 and the write set of transaction 1, add the index of transaction 3 (i.e., the transaction index value) to the transaction subfield list of transaction 1 (i.e., the sub-transaction list), add the number of transaction parent fields of transaction 3 (i.e., the number of dependencies in the transaction parent fields) to 1, and then perform step S56, then continue to perform step S52 to determine that there is no preamble transaction associated with transaction 3, and then perform step S56 to end the collision detection on transaction 3.
By analogy, when there is still transaction service to be executed in the N transaction services, the first node may continue to execute step S51 until transaction N is obtained from the N transaction services, and execute step S56 to end the conflict detection on transaction N. For a specific process of the first node for detecting the conflict of the transaction 4, the transaction …, and the transaction N, reference may be made to the above description of detecting the conflict of the transaction 1, the transaction 2, and the transaction 3, which is not described herein again.
It can be understood that, if the result of the string comparison indicates that no overlapping string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service, the first node may determine the preamble transaction service as a transaction service that does not satisfy the conflict detection condition, set the dependent number in the transaction parent field of the first transaction service as a target threshold (e.g., 0, none) in the target key field of the first transaction service based on the transaction service that does not satisfy the conflict detection condition, add the first transaction service to the parallel transaction data set to which the first transaction service belongs based on the target threshold, and obtain a second transaction service for updating the first transaction service from the N transaction services. The transaction execution sequence of the second transaction service is later than that of the first transaction service; the dependency number of each transaction service in the parallel transaction data set is a target threshold, a parallel dependency relationship exists between each transaction service in the parallel transaction data set, and the parallel dependency relationship is used for updating the service dependency relationship.
Step S103, if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the N transaction services, taking the transaction service meeting the conflict detection condition as a forward dependent service associated with the first transaction service, and recording a service dependency relationship between the first transaction service and the forward dependent service;
it can be understood that, in the embodiments of the present application, the transaction service meeting the conflict detection condition may be regarded as a forward dependency service associated with the first transaction service, and accordingly, the embodiments of the present application may regard the first transaction service as a backward dependency service associated with the forward dependency service. It should be understood that the number of forward dependency services associated with a certain transaction service (e.g., the first transaction service) may be zero, one, or more, and the number of backward dependency services associated with a certain transaction service (e.g., the first transaction service) may be zero, one, or more, which is not limited in this application.
And step S104, constructing a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, packaging the directed acyclic graph and the N transaction services to obtain an offer block carrying the directed acyclic graph, and sending the offer block to the second node so that the second node executes the N transaction services in series or in parallel based on the service dependency relationship indicated by the directed acyclic graph in the offer block.
Specifically, the first node may select, based on the parallel dependency relationship in the recorded service dependency relationships, a transaction service corresponding to the transaction parent field carrying the target threshold from the N transaction services, and use the selected transaction service as the first connection service. Wherein, the first connection service comprises a first transaction service. Further, the first node may obtain a sub-transaction list associated with the first connection service from the target transaction subfield of the first connection service based on the serial dependency in the recorded service dependencies. Wherein, the sub-transaction list includes M second connection services, where M may be a non-negative integer smaller than N. Further, the first node may construct and obtain a directed acyclic graph associated with the N transaction services based on the first connection service and the M second connection services, package the directed acyclic graph and the N transaction services to obtain an offer block carrying the directed acyclic graph, and send the offer block to the second node. The second node belongs to a common node in the block chain network to which the first node belongs. The business dependency relationship comprises a serial dependency relationship and a parallel dependency relationship; the parallel dependency is determined by a transaction service in a parallel transaction data set to which the first transaction service belongs, and the serial dependency is determined by a forward dependency associated with the first transaction service. It will be appreciated that the first node may pick the first connection service from the parallel transaction data set.
Optionally, when the sub-transaction list associated with the first connection service is empty, the sub-transaction list includes 0 transaction services, and then there is no second connection service having a service dependency relationship with the first connection service in the N transaction services, that is, there is no second connection service having a connection relationship with the first connection service in the directed acyclic graph. Therefore, the first node can directly construct a directed acyclic graph associated with the N transaction services based on the first connection service.
It can be understood that, when constructing the directed acyclic graph associated with the N transaction services based on the first connection service and the M second connection services, the directed acyclic graph between the first connection service and the M second connection services may be constructed first, that is, the first connection service is connected to the M second connection services. Further, the first node may take the M second connection services as new first connection services, and obtain a sub-transaction list associated with the new first connection services from the target transaction subfield of the new first connection services based on the serial dependency relationship in the recorded service dependency relationships. The sub-transaction list includes P new second connection services, and a directed acyclic graph between the new first connection service and the P new second connection services may be further constructed, that is, the new first connection service is connected to the P new second connection services, where P may be a non-negative integer smaller than N. And repeating the steps until the sub-transaction list associated with the latest first connection service is empty, and obtaining the directed acyclic graph associated with the N transaction services.
For ease of understanding, please refer to fig. 6, and fig. 6 is a schematic view of a scenario for constructing a directed acyclic graph according to an embodiment of the present application. Transaction Y-2 (i.e., forward dependent service Y-2) and transaction Y-1 (i.e., forward dependent service Y-1) may be preceding transaction services associated with transaction Y, where transaction Y may be the currently performed transaction service, i.e., first transaction service Y. As shown in FIG. 6, the transaction index values in the write data set of transaction Y-2 are [ D1, D7], the transaction index values in the write data set of transaction Y-1 are [ D3, D5], the transaction index values in the read data set of the first transaction Y are [ D1, D3], and the transaction index values here may be KEY in the read data set and the write data set. Thus, the first transaction service Y uses the transaction Y-2 changed data D1 and the transaction Y-2 changed data D3, and the transaction Y-2 and the transaction Y-1 may be referred to as a forward dependency service associated with the first transaction service Y.
It should be appreciated that in the first transaction Y, the value of the transaction parent field (i.e., the dependency number in the transaction parent field) is 2, and the value of the transaction subfield (i.e., the sub-transaction list in the transaction subfield) is none (i.e., null), indicating that the first transaction Y depends on the execution of two forward dependent transactions; in the forward dependent transaction Y-2, the value of the transaction parent field is none (namely 0), and the value of the transaction subfield is [ Y ], which indicates that the first transaction service Y needs to be executed after the forward dependent transaction Y-2; in forward dependent transaction Y-1, the value of the transaction parent field is none (i.e., 0) and the value of the transaction subfield is [ Y ], indicating that the first transaction Y needs to be performed after forward dependent transaction Y-1.
Further, the first node may construct the directed acyclic graph 6 shown in fig. 6 based on a parallel dependency relationship and a serial dependency relationship in the service dependency relationship between the first transaction service Y and the forward dependency service, that is, the transaction parent field and the transaction subfield of the first transaction service Y, the forward dependency transaction Y-1, and the forward dependency transaction Y-2, where the directed acyclic graph 6 represents a front and rear service dependency relationship, the transaction services having the parallel dependency relationship may be executed in parallel, and the transaction services having the serial dependency relationship may be executed until the transaction services in the transaction parent field are executed. Thus, forward dependent transaction Y-2 and forward dependent transaction Y-1 may be executed in parallel, and first transaction Y may only be executed after forward dependent transaction Y-2 and forward dependent transaction Y-1 have been executed.
For ease of understanding, please refer to fig. 7, and fig. 7 is a schematic view of a scenario for processing transaction services according to an embodiment of the present application. As shown in fig. 7, the node 1 may be a first node, the proposed block obtained by the node 1 through packaging may include N transaction services, and when N is equal to 8, the proposed block may include 8 transaction services, where the 8 transaction services specifically may include: transaction 1 (i.e., tx1), transaction 2 (i.e., tx2), transaction 3 (i.e., tx3), transaction 4 (i.e., tx4), transaction 5 (i.e., tx5), transaction 6 (i.e., tx6), transaction 7 (i.e., tx7), transaction 8 (i.e., tx8), where transactions 1, …, and transaction 8 are arranged in transaction execution order.
It can be understood that the node 1 may serially execute 8 transaction services to be packaged according to a transaction execution sequence, record a transaction read-write set (i.e., a read data set and a write data set) of each transaction service through a transaction buffer (i.e., a transaction buffer component), and perform conflict detection on the 8 transaction services according to the transaction execution sequence through a conflict detector (i.e., a conflict detection component) to obtain a service dependency relationship between the 8 transaction services, and further may construct a directed acyclic graph 7 associated with the 8 transaction services through a directed acyclic graph constructor (i.e., a directed acyclic graph constructing component) based on the recorded service dependency relationship.
It is to be understood that, the first node may store the directed acyclic graph through a directed acyclic graph memory (i.e., a directed acyclic graph storage component), and for N transaction traffics in the directed acyclic graph, the N transaction traffics may be stored in a transaction list, where each transaction traffic in the N transaction traffics is one entry in the transaction list, each entry is a tx (i.e., a transaction traffic), and each tx may include a transaction parent field and a transaction subfield. Optionally, the directed acyclic graph may also be stored in a code manner, where the code manner may abstract N transaction services into one class, the class may be represented as tx, each transaction service in the N transaction services serves as an object of the class, and the object may include a transaction parent field and a transaction subfield of each transaction service. Wherein the transaction parent field may be denoted as "parent" and the transaction sub-field may be denoted as "son".
For example, transaction 1 may be represented as:
tx1{
parent:none,
son=[tx4,tx8]
}
this tx1 indicates that the dependency number in the transaction parent field of transaction 1 is 0 and the list of child transactions in the transaction sub-field is [ tx4, tx8], thus the number of forward dependent transactions associated with transaction 1 is 0 and the backward dependent transactions associated with transaction 1 may be transactions 4 and 8, i.e., transaction 1 may be the forward dependent transaction associated with transaction 4 and transaction 1 may be the forward dependent transaction associated with transaction 8.
Similarly, transaction 2 may be represented as:
tx2{
parent:none,
son=none
}
this tx2 indicates that the dependency number in the transaction parent field of transaction 2 is 0 and the child transaction list in the transaction subfield is null, i.e., the number of forward dependent traffic associated with transaction 2 is 0 and the backward dependent traffic associated with transaction 2 is null.
Similarly, for the representation of transaction 3, …, and transaction 8, reference may be made to the representation of transaction 1 and transaction 2, which is not described in detail herein.
It is understood that after receiving the proposed block carrying the directed acyclic graph sent by the first node, the second node may execute the 8 transaction services in the proposed block in series or in parallel based on the service dependency indicated by the directed acyclic graph in the proposed block. The transaction service with the parallel dependency relationship may be executed in parallel, and the transaction service with the serial dependency relationship may be executed only after the forward dependency service is executed, for example, in the embodiment corresponding to fig. 7, transaction 1, transaction 2, and transaction 3 may be executed in parallel; after transaction 1 is executed, transaction 4 and transaction 8 may be executed in parallel, and after transaction 3 is executed, transaction 5 may be executed; after transaction 4 is performed, transaction 6 may be performed; after transaction 6 is performed, transaction 7 may be performed.
In the embodiment of the application, a first node (i.e., a packaging node) may serially execute N transaction services to be packaged according to a transaction execution sequence, and may determine a service dependency relationship between N transaction services in the same block according to a read data set and a write data set of each transaction service recorded in a process of serially executing each transaction service, and further obtain an proposed block carrying a directed acyclic graph after constructing and obtaining the directed acyclic graph according to the service dependency relationships, which may ensure as far as possible that other common nodes (i.e., second nodes) in a block chain network to which the first node belongs may quickly implement parallel and serial connection of the N transaction services in the proposed block based on the service dependency relationship indicated by the directed acyclic graph, obviously, the directed acyclic graph obtained by the second nodes may reasonably implement serial and parallel connection of the N transaction services, therefore, under the condition of small transaction conflict amount, most transaction services in the N transaction services can be executed in parallel as much as possible, so that the consensus performance of the consensus nodes in the block chain network can be improved, and the throughput of the block chain can be effectively improved.
Further, please refer to fig. 8, and fig. 8 is a flowchart illustrating a transaction data processing method according to an embodiment of the present application. The method may be performed by a first node (e.g., block chain node 10a shown in fig. 1, described above), may be performed by a second node (e.g., block chain node 10b shown in fig. 1, described above), or may be performed by both the first node and the second node. For ease of understanding, the present embodiment is described as an example in which the method is performed by the first node and the second node together. The transaction data processing method can comprise the following steps:
step S201, a first node acquires a first transaction service from N transaction services to be packaged, and acquires a read data set corresponding to the first transaction service;
the first transaction service may be a transaction service other than the first transaction service among N transaction services, where N is a positive integer.
For a specific process of the first node obtaining the first transaction service and the read data set corresponding to the first transaction service, reference may be made to the description of step S101 in the embodiment corresponding to fig. 3, which will not be described herein again.
Step S202, a first node determines a transaction execution sequence of a first transaction service in N transaction services, and performs conflict detection on the first transaction service based on the transaction execution sequence, a read data set corresponding to the first transaction service and a conflict detection condition to obtain a conflict detection result;
for a specific process of performing conflict detection on the first transaction service by the first node to obtain a conflict detection result, reference may be made to the description of step S102 in the embodiment corresponding to fig. 3, which will not be described herein again.
Step S203, if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the N transaction services, the first node takes the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service, and records a service dependency relationship between the first transaction service and the forward dependency service;
for a specific process of determining the forward dependency service associated with the first transaction service and recording the service dependency relationship between the first transaction service and the forward dependency service, reference may be made to the description of step S103 in the embodiment corresponding to fig. 3, which will not be described herein again.
Step S204, the first node constructs a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, packages the directed acyclic graph and the N transaction services to obtain an offer block carrying the directed acyclic graph, and sends the offer block to the second node;
for a specific process of the first node constructing the directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, reference may be made to the description of step S104 in the embodiment corresponding to fig. 3, which will not be described herein again.
Step S205, the second node receives the proposed block which is sent by the first node and carries the directed acyclic graph;
the second node belongs to a consensus node in the block chain network to which the first node belongs, and the first node belongs to a packing node in the block chain network to which the second node belongs. The packing node belongs to a consensus node in the blockchain network, and the first node may be any one of the consensus nodes in the blockchain network.
Step S206, the second node selects the transaction service meeting the transaction execution condition from the N transaction services based on the service dependency relationship indicated by the directed acyclic graph, takes the selected transaction service as a first connection service, and acquires a sub-transaction list associated with the first connection service;
wherein, the sub-transaction list includes M second connection services, where M may be a non-negative integer less than N; the first connection service may include a first transaction service.
It can be understood that the transaction service carrying the target threshold among the N transaction services is the transaction service satisfying the transaction execution condition, that is, the dependent number in the transaction parent field of the transaction service satisfying the transaction execution condition is equal to the target threshold.
For ease of understanding, please refer to fig. 9, and fig. 9 is a schematic view of a scenario for acquiring a transaction service according to an embodiment of the present application. The directed acyclic graph 9 shown in fig. 9 may be the directed acyclic graph 7 in the embodiment corresponding to fig. 7 described above. The dependency number in the transaction parent field of transaction 1 is equal to the target threshold (i.e., 0), then transaction 1 may be a transaction service satisfying the transaction execution condition, and thus, the second node may treat transaction 1 as the first connection service 100 a. Upon acquiring the sub-transaction list associated with transaction 1, the second node may use the transaction services in the sub-transaction list as the second connection services 200a, where transactions 4 and 8 may be used as the second connection services 200a (i.e., 2 second connection services). Where the number of dependencies in the transaction parent fields of transaction 4 and transaction 8 may be equal to 1.
Similarly, in another execution path, the dependency number in the transaction parent field of transaction 2 is also equal to the target threshold (i.e. 0), then transaction 2 may be a transaction service satisfying the transaction execution condition, and therefore, the second node may regard transaction 2 as the first connection service 100 a. When the sub-transaction list associated with the transaction 2 is acquired, it is determined that no transaction service exists in the sub-transaction list, that is, the second connection service 200a corresponding to the first connection service 100a (i.e., the transaction 2) does not exist.
Similarly, in another execution path, the dependency number in the transaction parent field of transaction 3 is also equal to the target threshold (i.e. 0), then transaction 3 may be a transaction service satisfying the transaction execution condition, and therefore, the second node may treat transaction 3 as the first connection service 100 a. Upon acquiring the sub-transaction list associated with transaction 3, the second node may regard the transaction traffic in the sub-transaction list as the second connection traffic 200a, where transaction 5 may be regarded as the second connection traffic 200a (i.e., 1 second connection traffic). Where the dependency number in the transaction parent field of transaction 5 may be equal to 1.
It should be understood that the above-mentioned transactions 1, 2 and 3 may be collectively referred to as a first connection service, and the above-mentioned transactions 4, 8 and 5 may be collectively referred to as a second connection service in the embodiments of the present application.
Step S207, the second node constructs an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first connection service and the M second connection services, and performs legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
Specifically, the second node may transmit the first connection service and the M second connection services to a transaction execution coroutine pool associated with the transaction coordinator through the transaction coordinator, where the coroutine in the idle state is used as a first coroutine when the coroutine in the transaction execution coroutine pool is in the idle state, and the first connection service is executed through the first coroutine when the business state of the first coroutine is in the working state, so as to obtain a first transaction execution result corresponding to the first connection service. Further, the second node may perform, based on the first transaction execution result, decremental processing on the dependent number of the transaction parent field of each of the M second connection services, and take each of the decremental second connection services as a service to be processed, respectively. Further, the second node may search, from each to-be-processed service, a to-be-processed service for which the dependency number of the transaction parent field reaches the target threshold in the transaction execution condition, and use the searched to-be-processed service as a backward dependency service associated with the first connection service. Further, the second node may use the coroutine in the idle state as a second coroutine in the transaction execution coroutine pool, execute the backward dependent service through the second coroutine when the service state of the second coroutine is the working state, obtain a second transaction execution result corresponding to the backward dependent service, and obtain a second transaction execution result corresponding to each service to be processed until each service to be processed is executed. Further, the second node may construct an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first transaction execution result and the second transaction execution result corresponding to each service to be processed, and perform legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
Optionally, when the number of the first protocols is smaller than the number of the first connection services, a part of the first connection services in the first connection services may be executed by the first protocols, and when new first protocols in an idle state exist in the transaction execution protocol pool, another part of the first connection services in the first connection services may be executed by using the new first protocols in the idle state. Similarly, when the number of the second coroutines is smaller than the number of the second connection businesses, a part of the backward dependency businesses in the backward dependency businesses can be executed through the second coroutines, and when new second coroutines in an idle state exist in the transaction execution coroutine pool, the new second coroutines in the idle state are used for executing another part of the backward dependency businesses in the backward dependency businesses.
It can be understood that, when taking the protocol in the idle state as the first protocol, the first connection service may be executed through the first protocol, where one first connection service corresponds to one first protocol, if the number of the first connection services is less than the number of the first protocols, then when the first protocol executes the first connection service, the protocol in the idle state (i.e. the first protocol) still exists in the transaction execution protocol pool, and the second node may take these first protocols in the idle state as the second protocol. For example, when there are X1 routines in the idle state in the transaction execution routine pool, the X1 routines may be used as the first routines, when the number of the first connection services is X2 (assuming that X2 is smaller than X1), the first connection services may be executed through X2 of the X1 routines, and the remaining (X1-X2) routines in the idle state (i.e., the first routines) may be used as the second routines, so as to execute the pending services (i.e., backward dependent services) satisfying the transaction execution conditions through (X1-X2) routines.
Referring to fig. 9 again, when the first connection service 100a is transaction 1 and the second connection service 200a is transactions 4 and 8, transaction 1 may be executed through the first coordination process, and after the execution of transaction 1 is completed, the dependent numbers in the transaction parent fields of transactions 4 and 8 may be subjected to decrement processing, so that transactions 4 and 8 are used as services to be processed. Similarly, when the first connection service 100a is transaction 3 and the second connection service 200a is transaction 5, transaction 3 may be executed through the first protocol, and after the execution of transaction 3 is completed, the dependent number in the transaction parent field of transaction 5 may be subjected to decremental processing, so that transaction 4 is used as a service to be processed. Similarly, when the first connection service 100a is transaction 2, transaction 2 may be executed through the first protocol, and after the execution of transaction 2 is completed, since the sub-transaction list associated with transaction 2 is empty, the decrement operation is not needed.
Taking the first connection service 100a as the transaction 1, and the second connection service 200a as the transactions 4 and 8 as examples, the second node may obtain, based on the first transaction execution result corresponding to the first connection service 100a, the transaction service that satisfies the transaction execution condition, that is, obtain the transaction service whose dependency number in the transaction parent field is equal to the target threshold (that is, 0), and use the obtained transaction service that satisfies the transaction execution condition as the backward dependency service, for example, the transactions 4 and 8 may be used as the backward dependency service (that is, the second connection service 200 a).
It can be understood that, in the embodiment of the present application, the second connection service 200a may be used as a new first connection service (i.e., the first connection service 100b), and when the sub-transaction list associated with the first connection service 100b is obtained, the second node may use the transaction service in the sub-transaction list as a new second connection service (i.e., the second connection service 200b), where the transaction 6 may be used as the second connection service 200b (i.e., 1 second connection service).
It will be appreciated that transactions 4 and 8 may be executed by a new first coroutine (i.e., a second coroutine). After the execution of the transaction 4 is completed, the dependent number in the transaction subfield of the transaction 6 can be subjected to decrement processing, and then the transaction 6 is used as a new service to be processed; after completion of execution of transaction 8, no decrement operation is required since the sub-transaction list associated with transaction 8 is empty.
It should be understood that the second node may continue to obtain the transaction services satisfying the transaction execution condition based on the second transaction execution result (i.e. the new first transaction execution result) corresponding to the first connection service 100b, and so on until all the N transaction services in the proposed block are executed.
It should be appreciated that the second node may release the first coroutine in a work queue of the transactional execution coroutine pool based on the first transactional execution result. Further, the second node may switch the service state of the first coroutine from the working state to an idle state, and add the first coroutine in the idle state to an idle queue corresponding to the transaction execution coroutine pool. Similarly, when the business state of the first coroutine in the idle state is switched to the working state, the second node can release the first coroutine in the idle queue of the transaction execution coroutine pool, further switch the business state of the first coroutine from the idle state to the working state, and add the first coroutine in the working state to the working queue corresponding to the transaction coroutine pool. For the switching process of the service state of the second coroutine, reference may be made to the description of the switching process of the service state of the first coroutine. It should be understood that the number of coroutines in the idle queue and the work queue is uncertain, and the application is not limited thereto.
For ease of understanding, please refer to fig. 10, where fig. 10 is a schematic view of a scenario for scheduling transaction services according to an embodiment of the present application. As shown in fig. 10, the transaction execution coroutine pool may include a work coroutine and an idle coroutine (i.e., an idle coroutine), where a business state of the work coroutine is a work state, and a business state of the idle coroutine is an idle state, where the work coroutine specifically may include: coroutine 1, coroutine 2, …, coroutine X, where the idle coroutine may specifically include: coroutine X +1, coroutine X +2, …, etc. The work coroutines may belong to work queues in the transaction execution coroutine pool, and the idle coroutines may belong to idle queues in the transaction execution coroutine pool.
As shown in fig. 10, the transaction scheduler (i.e., the transaction coordinator, the transaction scheduling component) may cyclically search for the transaction service satisfying the transaction execution condition from the to-be-executed transaction services (i.e., the transaction list) of the N transaction services, where the transaction parent field of the transaction service satisfying the transaction execution condition is empty (i.e., the dependency number of the transaction parent field is equal to 0), and then send the transaction service satisfying the transaction execution condition to the transaction execution protocol pool for processing until all transaction services in the transaction list are executed.
Referring to fig. 9 together, the directed acyclic graph 9 in the embodiment corresponding to fig. 9, the transaction scheduler may obtain a first connection service (e.g., transaction 1), send transaction 1 to the transaction execution protocol pool, obtain a protocol in an idle state in the transaction execution protocol pool, for example, obtain protocol X +1 from an idle queue, execute transaction 1 through protocol X +1, release protocol X +1 in the idle queue, switch the service state of protocol X +1 from the idle state to a working state, and add protocol X +1 in the working state to the working queue.
Further, after transaction 1 is completed through coroutine X +1 execution, coroutine X +1 is released in the work queue, the service state of coroutine X +1 is switched from the working state to the idle state, and coroutine X +1 in the idle state is added to the idle queue. The transaction scheduler may obtain pending transactions (i.e., transaction 4 and transaction 8), send transaction 4 and transaction 8 to the transaction execution progress pool, and obtain progresses in the transaction execution progress pool that are idle, e.g., progress X +2 and progress X +3 are obtained from the idle queue, so as to execute transaction 8 via progress X +2 and execute transaction 4 via progress X + 3. And so on until transaction 1, transaction 4, transaction 8, transaction 6, and transaction 7 are performed.
Similarly, the transaction scheduler may obtain the first connection service (e.g., transaction 2 and transaction 3), send transaction 2 and transaction 3 to the transaction execution coroutine pool, obtain coroutines in the transaction execution coroutine pool that are idle, to execute transaction 2 and transaction 3, and then execute transaction 5 after executing transaction 3. For the execution of transaction 2 and transaction 3 by the transaction scheduler, reference may be made to the above description of transaction 1, and for the execution of transaction 5 by the transaction scheduler, reference may be made to the above description of transactions 4 and 8. The transaction scheduler may end the lookup of the transaction list when all transaction transactions in the proposed block have been performed.
For ease of understanding, please refer to fig. 11, fig. 11 is a schematic view illustrating a scenario of performing transaction services serially and in parallel according to an embodiment of the present application. As shown in fig. 11, the transactions 1, …, and 8 may be transaction services in the embodiment corresponding to fig. 9. The node 1 (i.e., the first node) may be the node 10a in the embodiment corresponding to fig. 1, the node 2 (i.e., the second node 12a) may be the node 10b in the embodiment corresponding to fig. 1, the node 3 (i.e., the second node 12b) may be the node 10c in the embodiment corresponding to fig. 1, and the second node 12a and the second node 12b may be collectively referred to as the second node. It is understood that other common nodes may also be included in the blockchain network, for example, the second node 12c (not shown in the figure) may also be included. The time axis may represent the execution sequence of the N transaction services in the proposed block, and the time interval between every two time instants on the time axis is not limited herein.
It should be appreciated that the first node may execute transactions 1, …, 8 serially according to the transaction execution order of transactions 1, …, 8, e.g., transaction 1 is executed at time T11, transaction 2 is executed at time T12, transaction 3 is executed at time T13, transaction 4 is executed at time T14, transaction 5 is executed at time T15, transaction 6 is executed at time T16, transaction 7 is executed at time T17, and transaction 8 is executed at time T18.
It should be appreciated that the second node 12a may execute transactions 1, …, 8 serially and in parallel according to the business dependencies determined by the directed acyclic graph, e.g., execute transaction 1, transaction 2, and transaction 3 in parallel at time T21, execute transaction 4, transaction 8, and transaction 5 in parallel at time T22 after transaction 1, transaction 2, and transaction 3 are executed, execute transaction 6 at time T23 after transaction 4, transaction 8, and transaction 5 are executed, and execute transaction 7 at time T24 after transaction 6 is executed.
It should be appreciated that in the second node 12a, transaction 1, transaction 2, and transaction 3 do not have business dependencies between them, and are independent of each other, so that transaction 1, transaction 2, and transaction 3 may be performed in parallel. It will be appreciated that the timing of execution of transactions 4, 8, and 5 may be different, and that transactions 4 and 8 may be executed after transaction 1 is completed, and transaction 5 may be executed after transaction 3 is completed. Transaction 4, transaction 8, and transaction 5 may be executed at the same time (e.g., time T22 described above) assuming that transaction 1 and transaction 3 are executed at the same time and that there are enough sessions in the idle state.
Similarly, the specific process of executing the transaction 1, …, and the transaction 8 by the second node 12b may be referred to the description of executing the transaction 1, …, and the transaction 8 by the second node 12a, which will not be described herein again. The total time for the second node 12a and the second node 12b to execute the transaction service may be the same or different.
It should be understood that, in other common nodes (for example, the second node 12c) of the blockchain network except for the first node, the second node 12a, and the second node 12b, specific processes for executing N transaction services may be referred to together with the description of executing N transaction services by the second node 12a and the second node 12b, and will not be described herein again.
It can be understood that, based on the first transaction execution result and the second transaction execution result corresponding to each service to be processed, an auxiliary acyclic graph associated with N transaction services in the proposed block is constructed, and a specific process of legally verifying a directed acyclic graph based on the auxiliary acyclic graph may be described as follows: when the first transaction execution result and the second transaction execution result corresponding to each service to be processed are combined, the second node may write the first transaction execution result into the first transaction write cache of the first connection service, and use the data written into the first transaction write cache as the first write data set of the first connection service. Further, the second node may traverse to obtain an ith transaction execution result in a second transaction execution result corresponding to each service to be processed, write the ith transaction execution result into a second transaction write cache of the ith service to be processed, use data written into the second transaction write cache of the ith service to be processed as a second write data set of the ith service to be processed, obtain a second read data set corresponding to the ith service to be processed in a transaction read cache of the ith service to be processed, and obtain the second read data set of each service to be processed until each service to be processed is executed. Wherein i may be a non-negative integer less than or equal to M. Further, the second node may construct an auxiliary acyclic graph associated with the N transaction transactions based on the first write data set of the first connection transaction and the second read data set of each pending transaction. Further, the second node may perform similar comparison on the auxiliary acyclic graph and the directed acyclic graph to obtain a similar comparison result, and determine the validity of the directed acyclic graph based on the similar comparison result.
It can be understood that, in the specific process of the second node constructing the auxiliary acyclic graph associated with the N transaction services based on the first write data set of the first connection service and the second read data set of each service to be processed, reference may be made to the description of the first node constructing the directed acyclic graph associated with the N transaction services, which will not be described herein again.
It can be understood that, when constructing the auxiliary acyclic graph associated with the N transaction traffics based on the first write data set of the first connection traffic and the second read data set of each pending transaction, the first auxiliary acyclic graph associated with the first connection traffic and each pending transaction may be constructed first based on the first write data set of the first connection traffic and the second read data set of each pending transaction. Further, the second node may use each to-be-processed service as a new first connection service, use the second write data set of each to-be-processed service as a new first write data set, and obtain a sub-transaction list associated with each to-be-processed service. The sub-transaction list comprises a new service to be processed, a new second read data set of the new service to be processed can be obtained, and a second auxiliary acyclic graph associated with the new first connection service and the new service to be processed is constructed based on the new first write data set of the new first connection service and the new second read data set of the new service to be processed. Wherein the second auxiliary acyclic graph is constructed on the basis of the first auxiliary acyclic graph. And repeating the steps until the sub-transaction list associated with the latest first connection service is empty, and obtaining the auxiliary acyclic graph associated with the N transaction services.
It is understood that when the first node performs malicious activities, the first node may send the proposed block containing the fake directed acyclic graph to the second node, and therefore, the second node may determine whether the directed acyclic graph in the proposed block is true or false through a directed acyclic graph validity verifier (i.e., a directed acyclic graph validity verification component) to determine whether the first node performs malicious activities. The method comprises the steps that a directed acyclic graph received from a first node is compared with an auxiliary acyclic graph constructed at a second node, the legality of the received directed acyclic graph can be judged rapidly, if the similar comparison result indicates that the auxiliary acyclic graph is different from the directed acyclic graph, the second node can initiate a malicious vote on the first node through consensus committee convergence, and when the number of the malicious votes of the consensus nodes in a consensus node list reaches a voting threshold value, the directed acyclic graph is determined to be illegal.
It should be appreciated that upon determining that the directed acyclic graph does not have legitimacy, the second node may invoke a consensus committee contract for maintaining a list of consensus nodes, obtain the list of consensus nodes through the consensus committee contract, and delete the node identification (i.e., the penalty of the chain) of the first node in the list of consensus nodes.
It can be seen that, during the serial execution of the first transaction service (it should be understood that the first transaction service is other transaction services except the first transaction service among the N transaction services) according to the transaction execution sequence of the N transaction services, the first node (i.e. the packaging node participating in the consensus) can perform conflict detection, and further, the business dependency relationship between each transaction business can be recorded according to the conflict detection result, so that, after the directed acyclic graph is constructed according to the service dependencies, the packaged proposed blocks carrying the directed acyclic graph may be further sent to other consensus nodes (e.g., a second node) in the blockchain network, so that other nodes (e.g., the second node) can perform the N transaction transactions serially or in parallel directly according to the traffic dependencies indicated by the directed acyclic graph in the received proposed block. It should be understood that, by implementing parallel execution of the transaction service according to the directed acyclic graph in the consensus nodes, the execution efficiency of the transaction service can be improved, so that the consensus performance of the second node can be improved, and the throughput of the block chain can be improved.
Further, please refer to fig. 12, wherein fig. 12 is a schematic structural diagram of a transaction data processing apparatus according to an embodiment of the present application. The transaction data processing device 1 may include: a first obtaining module 11, a conflict detecting module 12, a dependent recording module 13, and a block sending module 14; further, the transaction data processing apparatus 1 may further include: a contract calling module 15 and a second obtaining module 16;
the first obtaining module 11 is configured to obtain a first transaction service from the N transaction services to be packaged, and obtain a read data set corresponding to the first transaction service; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
the conflict detection module 12 is configured to determine a transaction execution order of the first transaction service among the N transaction services, and perform conflict detection on the first transaction service based on the transaction execution order, the read data set corresponding to the first transaction service, and a conflict detection condition to obtain a conflict detection result;
the first transaction service is to-be-executed transaction service acquired from the N transaction services, and a transaction read cache corresponding to the first transaction service comprises a read data set corresponding to the first transaction service;
the collision detection module 12 includes: an order determination unit 121, a transaction search unit 122, a write set acquisition unit 123, a conflict detection unit 124;
the order determining unit 121 is configured to obtain a transaction identifier configured for each of the N transaction services, determine an identifier position of the transaction identifier of the first transaction service in the transaction identifiers of the N transaction services, and determine a transaction execution order of the first transaction service based on the identifier position;
the transaction searching unit 122 is configured to search, among the N transaction services, a transaction service whose transaction execution order is earlier than that of the first transaction service, and use the searched transaction service as a preamble transaction service associated with the first transaction service; the preamble transaction service is an executed transaction service acquired from the N transaction services;
the write set obtaining unit 123 is configured to obtain a transaction write cache of the preamble transaction service, and obtain a write data set corresponding to the preamble transaction service from the transaction write cache;
the conflict detection unit 124 is configured to perform conflict detection on the first transaction service based on the write data set corresponding to the preamble transaction service, the read data set corresponding to the first transaction service, and a conflict detection condition, so as to obtain a conflict detection result.
Wherein, the collision detection unit 124 includes: a data comparison subunit 1241, a first comparison subunit 1242, a field determination subunit 1243, a result determination subunit 1244; optionally, the collision detection unit 124 may further include: a second comparator subunit 1245;
a data comparison subunit 1241, configured to perform character string comparison on the read data set corresponding to the first transaction service and the write data set corresponding to the preorder transaction service, so as to obtain a character string comparison result;
a first comparing subunit 1242, configured to determine, if the result of the character string comparison indicates that an overlapping character string exists between a read data set corresponding to the first transaction service and a write data set corresponding to the preamble transaction service, the preamble transaction service in which the overlapping character string exists as a target preamble transaction service that meets a collision detection condition;
a field determining subunit 1243, configured to add the transaction index value of the first transaction service to the initial transaction subfield corresponding to the history key field of the target preamble transaction service, to obtain a target transaction subfield of the target preamble transaction service, and perform incremental processing on the dependency number in the transaction parent field of the first transaction service in the target key field of the first transaction service, to obtain an incremental transaction parent field;
a result determination subunit 1244, configured to use the target transaction sub-field and the incremented transaction parent field of the target preamble transaction service as a collision detection result associated with the first transaction service.
Optionally, the second comparing subunit 1245 is configured to, if the result of the string comparison indicates that no overlapping string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service, determine the preamble transaction service as a transaction service that does not satisfy the conflict detection condition, set, based on the transaction service that does not satisfy the conflict detection condition, a dependency number in a transaction parent field of the first transaction service in a target key field of the first transaction service as a target threshold, add the first transaction service to a parallel transaction data set to which the first transaction service belongs based on the target threshold, and obtain, from the N transaction services, a second transaction service for updating the first transaction service; the transaction execution sequence of the second transaction service is later than that of the first transaction service; the dependency quantity of each transaction service in the parallel transaction data set is a target threshold, a parallel dependency relationship exists between each transaction service in the parallel transaction data set, and the parallel dependency relationship is used for updating the service dependency relationship.
For a specific implementation manner of the data comparing subunit 1241, the first comparing subunit 1242, the field determining subunit 1243, the result determining subunit 1244, and the second comparing subunit 1245, reference may be made to the description of step S102 in the embodiment corresponding to fig. 3, which will not be described herein again.
For a specific implementation manner of the sequence determining unit 121, the transaction searching unit 122, the write set obtaining unit 123, and the conflict detecting unit 124, reference may be made to the description of step S102 in the embodiment corresponding to fig. 3, which will not be described herein again.
The dependency recording module 13 is configured to, if the conflict detection result indicates that a transaction service meeting the conflict detection condition exists in the N transaction services, take the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service, and record a service dependency relationship between the first transaction service and the forward dependency service;
the block sending module 14 is configured to construct a directed acyclic graph associated with the N transaction services based on the recorded service dependency relationship, package the directed acyclic graph and the N transaction services to obtain an proposed block carrying the directed acyclic graph, and send the proposed block to the second node, so that the second node executes the N transaction services in series or in parallel based on the service dependency relationship indicated by the directed acyclic graph in the proposed block; the second node belongs to a consensus node in the blockchain network to which the first node belongs.
The business dependency relationship comprises a serial dependency relationship and a parallel dependency relationship; the parallel dependency relationship is determined by the transaction service in the parallel transaction data set to which the first transaction service belongs; the serial dependency is determined by a forward dependency associated with the first transaction;
the block transmission module 14 includes: a first obtaining unit 141, a second obtaining unit 142, a acyclic graph constructing unit 143;
a first obtaining unit 141, configured to select, based on a parallel dependency relationship in the recorded service dependency relationships, a transaction service corresponding to a transaction parent field carrying a target threshold from the N transaction services, and use the selected transaction service as a first connection service; the first connection service comprises a first transaction service;
a second obtaining unit 142, configured to obtain, based on a serial dependency relationship in the recorded service dependency relationships, a sub-transaction list associated with the first connection service from a target transaction subfield of the first connection service; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N;
the acyclic graph constructing unit 143 is configured to construct a directed acyclic graph associated with the N transaction services based on the first connection service and the M second connection services, package the directed acyclic graph and the N transaction services to obtain an proposed block carrying the directed acyclic graph, and send the proposed block to the second node.
For specific implementation manners of the first obtaining unit 141, the second obtaining unit 142, and the acyclic graph constructing unit 143, reference may be made to the description of step S104 in the embodiment corresponding to fig. 3, which will not be described herein again.
Optionally, the contract invoking module 15 is configured to obtain an intelligent contract for executing the first transaction service based on a contract invoking address and a contract name in the read data set corresponding to the first transaction service, invoke the intelligent contract to execute the first transaction service, obtain a transaction service execution result corresponding to the first transaction service, add the transaction service execution result to the transaction write cache of the first transaction service, and construct a write data set corresponding to the first transaction service based on data stored in the transaction write cache.
Optionally, the second obtaining module 16 is configured to obtain a first transaction service from the N transaction services, execute the first transaction service based on a read data set corresponding to the first transaction service, obtain a first service execution result of the first transaction service, add the first service execution result to a first transaction write cache of the first transaction service, and construct a write data set corresponding to the first transaction service based on data stored in the first transaction write cache; the transaction execution sequence of the first transaction service is earlier than that of the first transaction service, and the first transaction service is used as a preamble transaction service of the first transaction service.
For specific implementation manners of the first obtaining module 11, the conflict detecting module 12, the dependency recording module 13, the block sending module 14, the contract invoking module 15, and the second obtaining module 16, reference may be made to the description of step S101 to step S104 in the embodiment corresponding to fig. 3, which will not be described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, please refer to fig. 13, fig. 13 is a schematic structural diagram of a transaction data processing apparatus according to an embodiment of the present application. The transaction data processing device 2 may include: a block receiving module 21, a transaction selecting module 22 and a legal verification module 23;
a block receiving module 21, configured to receive an proposed block with a directed acyclic graph sent by a first node; the directed acyclic graph is constructed based on business dependency relations among the N transaction businesses in the proposal block; the business dependency relationship is determined by the first transaction business and the forward dependency business related to the first transaction business after the first transaction business is obtained from the N transaction businesses; the forward dependency service is obtained by performing conflict detection on the first transaction service based on a transaction execution sequence of the first transaction service in the N transaction services, a read data set corresponding to the first transaction service and a conflict detection condition; the first node belongs to a packing node in a blockchain network to which the second node belongs; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
the transaction selection module 22 is configured to select, based on a service dependency relationship indicated by the directed acyclic graph, a transaction service that meets a transaction execution condition from the N transaction services, use the selected transaction service as a first connection service, and acquire a sub-transaction list associated with the first connection service; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N; the first connection service comprises a first transaction service;
and the legal verification module 23 is configured to construct an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first connection service and the M second connection services, and perform legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
The legal verification module 23 includes: a first execution unit 231, a transaction determination unit 232, a service determination unit 233, a second execution unit 234, a validity verification unit 235; optionally, the legal verification module 23 may further include: a coroutine releasing unit 236, a state switching unit 237 and a node deleting unit 238;
the first execution unit 231 is configured to transmit the first connection service and the M second connection services to a transaction execution coroutine pool associated with the transaction coordinator through the transaction coordinator, respectively, when an idle coroutine exists in the transaction execution coroutine pool, use the idle coroutine as a first coroutine, and when a business state of the first coroutine is a working state, execute the first connection service through the first coroutine, so as to obtain a first transaction execution result corresponding to the first connection service;
a transaction determining unit 232, configured to perform, based on the first transaction execution result, decremental processing on the dependent number of the transaction parent field of each of the M second connection services, and take each of the decremental second connection services as a service to be processed respectively;
a service determining unit 233, configured to search, from each service to be processed, a service to be processed whose dependency number of the transaction parent field reaches a target threshold in the transaction execution condition, and use the searched service to be processed as a backward dependency service associated with the first connection service;
the second execution unit 234 is configured to use the coroutine in an idle state as a second coroutine in the transaction execution coroutine pool, execute the backward dependent service through the second coroutine when a service state of the second coroutine is a working state, obtain a second transaction execution result corresponding to the backward dependent service, and obtain a second transaction execution result corresponding to each service to be processed until each service to be processed is executed;
and a legal verification unit 235, configured to construct an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first transaction execution result and the second transaction execution result corresponding to each service to be processed, and perform legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
The legal verifying unit 235 includes: a first determination subunit 2351, a second determination subunit 2352, an auxiliary construction subunit 2353, a legal determination subunit 2354;
the first determining subunit 2351 is configured to, when the first transaction execution result and the second transaction execution result corresponding to each service to be processed are combined, write the first transaction execution result into a first transaction write cache of the first connection service, and use data written into the first transaction write cache as a first write data set of the first connection service;
the second determining subunit 2352 is configured to obtain an ith transaction execution result in a traversal manner in the second transaction execution result corresponding to each service to be processed, write the ith transaction execution result into a second transaction write cache of the ith service to be processed, use data written into the second transaction write cache of the ith service to be processed as a second write data set of the ith service to be processed, obtain a second read data set corresponding to the ith service to be processed in a transaction read cache of the ith service to be processed, and obtain a second read data set of each service to be processed until each service to be processed is executed; i is a non-negative integer less than or equal to M;
an auxiliary construction subunit 2353, configured to construct an auxiliary acyclic graph associated with the N transaction services based on the first write data set of the first connection service and the second read data set of each service to be processed;
the legality determining subunit 2354 is configured to perform similar comparison on the auxiliary acyclic graph and the directed acyclic graph to obtain a similar comparison result, and determine the legality of the directed acyclic graph based on the similar comparison result.
For specific implementation manners of the first determining subunit 2351, the second determining subunit 2352, the auxiliary constructing subunit 2353 and the legal determining subunit 2354, reference may be made to the description of step S207 in the embodiment corresponding to fig. 8, and details will not be described here.
Optionally, the coroutine releasing unit 236 is configured to release the first coroutine in the work queue of the transaction execution coroutine pool based on the first transaction execution result;
the state switching unit 237 is configured to switch the service state of the first coroutine from the working state to an idle state, and add the first coroutine in the idle state to an idle queue corresponding to the transaction execution coroutine pool.
Optionally, the node deleting unit 238 is configured to, when it is determined that the directed acyclic graph does not have validity, invoke a consensus committee contract for maintaining a consensus node list, obtain the consensus node list through the consensus committee contract, and delete the node identifier of the first node in the consensus node list.
For a specific implementation manner of the first executing unit 231, the transaction determining unit 232, the service determining unit 233, the second executing unit 234, the validity verifying unit 235, the coroutine releasing unit 236, the state switching unit 237 and the node deleting unit 238, reference may be made to the description of step S207 in the embodiment corresponding to fig. 8, which will not be described herein again.
The specific implementation manners of the block receiving module 21, the transaction selecting module 22 and the validity verifying module 23 may refer to the descriptions of step S205 to step S207 in the embodiment corresponding to fig. 8, and will not be described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, please refer to fig. 14, fig. 14 is a schematic structural diagram of a computer device according to an embodiment of the present application. As shown in fig. 14, the computer device 2000 may include: the processor 2001, the network interface 2004 and the memory 2005, the computer device 2000 may further include: a user interface 2003, and at least one communication bus 2002. The communication bus 2002 is used to implement connection communication between these components. The user interface 2003 may include a Display (Display) and a Keyboard (Keyboard), and the optional user interface 2003 may further include a standard wired interface and a standard wireless interface. Optionally, the network interface 2004 may include a standard wired interface, a wireless interface (e.g., WI-FI interface). Memory 2005 may be a high-speed RAM memory or a non-volatile memory (e.g., at least one disk memory). Alternatively, the memory 2005 may be at least one storage device located remotely from the aforementioned processor 2001. As shown in fig. 14, the memory 2005 which is a kind of computer-readable storage medium may include therein an operating system, a network communication module, a user interface module, and a device control application program.
In the computer device 2000 shown in fig. 14, the network interface 2004 may provide a network communication function; and the user interface 2003 is primarily used to provide an interface for user input; and processor 2001 may be used to invoke device control applications stored in memory 2005.
It should be understood that the computer device 2000 described in this embodiment may perform the description of the transaction data processing method in the embodiment corresponding to fig. 3 and fig. 8, and may also perform the description of the transaction data processing apparatus 1 and the transaction data processing apparatus 2 in the embodiment corresponding to fig. 12 and fig. 13, which is not described herein again. In addition, the beneficial effects of the same method are not described in detail.
Further, here, it is to be noted that: an embodiment of the present application further provides a computer-readable storage medium, where the aforementioned computer programs executed by the transaction data processing apparatus 1 and the transaction data processing apparatus 2 are stored in the computer-readable storage medium, and the computer programs include program instructions, and when the processor executes the program instructions, the description of the transaction data processing method in the embodiment corresponding to fig. 3 and fig. 8 can be executed, so that details are not repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in embodiments of the computer-readable storage medium referred to in the present application, reference is made to the description of embodiments of the method of the present application.
Further, it should be noted that: embodiments of the present application also provide a computer program product or computer program, which may include computer instructions, which may be stored in a computer-readable storage medium. The processor of the computer device reads the computer instruction from the computer-readable storage medium, and the processor can execute the computer instruction, so that the computer device executes the description of the transaction data processing method in the embodiment corresponding to fig. 3 and fig. 8, which is described above, and therefore, the description thereof will not be repeated here. In addition, the beneficial effects of the same method are not described in detail. For technical details not disclosed in the embodiments of the computer program product or the computer program referred to in the present application, reference is made to the description of the embodiments of the method of the present application.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium and can include the processes of the embodiments of the methods described above when the computer program is executed. The storage medium may be a magnetic disk, an optical disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), or the like.
The above disclosure is only for the purpose of illustrating the preferred embodiments of the present application and is not to be construed as limiting the scope of the present application, so that the present application is not limited thereto, and all equivalent variations and modifications can be made to the present application.

Claims (15)

1. A transaction data processing method, performed by a packing node in a blockchain network, comprising:
acquiring a first transaction service from N transaction services to be packaged, taking the transaction services except the first transaction service in the N transaction services as a first transaction service, acquiring a read data set corresponding to the first transaction service when the packaging node executes the N transaction services in series, and acquiring a read data set corresponding to the first transaction service; n is a positive integer; the transaction execution sequence of the first transaction service is earlier than that of the first transaction service;
executing the first transaction service based on the read data set corresponding to the first transaction service to obtain a first service execution result of the first transaction service, obtaining a write data set of the first transaction service based on the first service execution result, and taking the first transaction service as a preamble transaction service associated with the first transaction service;
determining a transaction execution sequence of the first transaction service in the N transaction services, and performing conflict detection on the first transaction service based on the transaction execution sequence, a write data set corresponding to the preorder transaction service, a read data set corresponding to the first transaction service, and a conflict detection condition to obtain a conflict detection result;
if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the preorder transaction services, taking the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service, and recording a service dependency relationship between the first transaction service and the forward dependency service; the business dependency relationship comprises a serial dependency relationship and a parallel dependency relationship; the parallel dependency is determined by a transaction service in a parallel transaction data set to which the first transaction service belongs; the serial dependency is determined by a forward dependency associated with the first transaction;
and constructing a directed acyclic graph associated with the N transaction services based on the recorded serial dependency relationship and parallel dependency relationship, packaging the directed acyclic graph and the N transaction services to obtain an proposed block carrying the directed acyclic graph, and sending the proposed block to a consensus node in the block chain network, so that the consensus node executes the N transaction services in the proposed block in a serial and parallel combined manner based on the service dependency relationship indicated by the directed acyclic graph in the proposed block.
2. The method according to claim 1, wherein the executing the first transaction service based on the read data set corresponding to the first transaction service obtains a first service execution result of the first transaction service, obtains a write data set of the first transaction service based on the first service execution result, and regards the first transaction service as a preamble transaction service associated with the first transaction service, includes:
taking the transaction cache component of the packaging node as a transaction cache for recording a transaction read-write set of each transaction service;
recording a read data set corresponding to the first transaction service through a transaction buffer in the packaging node, and executing the first transaction service based on the read data set corresponding to the first transaction service to obtain a first service execution result of the first transaction service;
adding the first business execution result to a first transaction write cache of the first transaction business, and constructing a write data set corresponding to the first transaction business based on data stored in the first transaction write cache;
and recording a write data set corresponding to the first transaction service through the transaction buffer, and taking the first transaction service as a preamble transaction service associated with the first transaction service.
3. The method of claim 2, further comprising:
taking a conflict detection component of the packaging node as a conflict detector for carrying out conflict detection on each transaction service;
when the first transaction service is executed based on the read data set corresponding to the first transaction service, performing conflict detection on the first transaction service through the conflict detector;
and when the conflict detector determines that no preamble transaction service associated with the first transaction service exists in the N transaction services, ending the step of carrying out conflict detection on the first transaction service.
4. The method of claim 1, wherein when the first transaction service is taken as a preceding transaction service associated with the first transaction service, the method further comprises:
the first transaction service is taken as a subsequent transaction service associated with the first transaction service; wherein the number of subsequent transaction transactions comprises one or more.
5. The method of claim 1, wherein the read data set corresponding to the first transaction service is recorded by a transaction buffer of the packaging node;
the determining a transaction execution sequence of the first transaction service in the N transaction services, and performing conflict detection on the first transaction service based on the transaction execution sequence, a write data set corresponding to the preamble transaction service, a read data set corresponding to the first transaction service, and a conflict detection condition to obtain a conflict detection result includes:
when the transaction service to be executed acquired from the N transaction services is a transaction N-1, taking the transaction N-1 as the first transaction service, and searching the transaction service which is earlier than the first transaction service in the transaction execution sequence and has been executed in the N transaction services based on the transaction execution sequence of the first transaction service in the N transaction services;
the searched transaction execution sequence is earlier than the first transaction service and the executed transaction services are all used as the preorder transaction services related to the first transaction service;
acquiring a transaction write cache of the preamble transaction service, and acquiring a write data set corresponding to the preamble transaction service from the transaction write cache through the transaction cache;
and acquiring a conflict detection condition for conflict detection through a conflict detector of the packaging node, and performing conflict detection on the first transaction service based on the write data set corresponding to the preorder transaction service, the read data set corresponding to the first transaction service and the conflict detection condition to obtain a conflict detection result.
6. The method of claim 5, wherein the obtaining, by the collision detector of the packaging node, a collision detection condition for collision detection, and performing collision detection on the first transaction traffic based on the write data set corresponding to the preamble transaction traffic, the read data set corresponding to the first transaction traffic, and the collision detection condition to obtain a collision detection result comprises:
acquiring a conflict detection condition for performing conflict detection through a conflict detector of the packaging node, and performing character string comparison on the read data set corresponding to the first transaction service and the write data set corresponding to the preorder transaction service to obtain a character string comparison result;
if the character string comparison result indicates that an overlapping character string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service, determining the preamble transaction service with the overlapping character string as a target preamble transaction service meeting the conflict detection condition;
adding the transaction index value of the first transaction service to an initial transaction subfield corresponding to a history key field of the target preamble transaction service to obtain a target transaction subfield of the target preamble transaction service, and performing incremental processing on the dependence number in a transaction parent field of the first transaction service in the target key field of the first transaction service to obtain an incremental transaction parent field;
and taking a target transaction subfield of the target preamble transaction service and the incremented transaction parent field as a conflict detection result associated with the first transaction service.
7. The method according to claim 6, wherein in the N transaction services, the number of preamble transaction services associated with the first transaction service is N-2, the N-2 preamble transaction services including at least transaction N-2;
if the conflict detection result indicates that the transaction service meeting the conflict detection condition exists in the pre-preamble transaction services, taking the transaction service meeting the conflict detection condition as a forward dependency service associated with the first transaction service, and recording a service dependency relationship between the first transaction service and the forward dependency service, including:
if the conflict detection result indicates that the target preamble transaction service meeting the conflict detection condition in the N-2 preamble transaction services is the transaction N-2, taking the transaction N-2 as a forward dependent service associated with the transaction N-1;
determining a serial dependency relationship between the transaction N-1 and the transaction N-2 based on the forward dependency service, and taking the serial dependency relationship as a recorded service dependency relationship between the first transaction service and the forward dependency service.
8. The method of claim 6, wherein the read data set corresponding to the first transaction and the write data set corresponding to the preceding transaction are comprised of key-value pairs; the keys in the data reading set corresponding to the first transaction service belong to the character strings in the data reading set corresponding to the first transaction service, and the keys in the data writing set corresponding to the preorder transaction service belong to the character strings in the data writing set corresponding to the preorder transaction service;
the comparing the character string of the read data set corresponding to the first transaction service with the write data set corresponding to the preorder transaction service to obtain a character string comparison result, including:
judging the keys in the read data set corresponding to the first transaction service and the keys in the write data set corresponding to the preorder transaction service;
if the overlapped key exists between the key in the read data set corresponding to the first transaction service and the key in the write data set corresponding to the preorder transaction service, determining that an overlapped character string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preorder transaction service;
and taking the overlapping character string existing between the determined read data set corresponding to the first transaction service and the write data set corresponding to the preorder transaction service as a character string comparison result.
9. The method of claim 8, wherein the dependent number of each transaction in the parallel transaction data set is a target threshold, and the target threshold is 0;
the method further comprises the following steps:
if the character string comparison result indicates that no overlapping character string exists between the read data set corresponding to the first transaction service and the write data set corresponding to the preamble transaction service, determining the preamble transaction service as the transaction service which does not meet the conflict detection condition, and based on the transaction service which does not meet the conflict detection condition, adding the first transaction service to the parallel transaction data set when the dependency number in the transaction parent field of the first transaction service is set as the target threshold value in the target key field of the first transaction service; the parallel dependency exists between each transaction in the parallel transaction data set.
10. The method of claim 1, wherein the directed acyclic graph is obtained by the packaging node constructing a first connection service and M second connection services through a directed acyclic graph constructor; m is a non-negative integer less than N; the first connection service is a transaction service corresponding to a transaction parent field carrying a target threshold value selected from the N transaction services based on the recorded parallel dependency relationship; the M second connection services are sub-transaction lists associated with the first connection services and acquired from target transaction subfields of the first connection services based on the recorded serial dependency;
the method further comprises the following steps:
and if the sub-transaction list comprises 0 transaction services, determining that a second connection service having a connection relation with the first connection service does not exist in the directed acyclic graph.
11. The method of claim 10, further comprising:
taking the M second connection services as new first connection services, and acquiring a sub-transaction list associated with the new first connection services from a target transaction subfield of the new first connection services on the basis of serial dependency relations in the recorded service dependency relations; and the sub-transaction list associated with the new first connection service comprises new P second connection services, and the P second connection services are used for constructing the directed acyclic graph.
12. The method of claim 1, wherein the directed acyclic graph storage component in the packing node is a directed acyclic graph storage;
the method further comprises the following steps:
storing the directed acyclic graph by the directed acyclic graph memory and storing N transaction transactions associated with the directed acyclic graph to a transaction list; in the transaction list, a transaction includes a transaction parent field and a transaction child field.
13. A transaction data processing method, performed by any one of consensus nodes in a blockchain network, comprising:
receiving an proposed block which is sent by a packing node in the block chain network and carries a directed acyclic graph; the directed acyclic graph is constructed by the packaging node based on business dependency relations among the N transaction businesses in the proposal block; the service dependency relationship is determined by the first transaction service and a forward dependency service associated with the first transaction service after the first transaction service and the first transaction service are obtained from the N transaction services by the packaging node; the forward dependency service is obtained by the packaging node performing conflict detection on the first transaction service based on a transaction execution sequence of the first transaction service in the N transaction services, a write data set corresponding to a preamble transaction service of the first transaction service, a read data set corresponding to the first transaction service, and a conflict detection condition; the preorder transaction service of the first transaction service comprises the first transaction service; the first transaction service is a transaction service except the first transaction service in the N transaction services; n is a positive integer;
based on the parallel dependency relationship in the business dependency relationship indicated by the directed acyclic graph, selecting a transaction business meeting a transaction execution condition from the N transaction businesses, taking the selected transaction business as a first connection business, and acquiring a sub-transaction list associated with the first connection business; the sub-transaction list comprises M second connection services; m is a non-negative integer less than N; the first connection service comprises the first transaction service;
and constructing an auxiliary acyclic graph associated with the N transaction services in the proposed block based on the first connection services and the M second connection services, and performing legal verification on the directed acyclic graph based on the auxiliary acyclic graph.
14. The method of claim 13, wherein the consensus node comprises a transaction orchestrator and a transaction execution negotiation pool associated with the transaction orchestrator; the transaction execution coroutine pool comprises a first coroutine for executing the first connection service; the first coroutine is a coroutine in an idle state determined in the transaction execution coroutine pool;
the method further comprises the following steps:
when the number of the first protocol is smaller than the number of the first connection services, executing a part of the first connection services through the first protocol, and when a new idle first protocol exists in the transaction execution protocol pool, executing another part of the first connection services by using the new idle first protocol.
15. The method of claim 13, wherein the consensus node comprises a transaction orchestrator and a transaction execution negotiation pool associated with the transaction orchestrator; the number of the first connection services is X2; the transaction execution coroutine pool contains X1 first coroutines for executing the first connection service; the X1 first routines are routines in an idle state as determined in the transaction execution routine pool; the X2 is a positive integer less than the X1;
the method further comprises the following steps:
executing X2 first connection businesses through X2 of the X1 coroutines; a first connection service corresponds to a first protocol;
in the transaction execution coroutine pool, the remaining (X1-X2) first coroutines in an idle state are used as second coroutines for executing second connection traffic.
CN202110442672.8A 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment Active CN113034142B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110442672.8A CN113034142B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110122558.7A CN112508573B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment
CN202110442672.8A CN113034142B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment

Related Parent Applications (1)

Application Number Title Priority Date Filing Date
CN202110122558.7A Division CN112508573B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment

Publications (2)

Publication Number Publication Date
CN113034142A CN113034142A (en) 2021-06-25
CN113034142B true CN113034142B (en) 2022-08-02

Family

ID=74952518

Family Applications (2)

Application Number Title Priority Date Filing Date
CN202110122558.7A Active CN112508573B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment
CN202110442672.8A Active CN113034142B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment

Family Applications Before (1)

Application Number Title Priority Date Filing Date
CN202110122558.7A Active CN112508573B (en) 2021-01-29 2021-01-29 Transaction data processing method and device and computer equipment

Country Status (1)

Country Link
CN (2) CN112508573B (en)

Families Citing this family (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113923217B (en) * 2021-09-30 2024-04-16 中国人民解放军国防科技大学 Asynchronous Bayesian-busy family consensus method and system based on DAG
CN114529417A (en) * 2022-02-25 2022-05-24 蚂蚁区块链科技(上海)有限公司 Method for executing transaction, block chain, main node and slave node
CN114328133A (en) * 2022-03-16 2022-04-12 北京微芯感知科技有限公司 Single-mechanism distributed conflict detection method and system and deposit separation framework
CN115220924A (en) * 2022-07-29 2022-10-21 蚂蚁区块链科技(上海)有限公司 Transaction conflict detection method in blockchain system and blockchain node
CN115373824B (en) * 2022-10-24 2023-02-03 恒生电子股份有限公司 Conflict detection method, device, computing equipment and computer readable storage medium
CN116109112B (en) * 2023-04-12 2023-06-27 徐工汉云技术股份有限公司 Service data processing method, device, medium and equipment based on aggregation interface

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508337A (en) * 2018-11-12 2019-03-22 杭州秘猿科技有限公司 A kind of transaction is parallel to execute method, apparatus, electronic equipment and system
CN110806923A (en) * 2019-10-29 2020-02-18 百度在线网络技术(北京)有限公司 Parallel processing method and device for block chain tasks, electronic equipment and medium
CN111724258A (en) * 2020-05-28 2020-09-29 天津大学 Realization method of alliance chain transaction concurrent scheme based on ring topology, dependency graph and multi-version control

Family Cites Families (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20150172412A1 (en) * 2012-07-06 2015-06-18 Cornell University Managing dependencies between operations in a distributed system
US10255108B2 (en) * 2016-01-26 2019-04-09 International Business Machines Corporation Parallel execution of blockchain transactions
CN106897351B (en) * 2016-12-29 2020-11-10 北京瑞卓喜投科技发展有限公司 Generation method and system of directed acyclic graph block chain
CN107679857B (en) * 2017-10-10 2021-04-27 马晶瑶 Block chain cross-chain transaction method and storage medium
KR101946196B1 (en) * 2018-03-26 2019-02-08 그래프 블록체인 리미티드 Control system for controlling private block-chain system
CN108537543B (en) * 2018-03-30 2023-07-28 百度在线网络技术(北京)有限公司 Parallel processing method, device, equipment and storage medium for blockchain data
CN108958925B (en) * 2018-04-26 2023-06-20 武汉龙津科技有限公司 Energy-saving workload proving method and system
CN108846659B (en) * 2018-06-13 2021-09-14 深圳前海微众银行股份有限公司 Block chain-based transfer method and device and storage medium
CN110728578A (en) * 2019-09-29 2020-01-24 南京金宁汇科技有限公司 Parallel execution method, system and storage medium for block chain transaction
CN111340482B (en) * 2020-02-10 2021-06-01 腾讯科技(深圳)有限公司 Conflict detection method, device, node equipment and storage medium
CN111506783B (en) * 2020-04-08 2023-12-22 百度在线网络技术(北京)有限公司 Transaction request processing method, device, equipment and medium in blockchain
CN111556115B (en) * 2020-04-22 2023-04-21 财付通支付科技有限公司 Block chain-based data processing method, device, equipment and storage medium
CN112150163A (en) * 2020-11-26 2020-12-29 北京微芯区块链与边缘计算研究院 Block chain contract transaction parallel execution method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109508337A (en) * 2018-11-12 2019-03-22 杭州秘猿科技有限公司 A kind of transaction is parallel to execute method, apparatus, electronic equipment and system
CN110806923A (en) * 2019-10-29 2020-02-18 百度在线网络技术(北京)有限公司 Parallel processing method and device for block chain tasks, electronic equipment and medium
CN111724258A (en) * 2020-05-28 2020-09-29 天津大学 Realization method of alliance chain transaction concurrent scheme based on ring topology, dependency graph and multi-version control

Also Published As

Publication number Publication date
CN113034142A (en) 2021-06-25
CN112508573B (en) 2021-04-30
CN112508573A (en) 2021-03-16

Similar Documents

Publication Publication Date Title
CN113034142B (en) Transaction data processing method and device and computer equipment
US20170083579A1 (en) Distributed data processing method and system
CN113570466B (en) Transaction data processing method and device and readable storage medium
US10924281B2 (en) Method and apparatus for inter-blockchain transmission of authenticable message
CN111523890B (en) Block chain-based data processing method, device, storage medium and equipment
US12079130B2 (en) Method and apparatus for processing data based on block chain, device and readable storage medium
US20230370285A1 (en) Block-chain-based data processing method, computer device, computer-readable storage medium
JP2019523952A (en) Streaming data distributed processing method and apparatus
CN112037061A (en) Processing method and device for transactions in block chain, electronic equipment and storage medium
CN114092252B (en) Block chain transaction execution method, device, equipment and readable storage medium
CN111885050A (en) Data storage method and device based on block chain network, related equipment and medium
CN114647698A (en) Data synchronization method and device and computer storage medium
CN112527504A (en) Multi-tenant resource quota management method and device, and computer equipment
Tennakoon et al. CollaChain: A BFT collaborative middleware for decentralized applications
CN116703601B (en) Data processing method, device, equipment and storage medium based on block chain network
WO2023142605A1 (en) Blockchain-based data processing method and related apparatus
CN117692401A (en) Message sending method, device, server and storage medium
CN113709059A (en) Link flow recording method and node
CN117539649B (en) Identification management method, equipment and readable storage medium of distributed cluster
CN117874060B (en) Supply chain product traceability data multi-condition query method and device based on block chain
CN115174589B (en) Selection method and device of blockchain virtual machine, electronic equipment and storage medium
CN118041998A (en) Data processing method, device, equipment and medium
CN110889040B (en) Method and device for pushing information
CN110213314B (en) Method, device and server for determining storage node
CN116318623A (en) Block chain-based data sharing server and data transmission method

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: 40046835

Country of ref document: HK

GR01 Patent grant
GR01 Patent grant