CN116977067A - Block chain-based data processing method, device, equipment and readable storage medium - Google Patents
Block chain-based data processing method, device, equipment and readable storage medium Download PDFInfo
- Publication number
- CN116977067A CN116977067A CN202310110568.8A CN202310110568A CN116977067A CN 116977067 A CN116977067 A CN 116977067A CN 202310110568 A CN202310110568 A CN 202310110568A CN 116977067 A CN116977067 A CN 116977067A
- Authority
- CN
- China
- Prior art keywords
- block
- transaction
- cache data
- consensus
- transaction execution
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
- 238000003672 processing method Methods 0.000 title claims abstract description 21
- 238000000034 method Methods 0.000 claims abstract description 140
- 238000012545 processing Methods 0.000 claims abstract description 132
- 238000001514 detection method Methods 0.000 claims description 47
- 238000002360 preparation method Methods 0.000 claims description 27
- 238000004590 computer program Methods 0.000 claims description 16
- 238000004891 communication Methods 0.000 claims description 11
- 230000006870 function Effects 0.000 claims description 4
- 238000004806 packaging method and process Methods 0.000 claims description 3
- 238000010586 diagram Methods 0.000 description 10
- 238000012856 packing Methods 0.000 description 6
- 238000005516 engineering process Methods 0.000 description 4
- 230000000977 initiatory effect Effects 0.000 description 4
- 238000012546 transfer Methods 0.000 description 4
- 238000013473 artificial intelligence Methods 0.000 description 2
- 230000009286 beneficial effect Effects 0.000 description 2
- 238000012217 deletion Methods 0.000 description 2
- 230000037430 deletion Effects 0.000 description 2
- 230000002085 persistent effect Effects 0.000 description 2
- 230000001960 triggered effect Effects 0.000 description 2
- VLFZHMWZMNJMTK-UHFFFAOYSA-N CCC.CCC.CCC.CCC Chemical compound CCC.CCC.CCC.CCC VLFZHMWZMNJMTK-UHFFFAOYSA-N 0.000 description 1
- 238000007792 addition Methods 0.000 description 1
- 230000006399 behavior Effects 0.000 description 1
- 238000013461 design Methods 0.000 description 1
- 230000000737 periodic effect Effects 0.000 description 1
- 230000002123 temporal effect Effects 0.000 description 1
- 238000012795 verification Methods 0.000 description 1
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
- G06Q40/04—Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/27—Replication, distribution or synchronisation of data between databases or within a distributed database system; Distributed database system architectures therefor
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/46—Multiprogramming arrangements
- G06F9/54—Interprogram communication
- G06F9/546—Message passing systems or structures, e.g. queues
-
- Y—GENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
- Y02—TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
- Y02D—CLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
- Y02D10/00—Energy efficient computing, e.g. low power processors, power management or thermal management
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- Physics & Mathematics (AREA)
- Accounting & Taxation (AREA)
- Finance (AREA)
- Databases & Information Systems (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Development Economics (AREA)
- General Business, Economics & Management (AREA)
- Technology Law (AREA)
- Strategic Management (AREA)
- Marketing (AREA)
- Computing Systems (AREA)
- Economics (AREA)
- Data Mining & Analysis (AREA)
- Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
Abstract
The invention discloses a data processing method, a device, equipment and a readable storage medium based on a blockchain, which comprises the following steps: in the process of carrying out the consensus processing of the first block, carrying out the consensus processing of the second block in parallel through a consensus pool; in the process of carrying out consensus processing on the second block, executing the transactions in the transaction execution pool in parallel according to the transaction data sequence numbers to obtain transaction execution cache data, and adding the transaction execution cache data corresponding to the transactions in the transaction execution pool to a queue to be merged; if the second block passes the consensus, and the to-be-merged queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and block cache data of the first block exists, conflict merging processing is carried out on the transaction execution cache data related to the second block in the to-be-merged queue, so as to obtain the block cache data of the second block, and the block cache data of the second block is added to the storage queue. By adopting the method and the device, the block chain performance can be improved.
Description
Technical Field
The present application relates to the field of computer technologies, and in particular, to a data processing method, apparatus, device and readable storage medium based on a blockchain.
Background
Because of the non-tamper property and authenticity of blockchains, enterprises begin to utilize blockchain networks to store transaction data to ensure the security of the transaction data.
Currently, in most blockchain networks in the industry, transactions need to be subjected to processes of blocky consensus, transaction execution, account book deposit and the like during uplink. Wherein, the block consensus belongs to IO (network) intensive tasks, and the realization of the process mainly utilizes network resources at the moment; transaction execution belongs to a CPU (central processing unit, central processing unit intensive) intensive task, and at this time, the realization of the process mainly utilizes CPU resources; the deposit book belongs to an IO (hard disk) intensive task, and at the moment, the realization of the process mainly utilizes hard disk resources. In some block chain networks, for example, PBFT (practical b/f) fault tolerance algorithm, the processes of block consensus, transaction execution, and account deposit corresponding to each block are executed by a single line Cheng Chuanhang, which results in that system resources such as network, CPU, storage, etc. cannot be fully utilized, for example, when block consensus is performed, CPU resources are idle, and the idle of system resources is unfavorable for improving the performance of the block chain.
Disclosure of Invention
The embodiment of the application provides a data processing method, device and equipment based on a blockchain and a readable storage medium, which can fully utilize system resources and improve the performance of the blockchain.
In one aspect, an embodiment of the present application provides a data processing method based on a blockchain, including:
acquiring a second block in the process of carrying out the consensus processing of the first block through the consensus pool, and carrying out the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
in the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to a transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged;
if the consensus processing result of the second block is a consensus passing result, and the to-be-combined queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and block cache data of the first block exists, performing conflict combination processing on the transaction execution cache data related to the second block in the to-be-combined queue to obtain the block cache data of the second block, and adding the block cache data of the second block into the storage queue; the block cache data in the store queue is for sequential writing into the blockchain ledger.
In one aspect, an embodiment of the present application provides a data processing apparatus based on a blockchain, including:
the parallel consensus module is used for acquiring a second block in the process of performing the consensus processing of the first block through the consensus pool, and performing the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
the parallel execution module is used for adding the transaction in the second block into the transaction execution pool according to the transaction data sequence number in the process of carrying out consensus processing on the second block, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged;
the conflict merging module is used for carrying out conflict merging processing on the transaction execution cache data related to the second block in the queue to be merged to obtain the block cache data of the second block and adding the block cache data of the second block to the storage queue if the consensus processing result of the second block is a consensus passing result and the queue to be merged contains the transaction execution cache data corresponding to each transaction in the second block respectively and the block cache data of the first block exists; the block cache data in the store queue is for sequential writing into the blockchain ledger.
Wherein, the parallel consensus module includes:
the state determining unit is used for determining the running state of the consensus pool in the process of performing the consensus processing of the first block through the consensus pool;
and the assembly consensus unit is used for assembling the second block based on the transaction pool if the running state of the consensus pool is in an unsaturated running state, and carrying out consensus processing on the second block through the consensus pool.
Wherein the state determining unit includes:
the first detection subunit is used for detecting the number of the blocks in the consensus pool, which are being subjected to the consensus processing, as the number of the parallel consensus blocks in the process of performing the consensus processing of the first blocks through the consensus pool;
the first detection subunit is further configured to determine that the operation state of the consensus pool is an operation unsaturated state if the number of parallel consensus blocks is less than a first number threshold.
Wherein the consensus pool comprises one or more block consensus threads;
a state determination unit comprising:
the second detection subunit is used for detecting the running state of one or more block consensus threads in the process of carrying out the consensus processing of the first block through the consensus pool;
the second detection subunit is further configured to determine that the running state of the consensus pool is an running unsaturated state if one or more of the block consensus threads includes a block consensus thread whose running state is an idle state.
Wherein the consensus pool comprises one or more block consensus threads;
an assembled consensus unit comprising:
the packing subunit is used for acquiring a transaction to be packed from the transaction pool according to the block configuration information, and packing the transaction to be packed to obtain a second block;
a thread selection subunit, configured to obtain, from one or more block consensus threads, a block consensus thread whose running state is an idle state, as a target block consensus thread;
and the thread consensus subunit is used for carrying out consensus processing of the second block through the target block consensus thread.
The thread consensus subunit is specifically configured to construct pre-preparation information for the second block through a target block consensus thread, and broadcast the pre-preparation information to the consensus node cluster, so that the consensus node cluster performs pre-voting processing on the second block according to the pre-preparation information to obtain a first pre-voting result; pre-voting treatment is carried out on the second block to obtain a second pre-voting result; broadcasting a second pre-voting result to the consensus node cluster, so that the consensus node cluster performs pre-submitting processing on the second block according to the first pre-voting result and the second pre-voting result to obtain a first pre-submitting result; when the number of the pre-voting approval results in the received first pre-voting result and the second pre-voting result exceeds a second number threshold, pre-submitting the second block to obtain a second pre-submitting result; and when the number of the pre-submitted and approved results in the received first pre-submitted results and second pre-submitted results exceeds a pre-submitted and approved number threshold, determining that the consensus processing result of the second block is a consensus passing result.
Wherein, parallel execution module includes:
the transaction adding unit is used for adding the transaction in the second block into the transaction execution pool according to the transaction data sequence number in the process of carrying out consensus processing on the second block;
the transaction execution unit is used for acquiring a transaction execution thread with an idle running state in the transaction execution pool, and sequentially acquiring the transaction to be executed from the transaction execution pool through the transaction execution thread; the transaction quantity of the transactions to be executed is equal to the thread quantity corresponding to the transaction execution threads with idle running states;
the transaction execution unit is also used for executing the transaction to be executed in parallel to obtain transaction execution cache data corresponding to the transaction to be executed;
the transaction execution unit is further configured to sequentially add the transaction execution buffer data to the queue to be merged according to the block height corresponding to the transaction to be executed and the transaction data sequence number.
Wherein, conflict merge module includes:
the traversing unit is used for traversing the transaction execution cache data related to the second block in the queue to be merged in sequence to acquire kth transaction execution cache data; k is a positive integer less than or equal to H; h is the total number of transactions corresponding to the transactions in the second block;
The conflict detection unit is used for performing conflict detection on the cached data of the kth transaction to obtain a data conflict detection result;
the first merging unit is used for carrying out conflict merging and updating on the k transaction execution cache data if the conflict detection result corresponding to the k transaction execution cache data is a data conflict result, so as to obtain k merged and updated cache data;
the second merging unit is used for taking the kth transaction execution cache data as the kth merging and updating cache data if the conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result;
and the block cache determining unit is used for combining the H pieces of updated cache data to serve as the block cache data of the second block.
Wherein the kth transaction execution cache data comprises transaction execution read cache data;
a collision detection unit comprising:
an obtaining subunit, configured to obtain latest transaction execution read cache data of a transaction corresponding to the kth transaction execution cache data;
the detection subunit is used for determining that the conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result if the latest transaction execution read cache data is the same as the transaction execution read cache data;
The detection subunit is further configured to determine that the collision detection result corresponding to the kth transaction execution cache data is a data collision result if the latest transaction execution read cache data is different from the transaction execution read cache data.
The kth transaction execution cache data further comprises transaction execution write cache data;
a first merging unit comprising:
the latest execution subunit is used for executing the transaction corresponding to the kth transaction execution cache data according to the latest transaction execution read cache data to obtain latest transaction write cache data;
an updating subunit, configured to update the transaction execution read cache data in the kth transaction execution cache data to the latest transaction execution read cache data, and update the transaction execution write cache data in the kth transaction execution cache data to the latest transaction write cache data;
and the updating subunit is further used for executing the updated k transaction execution cache data as k merging and updating cache data.
The acquisition subunit is specifically configured to find whether read cache data of a transaction corresponding to the kth transaction execution cache data exists in the updated cache data; the updated cache data comprises block cache data in a storage queue and k-1 updated transaction cache data related to the second block, which are respectively corresponding to the combined updated cache data; k-1 updated transaction cache data are transaction execution cache data before the kth transaction execution cache data at a position or an adding time in a queue to be merged; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the updated cache data, taking the read cache data of the transaction corresponding to the kth transaction execution cache data in the updated cache data as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the k transaction execution cache data is not found in the updated cache data, searching whether the read cache data of the transaction corresponding to the k transaction execution cache data exists in the blockchain ledger; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the blockchain account book, the read cache data of the transaction corresponding to the kth transaction execution cache data in the blockchain account book is used as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the kth transaction execution cache data is not found in the blockchain account book, taking the default blank data as the latest transaction execution read cache data.
Wherein, above-mentioned data processing apparatus still includes:
and the deleting module is used for deleting the transaction execution cache data related to the second block from the queue to be merged after the block cache of the second block is added to the storage queue.
In one aspect, an embodiment of the present application provides a computer device, including: a processor, a memory, a network interface;
the processor is connected to the memory and the network interface, where the network interface is used to provide a data communication network element, the memory is used to store a computer program, and the processor is used to call the computer program to execute the method in the embodiment of the present application.
In one aspect, embodiments of the present application provide a computer readable storage medium having a computer program stored therein, the computer program being adapted to be loaded by a processor and to perform a method according to embodiments of the present application.
In one aspect, embodiments of the present application provide a computer program product or computer program comprising computer instructions stored in a computer-readable storage medium, the computer instructions being read from the computer-readable storage medium by a processor of a computer device, the computer instructions being executed by the processor, causing the computer device to perform a method according to an embodiment of the present application.
In the embodiment of the application, in the process of carrying out the consensus processing of the first block through the consensus pool, a second block is obtained, and the consensus processing of the second block is continuously carried out through the consensus pool, wherein the first block is a father block of the second block, and the consensus processing of the first block and the consensus block of the second block are executed in parallel; then, in the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to the transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged; finally, if the consensus processing result of the second block is a consensus passing result, and the to-be-combined queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and block cache data of the first block exists, performing conflict combination processing on the transaction execution cache data related to the second block in the to-be-combined queue to obtain the block cache data of the second block, and adding the block cache data of the second block into the storage queue; the block cache data in the store queue is for sequential writing into the blockchain ledger. By the method provided by the embodiment of the application, the processes of block consensus, transaction execution, account book storage and the like of each block can be processed in parallel, and the processes of block consensus, transaction execution and the like of different blocks can also be processed in parallel, so that system resources such as a network, a CPU, storage and the like can be utilized as much as possible, and idle of the system resources is reduced, thereby improving the performance of a block chain.
Drawings
In order to more clearly illustrate the embodiments of the application or the technical solutions in the prior art, the drawings that are required in the embodiments or the description of the prior art will be briefly described, it being obvious that the drawings in the following description are only some embodiments of the application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic diagram of a network architecture according to an embodiment of the present application;
FIG. 2a is a schematic diagram of a scenario of a blockchain-based data processing provided by an embodiment of the present application;
FIG. 2b is a schematic diagram of a scenario of a blockchain-based data processing provided by an embodiment of the present application;
FIG. 3 is a flowchart of a block chain based data processing method according to an embodiment of the present application;
FIG. 4 is a flowchart of a block chain based data processing method according to an embodiment of the present application;
FIG. 5 is a schematic diagram of a block chain based data processing apparatus according to an embodiment of the present application;
fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the present application.
Detailed Description
The following description of the embodiments of the present application will be made clearly and completely with reference to the accompanying drawings, in which it is apparent that the embodiments described are only some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
For ease of understanding, the following simple explanation of partial nouns is first made:
1. blockchain (Block chain): in a narrow sense, the blockchain is a chain data structure taking a block as a basic unit, and the block uses a digital abstract to verify the transaction history acquired before, so that the blockchain is suitable for the requirements of tamper resistance and expandability in a distributed accounting scene; in a broad sense, blockchain also refers to distributed accounting techniques implemented by blockchain structures, including distributed consensus, privacy and security protection, point-to-point communication techniques, network protocols, smart contracts, and the like.
The goal of the blockchain is to implement a distributed data logging ledger that allows only additions and not deletions. The basic structure of the ledger floor is a linear linked list. The linked list is formed by serially connecting blocks, the Hash value of the preceding block is recorded in the following blocks, and whether each block (and the transaction in the block) is legal or not can be rapidly checked by calculating the Hash value. If a node in the network proposes to add a new block, a consensus acknowledgement must be made for the block via a consensus mechanism.
2. Block (block): the data packet carrying transaction data on the blockchain network is a data structure marked with a timestamp and a hash value corresponding to a preceding block, and the block verifies and confirms the transaction in the block through a consensus mechanism of the network. The Block includes a Block Header (Block Header) and a Block Body (Block Body), where the Block Header can record meta information of the current Block and includes data such as a current version number, a hash value corresponding to a previous Block, a timestamp, a random number, a hash value of a Merkle Root (Merkle Root), and the like. The block may record detailed data generated over a period of time, including all transaction records or other information generated during the creation of the block for which the current block is verified, and may be understood as a representation of the ledger. In addition, the detailed data of the block may include generating a unique Merkle Root record in the block header through a hash process of a Merkle Tree (Merkle Tree).
The successor Block, also called Parent Block (Parent Block), is a Block chain that performs temporal ordering by recording the hash value corresponding to the Block and the hash value corresponding to the Parent Block in the Block header.
3. Hash value (hash): also called information characteristic value or eigenvalue, hash value is generated by converting input data of arbitrary length into a password by hash algorithm and performing fixed output, and original input data cannot be retrieved by decrypting the hash value, which is a one-way encryption function. In a blockchain, each block (except the initial block) contains a hash value of the successor block, which is the potential core foundation and most important aspect in blockchain technology, which preserves the authenticity of the recorded and viewed data, as well as the integrity of the blockchain as a whole.
4. Smart Contract: the concept of intelligent contracts has three major elements of commitment, agreement and digital form, so that the application range of the blockchain can be expanded to all links of transaction, payment, settlement and clearing in the financial industry. Intelligent contracts refer to the immediate execution of corresponding contract terms when a pre-programmed condition is triggered, the working principle of which is similar to the if-then statement of a computer program.
Referring to fig. 1, fig. 1 is a schematic diagram of a blockchain network according to an embodiment of the present application. The blockchain network as shown in fig. 1 may include, but is not limited to, a blockchain network to which the federated chain corresponds. The blockchain network may include a plurality of blockchain nodes, and the plurality of blockchain nodes may include a blockchain node 10a, a blockchain node 10b, a blockchain node 10c, a blockchain node 10d, …, and a blockchain node 10n. Each blockchain node can receive data sent by the outside during normal operation, perform blockchain uplink processing based on the received data, and also can send the data to the outside. To ensure data interworking between the various blockchain nodes, a data connection may exist between each blockchain node, such as between blockchain node 10a and blockchain node 10b, between blockchain node 10a and blockchain node 10c, and between blockchain node 10b and blockchain node 10 c.
It will be appreciated that data or block transfer may be performed between the blockchain nodes via the data connections described above. The blockchain network may implement data connection between blockchain nodes based on node identifiers, and for each blockchain node in the blockchain network, each blockchain node may store node identifiers of other blockchain nodes having a connection relationship with itself, so as to broadcast the acquired data or generated blocks to other blockchain nodes according to the node identifiers of the other blockchain nodes, for example, the blockchain node 10a may maintain a node identifier list as shown in table 1, where the node identifier list stores node names and node identifiers of the other nodes:
TABLE 1
Node name | Node identification |
Node 10a | AAA.AAA.AAA.AAA |
Node 10b | BBB.BBB.BBB.BBB |
Node 10c | CCC.CCC.CCC.CCC |
Node 10d | DDD.DDD.DDD.DDD |
… | … |
Node 10n | EEE.EEE.EEE.EEE |
The node identifier may be any of a protocol (Internet Protocol, IP) address for interconnection between networks, and any other information that can be used to identify a node in a blockchain network, and the IP address is only illustrated in table 1. For example, the blockchain node 10a may send information (e.g., a block) to the blockchain node 10b through the node identification bbb.bbb.bbb.bbb.bbb, and the blockchain node 10b may determine that the information was sent by the blockchain node 10a through the node identification aaa.aaa.aaa.
In a blockchain, a block must be consensus-passed through consensus nodes in the blockchain network before the block is uplink, and the block can be added to the blockchain after the consensus passes. It will be appreciated that when a blockchain is used in some contexts of a government or commercial establishment, not all participating nodes in the blockchain (i.e., blockchain nodes in the blockchain node system described above) have sufficient resources and necessity to become consensus nodes of the blockchain. For example, in the blockchain network shown in fig. 1, blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d may be considered as consensus nodes in the blockchain network. The consensus nodes in the blockchain network participate in consensus, namely, consensus is carried out on the blocks (comprising a batch of transactions), namely, voting is carried out on the blocks; while non-consensus nodes do not participate in consensus, but will help propagate block and vote messages, and synchronize status with each other, etc.
In the embodiment of the present application, in the blockchain network shown in fig. 1, the blockchain node with the consensus function, for example, the blockchain node 10a, if in the process of performing the consensus processing of the first block through the consensus pool, can acquire the second block, and perform the consensus processing of the second block through the consensus pool. The first block is a parent block of the second block. That is, the blockchain node 10a may perform the consensus process of the first block and the consensus process of the second block in parallel through the consensus pool. In addition, in the process of performing the consensus processing on the second block, the blockchain node 10a may add the transaction in the second block to the transaction execution pool according to the transaction data sequence number, execute the transaction in the transaction execution pool in parallel to obtain the transaction execution cache data corresponding to the transaction in the transaction execution pool, and then add the transaction execution cache data corresponding to the transaction in the transaction execution pool to the queue to be merged, that is, the transaction execution and the block consensus may be processed in parallel, and the transaction may also be executed in parallel. However, it can be understood that, in order to ensure the security of the data and the accuracy of the data, only when the blockchain node 10a determines that the result of the consensus processing of the second block is a result of the consensus passing, and the to-be-merged queue includes the transaction execution cache data corresponding to each transaction in the second block, and the block cache data of the first block exists, the blockchain node 10a performs the conflict merging processing on the transaction related to the second block in the to-be-merged queue to obtain the block cache data of the second block, and adds the block cache data of the second block to the storage queue. Wherein the block cache data in the store queue is for being written sequentially into the blockchain ledger. The conflict combining process is to compare whether the data read when executing the contract in the transaction are changed when executing the preamble transaction according to the serial number of the transaction data one by one, and if the data are changed, the transaction is executed again according to the latest data, and the transaction execution cache data corresponding to the transaction are updated; and if the transaction execution cache data is not changed, reserving transaction execution cache data corresponding to the transaction.
It should be understood that the above data connection is not limited to a 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, or may be connected through other connection manners, which is not limited herein.
It can be appreciated that the data processing method provided by the embodiment of the present application may be performed by a computer device, where the computer device includes, but is not limited to, the above-mentioned main chain node (which may be a terminal or a server), a sub-link node (which may be a terminal or a server), and a terminal device. 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 cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDNs, basic cloud computing services such as big data and artificial intelligence platforms. The terminal may be, but is not limited to, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart speaker, a smart watch, etc.
It is to be appreciated that embodiments of the present application may be applied to a variety of scenarios including, but not limited to, cloud technology, artificial intelligence, intelligent transportation, assisted driving, etc. For example, the block link point system may perform consensus on some driving behavior data, road track data, and the like sent by the vehicle-mounted terminal, and store the consensus on the vehicle-mounted terminal after the consensus passes.
It will be appreciated that in the specific embodiments of the present application, related data such as transaction data, status data, etc. are referred to, and when the above embodiments of the present application are applied to specific products or technologies, user permissions or consents are required, and the collection, use and processing of related data is required to comply with relevant laws and regulations and standards of relevant countries and regions.
For convenience of description, the block having the block height X is referred to as a block X throughout, and the block height X is described as a block height X, where X is a positive integer. For example, a block with a block height of 1 is named block 1, and a block with a block height of 1 is described as block height 1; the block with the block height m is named as the block m, the block height m is described as the block height m, and the corresponding blocks of other block heights are named as well, and the detailed description is omitted herein.
It will be appreciated that different blockchain networks may use different consensus algorithms, and that the blockconsensus corresponding to the different consensus algorithms is different from the transaction execution process, and for better understanding of the parallel execution process, the current blockchain network will be described by taking the PBFT consensus algorithm as an example. In a blockchain network employing a PBFT consensus algorithm, the assembly of blocks and initiation of the consensus is typically done by a master node (also referred to as a block out node), where the master node is a blockchain node selected from all blockchain nodes based on the PBFT consensus algorithm. In the blockchain network adopting the PBFT consensus algorithm, when the master node does not fail or the blockchain network does not have errors, the master node is not changed generally, namely the same blockchain node is always responsible for the packaging of the blocks and the initiation of consensus.
Referring to fig. 2 a-2 b, the blockchain node 20a and the blockchain node 20b shown in fig. 2 a-2 b may be any blockchain node in the blockchain network shown in fig. 1, for example, the blockchain node 20a is the blockchain node 10a, and the blockchain node 20b is the blockchain node 10n; the blockchain node 20a and the blockchain node 20b may also be the same blockchain node, such as blockchain node 20a and blockchain node 20b are both blockchain node 10a.
Referring to fig. 2a, fig. 2a is a schematic diagram of a scenario of a blockchain-based data processing according to an embodiment of the present application. As shown in FIG. 2a, blockchain node 20a is the master node in the current blockchain network. The blockchain node 20a acts as a master node and needs to be responsible for the assembly of blocks and initiation of consensus. As shown in fig. 2a, the blockchain node 20a may obtain a transaction to be packaged from the transaction pool according to the blockwise configuration information, and then generate a blockwise m based on the transaction to be packaged. The transaction pool is used for storing the transactions known in the blockchain network but not yet contained in the blockchain, such as the transaction Tx1, the transaction Tx2, … and the transaction Txn, and the master node generates a new block from a fixed number of transactions to be packed acquired from the transaction pool when assembling the new block, but the refresh operation of the transaction pool is triggered, namely, the transaction already contained in the blockchain is deleted, each time the new block agrees and is then inserted into the blockchain structure.
Referring back to fig. 2a, after the blockchain node 20a assembles the blockm, the blockm is added to the consensus pool, then the consensus for the blockm is initiated through the consensus pool, that is, the blockm is broadcast into the blockchain network, and then the blockchain node 20a performs the consensus for the blockm together with the consensus nodes in the blockchain network. The consensus pool may include a plurality of block consensus threads, and one block consensus thread may complete the consensus of one block, so when a plurality of blocks are added to the consensus pool, the consensus for a plurality of blocks may be initiated in parallel by different block consensus threads. As shown in FIG. 2a, while blockchain node 20a is adding blockm to the pool, blockchain node 20a determines the operational status of the pool, if blockchain node 20a determines that the pool is in an operational unsaturated status, blockchain node 20a obtains a new transaction to be packaged from the pool, and then generates blockm+1 based on the new transaction to be packaged. Wherein, the fact that the consensus pool is in an operation unsaturated state means that the number of blocks in the consensus pool does not reach the maximum block accommodating number of the consensus pool, or that the consensus pool has a block consensus thread with an operation state of an idle state. The blockchain node 20a then adds the block m+1 to the consensus pool as well, and then initiates a consensus for the block m+1 through the consensus pool. It will be appreciated that the block consensus requires a certain amount of time, and therefore, the block m consensus may not be completed when the block chain node 20a performs the block m+1 consensus, i.e., the block m and the block m+1 consensus are performed in parallel for the block chain node 20a, and the two do not affect each other.
Referring to fig. 2b, fig. 2b is a schematic diagram of a scenario of data processing based on a blockchain according to an embodiment of the present application. As shown in fig. 2a or 2b, the block m may include a transaction T (m,1) …, transaction T (m,n) Block m+1 may include transaction T (m+1,1) …, transaction T (m+1,n) . Wherein, trade T (a,b) A in the subscript indicates that the transaction belongs to a block a, b in the subscript indicates that the transaction data sequence number, a and b are positive integers, and b is less than or equal to the total number of transactions in the block a.
As shown in fig. 2b, after obtaining the block m, the blockchain node 20b puts the block m into the consensus pool, and puts the block m into the transaction execution pool; the blockchain node 20b may then proceed to acquire the block m+1, then place the block m+1 into the consensus pool while placing the block m+1 into the transaction execution pool. As shown in fig. 2b, the blockchain node 20b may share each block in parallel through the consensus pool, and the blockchain node 20b may perform the consensus process for block m and the consensus process for block m+1 in parallel. The process of the consensus process depends on a consensus algorithm used in the blockchain network, and in the blockchain network adopting the PBFT consensus algorithm, the consensus process comprises a pre-preparation stage, a preparation stage and a submission stage, that is, the blocks need to agree through a three-stage protocol.
As shown in fig. 2b, the blockchain node 20b may perform parallel execution of transactions through the transaction execution pool while the blockchain node 20b performs parallel consensus of blocks through the consensus pool. As shown in FIG. 2b, when the blockchain node 20b performs the blockm method transaction execution pool, the transaction is added to the transaction execution pool according to the transaction data sequence number, i.e., T is added (m,1) …, transaction T (m,n) Sequentially adding the blocks into a transaction execution pool, and after the block m+1 is acquired, dividingThe block link points 20b will sequentially carry the transaction T (m+1,1) …, transaction T (m+1,n) Sequentially adding the data to the transaction execution pool. When the transaction execution pool has free transaction execution threads, the blockchain node 20b may execute T in parallel through the transaction execution pool (m,1) …, transaction T (m,n) 、T (m+1,1) …, transaction T (m+1,n) Obtaining transaction execution cache data corresponding to each transaction respectively, namely transaction execution cache data C (m,1) … transaction execution cache data C (m,n) Transaction execution cache data C (m+1,1) … transaction execution cache data C (m+1,n) Then, the blockchain node 20b sequentially adds the transaction execution cache data to the queue to be merged according to the blockheight corresponding to the transaction execution cache data and the transaction data sequence number. The transaction execution cache data may include transaction execution read cache data that needs to be read before the transaction execution, and transaction execution write cache data that needs to be written into the blockchain ledger after the execution is completed.
It will be appreciated that the transaction may be performed in parallel with the block consensus, but after the transaction is performed, the blockchain node 20b may not determine that the corresponding transaction execution cache data is to be written to the blockchain until the block consensus is passed. It will be appreciated that when the blockchain node 20b executes a plurality of transactions in parallel, it is assumed that the transactions are not intersected and not affected, that is, the transaction execution cache data corresponding to the transactions are all different data. In practical application, there may be an intersection between the transactions, so when determining that a certain block is commonly passed, the blockchain node 20b needs to execute the conflict merging processing on the cached data corresponding to the block to obtain the cached data corresponding to the block. For ease of understanding, taking block m as an example, as shown in FIG. 2b, the blockchain node 20b, after determining that block m is common, will perform the caching of data C for the transaction (m,1) … transaction execution cache data C (m,n) And performing conflict merging processing to obtain block m cache data. Wherein the conflict combination processing is performed by comparing contracts in the transaction one by one according to the transaction data sequence number If the data read by the line is changed when the preamble transaction is executed, executing the transaction again according to the latest data, and updating transaction execution cache data corresponding to the transaction; and if the transaction execution cache data is not changed, reserving transaction execution cache data corresponding to the transaction. The specific implementation process of the conflict combining process may be referred to as the following description in the embodiment corresponding to fig. 4.
As shown in fig. 2b, the blockchain node 20b will first add the merged blockm cache data to the storage queue, and it will be appreciated that, to ensure the storage order, it is necessary to wait for the blockm cache data of the preamble block (blockm-1) to be already entered into the storage queue before the blockchain node 20b will add the blockm cache data to the storage queue. Finally, the blockchain node 20b writes the block cache data into the blockchain ledger according to the sequence in the storage queue, so as to implement persistent storage.
The above-mentioned application can provide a solution for block parallel consensus and execution, block-to-block parallel consensus, and block-to-block parallel execution, thereby fully utilizing system resources and greatly improving the performance of the blockchain network.
Further, referring to fig. 3, fig. 3 is a flowchart of a data processing method based on a blockchain according to an embodiment of the present application. The data processing method may be performed by a blockchain node (e.g., any of the blockchain nodes in the blockchain node system of the embodiment described above with respect to fig. 1). The present data processing method will be described below by taking the block link point execution as an example. The data processing method based on the blockchain at least comprises the following steps of S101 to S103:
step S101, in the process of carrying out the consensus processing of the first block through the consensus pool, acquiring a second block, and carrying out the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel.
Specifically, the blockchain nodes in the blockchain network may be divided into a consensus node, a data node and a light node, where the consensus node is responsible for the consensus of the blockchain whole network, and in the consensus node, a master node may be selected based on a consensus algorithm in the blockchain network and used for responsible for the assembly of the blocks and the initiation of the consensus. The process of writing the transaction into the account book in the blockchain network can be that the client sends the transaction to the data node or the light node, then the transaction is transmitted between the data node or the light node in the blockchain network in a baton mode until the master node receives the transaction data, the master node packages the transaction into a block, performs consensus among other consensus nodes, and writes the block carrying the transaction into the account book after the consensus passes. It will be appreciated that based on the difference of the consensus algorithm, the master node may perform a periodic rotation between the consensus nodes, or may reselect a new master node after the current master node fails. In addition, the consensus process of different consensus algorithms is different, but the existing consensus process generally requires a plurality of consensus nodes to broadcast information to each other, the waiting time is long, and the consensus and execution of each block are generally executed by a single line Cheng Chuanhang, which results in that system resources such as network, CPU, storage and the like cannot be fully utilized. Therefore, the application provides a block consensus and execution parallelization method, which processes the consensus flow, execution flow and storage flow of a plurality of blocks in parallel and fully utilizes the system resources.
Specifically, if the blockchain node is a consensus node that is not a master node, the above-mentioned process of performing the consensus processing of the first block by the consensus pool, to obtain the second block, and one possible implementation process of performing the consensus processing of the second block by the consensus pool may be: determining the running state of the consensus pool in the process of performing the consensus processing of the first block through the consensus pool; acquiring a second block sent by a master node; and if the running state of the consensus pool is the running unsaturated state, performing consensus processing of the second block through the consensus pool. The running state of the consensus pool is an unsaturated running state, which means that the number of blocks which can be commonly recognized in parallel in the consensus pool does not reach the maximum allowable parallel number.
Specifically, if the blockchain node is the master node, the above-mentioned process of performing the consensus processing of the first block through the consensus pool to obtain the second block, and one possible implementation process of performing the consensus processing of the second block through the consensus pool may be: determining the running state of the consensus pool in the process of performing the consensus processing of the first block through the consensus pool; if the running state of the consensus pool is the running unsaturated state, assembling a second block based on the transaction pool, and performing consensus processing of the second block through the consensus pool.
In the process of performing the consensus processing of the first block through the consensus pool, one possible implementation process of determining the running state of the consensus pool may be: detecting the number of blocks in the consensus pool, which are being subjected to the consensus processing, as the number of parallel consensus blocks in the process of performing the consensus processing of the first block through the consensus pool; if the number of parallel consensus blocks is smaller than the first number threshold, determining that the running state of the consensus pool is an unsaturated running state. Wherein the first number threshold is used to characterize the number of blocks that the pool of consensus can at most agree in parallel. For example, if the first number threshold is 8 and the number of blocks in the consensus is 5, the running state of the consensus pool may be determined to be a running unsaturated state. It is understood that the first number threshold may be set according to an actual application scenario, or may be set according to other situations.
Wherein the consensus pool comprises one or more block consensus threads; in the process of performing the consensus processing of the first block through the consensus pool, one possible implementation process of determining the operation state of the consensus pool may be: detecting the running state of one or more block consensus threads in the process of carrying out the consensus processing of the first block through the consensus pool; if one or more block consensus threads comprise a block consensus thread with an idle running state, determining that the running state of the consensus pool is an unsaturated running state. For example, after detecting the running state of one or more block consensus threads, the block link point determines that the current consensus pool includes an idle block consensus thread E1, an idle block consensus thread E2, an idle block consensus thread E3, an idle block consensus thread E4, an idle block consensus thread E5, an idle block consensus thread E6, an idle block consensus thread E7, a busy block consensus thread E8, and a busy block consensus thread E9, where the idle block consensus thread refers to a block consensus thread whose running state is an idle state, i.e. a thread that is not performing block consensus processing; the busy block consensus thread refers to a block consensus thread whose running state is busy, i.e., a thread that is performing block consensus processing. Therefore, the blockchain node can determine that the running state of the consensus pool is in a running unsaturated state, and then the blockchain node can arbitrarily select one from the idle blockconsensus threads to perform the consensus processing of the second block. It can be appreciated that the number of block consensus threads in the consensus pool may be set according to the actual application scenario, or may be set according to other situations.
Specifically, the consensus pool may include one or more block consensus threads, where the second block is assembled, and one possible implementation procedure of performing the consensus processing of the second block by the consensus pool may be: obtaining a transaction to be packaged from a transaction pool according to the block configuration information, and packaging the transaction to be packaged to obtain a second block; acquiring a block consensus thread with an idle running state from one or more block consensus threads as a target block consensus thread; and performing consensus processing of the second block through the target block consensus thread. The block allocation information may include block-related allocation information, such as a fixed number of transactions that the block should contain. The block consensus thread with the idle running state can be selected randomly, can be set according to the actual application scene, or can be set according to other conditions.
Specifically, when the blockchain network adopts the PBFT consensus algorithm, the PBFT consensus process includes three phases, namely a pre-preparation phase, a preparation phase and a submitting phase, and a feasible implementation process of performing the second block consensus process through the target block consensus thread at this time may be: constructing pre-preparation information aiming at a second block through a target block consensus thread, broadcasting the pre-preparation information to a consensus node cluster, so that the consensus node cluster performs pre-voting treatment on the second block according to the pre-preparation information to obtain a first pre-voting result; pre-voting treatment is carried out on the second block to obtain a second pre-voting result; broadcasting a second pre-voting result to the consensus node cluster, so that the consensus node cluster performs pre-submitting processing on the second block according to the first pre-voting result and the second pre-voting result to obtain a first pre-submitting result; when the number of the pre-voting approval results in the received first pre-voting result and the second pre-voting result exceeds a second number threshold, pre-submitting the second block to obtain a second pre-submitting result; and when the number of the pre-submitted and approved results in the received first pre-submitted results and second pre-submitted results exceeds a pre-submitted and approved number threshold, determining that the consensus processing result of the second block is a consensus passing result. For example, when the master node performs the consensus for block X, it will broadcast a piece of pre-preparation information for block m to all consensus nodes to initiate the consensus for block m. Then, after receiving the pre-preparation message sent by the master node, the other consensus node checks the pre-preparation message, and after the check passes, the other consensus node receives the pre-preparation message and enters a preparation stage. At this time, all consensus nodes broadcast a preparation message (including one of the pre-vote approval result and the pre-vote disagreement result) to all other consensus nodes, and write the preparation message into a log, when the consensus node receives the preparation message from other consensus nodes, the preparation message is written into the log after verification is successful, when the consensus node has received the preparation message corresponding to the block X and the preparation message corresponding to 2f+1 (f generally refers to the maximum number of error-allowed consensus nodes, 2f+1 is the second number threshold value) from different consensus nodes (which may include themselves), the block X can be considered ready at this time, and the commit phase is entered. The consensus node then broadcasts a commit message (containing one of the pre-commit endorsement result and the pre-commit anti-result) and writes it to the log; when the consensus node receives a commit message, it can write it into the log after it is checked successfully. When block X is ready and the consensus node receives 2f+1 commit messages corresponding to block X from a different consensus node (which may include itself) containing pre-commit approval results, block X may be considered committed, i.e., block X consensus passes.
Step S102, in the process of performing the consensus processing on the second block, adding the transaction in the second block to a transaction execution pool according to a transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool to a queue to be merged.
Specifically, in the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to the transaction data sequence number; acquiring a transaction execution thread with an idle running state in a transaction execution pool, and sequentially acquiring a transaction to be executed from the transaction execution pool through the transaction execution thread; the transaction quantity of the transactions to be executed is equal to the thread quantity corresponding to the transaction execution threads with idle running states; executing the transaction to be executed in parallel to obtain transaction execution cache data corresponding to the transaction to be executed; and adding the transaction execution cache data to the queue to be merged in sequence according to the block height corresponding to the transaction to be executed and the transaction data sequence number. For example, taking the second block as the block m+1 shown in FIG. 2b, the block m+1 includes the transaction T (m+1,1) …, transaction T (m+1,n) Blockchain node 20b is ordering transactions T (m+1,1) …, transaction T (m+1,n) Adding to a transaction execution pool. The blockchain node 20b can determine the transaction execution thread with the idle running state in the transaction execution pool at regular time, and it is assumed that the transaction execution pool includes idle transaction execution thread E1, idle transaction execution thread E2, idle transaction execution thread E3, idle transaction execution thread E4, idle transaction execution thread E5, idle transaction execution thread E6, idle transaction execution thread E7, busy transaction execution thread E8 and busy transaction execution thread E9, and it is known that the transaction execution pool currently has 7 transaction execution threads with the idle running state, and at this time, the blockchain node 20b sequentially obtains 7 transactions to be executed from the transaction execution pool, and it is assumed that the transaction included in the transaction execution pool has transaction T at this time (m,n-1) 、T (m,n) 、T (m+1,1) …, transaction T (m+1,n) The blockchain node 20b may acquire the transaction T (m,n-1) 、T (m,n) 、T (m+1,1) …, transaction T (m+1,5) As transactions to be performed, these 7 transactions to be performed are then performed in parallel, i.e. transaction T (m,n-1) Adding the transaction T into an idle transaction execution thread E1 (m,n) Adding the transaction T into an idle transaction execution thread E2 (m+1,1) Adding the transaction T to an idle transaction execution thread E3 (m+1,2) Adding the transaction T to an idle transaction execution thread E4 (m+1,3) Adding the transaction T to an idle transaction execution thread E5 (m+1,4) Adding to idle transaction execution thread E6 and executing transaction T (m+1,5) Added to the idle transaction execution thread E7.
Specifically, the transaction execution cache data corresponding to the transaction includes transaction execution read cache data which needs to be read before the transaction is executed, and transaction execution write cache data which needs to be written into the blockchain ledger after the execution is completed. It can be understood that when the block link points execute multiple transactions in parallel, it is assumed that the multiple transactions are not intersected and not affected, that is, the transaction execution cache data corresponding to the transactions are all different data. In practical application, there may be an intersection between the transactions, that is, the transaction execution buffer data corresponding to the transaction with the front transaction data sequence number may affect the transaction execution buffer data with the rear transaction data sequence number, so the blockchain node needs to use the block as a unit to perform conflict merging processing on the transaction execution buffer data corresponding to the transaction contained in the block, so as to obtain the block buffer data to which the block should be written into the ledger.
It can be understood that when executing the transaction in parallel, because the number of transaction execution threads is limited, the transaction in the second block may be partially executed and partially awaiting execution, so that the blockchain node will first add the transaction execution cache data corresponding to the transaction to the queue to be merged according to the transaction data sequence number, and await the conflict merge processing.
Step S103, if the result of the consensus processing of the second block is a consensus passing result, and the to-be-combined queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and the block cache data of the first block exists, performing conflict combination processing on the transaction execution cache data related to the second block in the to-be-combined queue to obtain the block cache data of the second block, and adding the block cache data of the second block to the storage queue; the block cache data in the store queue is for being written sequentially into a blockchain ledger.
Specifically, the conflict merging processing is to compare whether the transaction execution cache data read during contract execution in the transaction is changed during the execution of the preceding transaction according to the transaction data sequence number one by one, and if so, the transaction is required to be executed again according to the latest data, and the transaction execution cache data corresponding to the transaction is updated; and if the transaction execution cache data is not changed, reserving transaction execution cache data corresponding to the transaction. For example, in the second block, transaction 1 with transaction data number 1 is "a transfers 5 to B", transaction 2 with transaction data number 2 is "a transfers 3 to C", transaction 3 with transaction data number 3 is "E transfers 2", block link points execute transaction 1, transaction 2 and transaction 3 in parallel, at this time, the account balance of a is 10, the account balance of E is 8, and in the transaction execution cache data corresponding to transaction 1, the account balance of a is 5; in the transaction execution cache data corresponding to the transaction 2, the account balance of the A is 7; in the transaction execution cache data corresponding to the transaction 3, the account balance of E is 6. Obviously, the account balance of A should be changed after the transaction 1 is executed, so that the transaction execution cache data corresponding to the transaction 2 is inaccurate, the transaction 2 can be re-executed at the moment, the account balance of A read at the moment is the account balance of A after the transaction 1 is executed, namely 5, and therefore, the account balance of A is 2 after the transaction 2 is executed; in addition, the account balance of E does not need to be changed after the transaction 1 and the transaction 2 are executed, so that the transaction execution cache data of the transaction 3 can be considered to be correct and can be directly used.
Specifically, after all transactions in the second block are conflict-combined according to the transaction data sequence number, the block cache data of the second block is obtained, and in order to ensure the storage sequence, the block chain node needs to wait until the block cache data of the preceding block (i.e. the first block) has entered the storage queue, and then adds the block cache data of the second block into the storage queue. Finally, the blockchain node writes the block cache data into the blockchain ledger according to the sequence in the storage queue so as to realize persistent storage.
Optionally, after adding the block cache of the second block to the store queue, the transaction execution cache data associated with the second block may be deleted from the queue to be merged.
By the method provided by the embodiment of the application, the processes of block consensus, transaction execution, account book storage and the like of each block can be processed in parallel, and the processes of block consensus, transaction execution and the like of different blocks can also be processed in parallel, so that system resources such as a network, a CPU, storage and the like can be utilized as much as possible, and idle of the system resources is reduced, thereby improving the performance of a block chain.
Further, referring to fig. 4, fig. 4 is a flowchart of a data processing method based on a blockchain according to an embodiment of the present application. The data processing method may be performed by a blockchain node (e.g., any of the blockchain nodes in the blockchain node system of the embodiment described above with respect to fig. 1). The present data processing method will be described below by taking the block link point execution as an example. The blockchain-based data processing method at least includes the following steps S201 to S207:
Step S201, in the process of carrying out the consensus processing of the first block through the consensus pool, acquiring a second block, and carrying out the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel.
Step S202, in the process of performing the consensus processing on the second block, adding the transaction in the second block to a transaction execution pool according to a transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool to a queue to be merged.
Specifically, the implementation process of step S201 to step 202 may refer to the specific description of step S101 to step S102, and will not be described herein.
Step S203, if the result of the consensus processing of the second block is a consensus passing result, and the to-be-merged queue includes transaction execution cache data corresponding to each transaction in the second block, and the block cache data of the first block exists, the transaction execution cache data related to the second block in the to-be-merged queue is traversed in sequence, so as to obtain kth transaction execution cache data.
Specifically, k is a positive integer less than or equal to H; and H is the total number of transactions corresponding to the transactions in the second block.
Step S204, performing conflict detection on the cached data of the kth transaction to obtain a data conflict detection result.
Specifically, the kth transaction execution cache data includes transaction execution read cache data; performing collision detection on the buffered data for the kth transaction to obtain a feasible implementation process of the data collision detection result may be: acquiring latest transaction execution read cache data of a transaction corresponding to the kth transaction execution cache data; if the latest transaction execution read cache data is the same as the transaction execution read cache data, determining that a conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result; if the latest transaction execution read cache data is different from the transaction execution read cache data, determining that the conflict detection result corresponding to the kth transaction execution cache data is a data conflict result. The latest transaction execution read cache data and the transaction execution read cache data are the same, which indicates that the execution of the preamble transaction does not affect the kth transaction, so that the conflict detection result corresponding to the kth transaction execution cache data can be determined as a data non-conflict result; the latest transaction execution read cache data is different from the transaction execution read cache data, which indicates that the execution of the preamble transaction affects the kth transaction, so that the conflict detection result corresponding to the kth transaction execution cache data can be determined as a data conflict result.
Specifically, a feasible implementation process of obtaining the latest transaction execution read cache data of the transaction corresponding to the kth transaction execution cache data may be: searching whether read cache data of a transaction corresponding to the kth transaction execution cache data exists in the updated cache data; the updated cache data comprises block cache data in a storage queue and k-1 updated transaction cache data related to the second block, which are respectively corresponding to the combined updated cache data; k-1 updated transaction cache data are transaction execution cache data before the kth transaction execution cache data at a position or an adding time in a queue to be merged; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the updated cache data, taking the read cache data of the transaction corresponding to the kth transaction execution cache data in the updated cache data as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the k transaction execution cache data is not found in the updated cache data, searching whether the read cache data of the transaction corresponding to the k transaction execution cache data exists in the blockchain ledger; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the blockchain account book, the read cache data of the transaction corresponding to the kth transaction execution cache data in the blockchain account book is used as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the kth transaction execution cache data is not found in the blockchain account book, taking the default blank data as the latest transaction execution read cache data. That is, when the latest transaction execution read cache data of the transaction corresponding to the kth transaction execution cache data is obtained, the blockchain node will preferentially read the relevant data in the kth-1 merge update cache data (i.e. the obtained merge update cache data after the merge conflict processing is performed on the kth-1 transaction execution cache data), if not found, then continue to query the kth-2 merge update cache data, and so on; if the blockchain node does not inquire the related data in the combined updating cache data related to the second block, the blockchain node inquires from the block cache data in the storage queue, firstly inquires the block cache data of a parent block (namely the first block), and then inquires the block cache data corresponding to the parent block of the first block, and so on; if the block chain link point does not inquire the related data in the storage queue, the block chain node then goes to the block chain account book to inquire the related data; the blockchain node can use the queried related data as the latest transaction execution read cache data; if the related data is not acquired in the blockchain ledger, the default blank data is used as the latest transaction execution read cache data.
In step S205, if the conflict detection result corresponding to the kth transaction execution cache data is a data conflict result, the kth transaction execution cache data is conflict-combined and updated to obtain kth combined and updated cache data.
Specifically, the kth transaction execution cache data further includes transaction execution write cache data; the method for performing conflict merge update on the k transaction execution cache data to obtain a feasible implementation process of the k merge update cache data may be: executing the transaction corresponding to the kth transaction execution cache data according to the latest transaction execution read cache data to obtain latest transaction write cache data; updating the transaction execution read cache data in the kth transaction execution cache data into the latest transaction execution read cache data, and updating the transaction execution write cache data in the kth transaction execution cache data into the latest transaction write cache data; and taking the updated k transaction execution cache data as k merging and updating cache data.
Step S206, if the conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result, using the kth transaction execution cache data as the kth merge update cache data.
Step S207, H merging and updating cache data are used as the block cache data of the second block, and the block cache data of the second block are added to the storage queue; the block cache data in the store queue is for being written sequentially into a blockchain ledger.
By adopting the scheme of block consensus and transaction execution parallelization provided by the embodiment of the application, the consensus flow, execution and storage flow of each block of the consensus are processed in parallel, so that the IO (network) intensive block consensus flow can fully utilize the network, the CPU intensive transaction execution flow can fully utilize the CPU, the IO (hard disk) intensive storage flow can fully utilize the hard disk, the consensus efficiency is improved, the consensus performance is limited by the bottlenecks of the three blocks, and the consensus performance can be improved through the expansion of resources.
Referring to fig. 5, fig. 5 is a schematic structural diagram of a data processing apparatus according to an embodiment of the present application. The data processing apparatus may be a computer program (including program code) running on a computer device, for example the data processing apparatus is an application software; the device can be used for executing corresponding steps in the data processing method provided by the embodiment of the application. As shown in fig. 5, the data processing apparatus 1 may include: a parallel consensus module 11, a parallel execution module 12 and a conflict merge module 13.
The parallel consensus module 11 is configured to obtain a second block during the consensus processing of the first block by using the consensus pool, and perform the consensus processing of the second block by using the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
the parallel execution module 12 is configured to, in the process of performing the consensus processing on the second block, add the transaction in the second block to the transaction execution pool according to the transaction data sequence number, execute the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and add the transaction execution cache data corresponding to the transaction in the transaction execution pool to the queue to be merged;
the conflict merging module 13 is configured to, if the result of the consensus processing of the second block is a consensus passing result, and the to-be-merged queue includes transaction execution cache data corresponding to each transaction in the second block, respectively, and there is block cache data of the first block, perform conflict merging processing on the transaction execution cache data related to the second block in the to-be-merged queue, obtain block cache data of the second block, and add the block cache data of the second block to the storage queue; the block cache data in the store queue is for sequential writing into the blockchain ledger.
The specific implementation manner of the parallel consensus module 11, the parallel execution module 12, and the conflict combination module 13 may refer to the description of step S101 to step S103 in the embodiment corresponding to fig. 3, and the description is not repeated here.
Wherein, the parallel consensus module 11 comprises: the state determination unit 111 and the assembly consensus unit 112.
A state determining unit 111, configured to determine an operation state of the consensus pool in a process of performing consensus processing of the first block by the consensus pool;
and the assembly consensus unit 112 is configured to assemble the second block based on the transaction pool if the operation state of the consensus pool is an operation unsaturated state, and perform consensus processing of the second block through the consensus pool.
The specific implementation manner of the state determining unit 111 and the assembly consensus unit 112 may refer to the description of step S101 in the embodiment corresponding to fig. 3, and the description thereof is omitted herein.
Wherein the state determination unit 111 includes: a first detection subunit 1111.
A first detecting subunit 1111, configured to detect, as the number of parallel consensus blocks, the number of blocks in the consensus pool that are being subjected to the consensus process in the process of performing the consensus process of the first block by the consensus pool;
The first detection subunit 1111 is further configured to determine that the operation state of the consensus pool is an operation unsaturated state if the number of parallel consensus blocks is smaller than the first number threshold.
The specific implementation manner of the first detection subunit 1111 may refer to the description of step S101 in the embodiment corresponding to fig. 3, and will not be described herein.
Wherein the consensus pool comprises one or more block consensus threads;
the state determination unit 111 includes: a second detection subunit 1112.
A second detecting subunit 1112, configured to detect an operation state of one or more block consensus threads in a process of performing a consensus process of the first block through the consensus pool;
the second detecting subunit 1112 is further configured to determine that the running state of the consensus pool is a running unsaturated state if one or more of the block consensus threads includes a block consensus thread whose running state is an idle state.
The specific implementation manner of the second detection subunit 1112 may refer to the description of step S101 in the embodiment corresponding to fig. 3, and will not be described herein.
Wherein the consensus pool comprises one or more block consensus threads;
assembling the consensus unit 112, comprising: a packing subunit 1121, a thread selection subunit 1122, and a thread consensus subunit 1123.
The packing sub-unit 1121 is configured to obtain a transaction to be packed from the transaction pool according to the block configuration information, and perform packing processing on the transaction to be packed to obtain a second block;
a thread selection subunit 1122, configured to obtain, from the one or more block consensus threads, a block consensus thread whose running state is an idle state, as a target block consensus thread;
the thread consensus subunit 1123 is configured to perform a consensus process for the second block by using the target block consensus thread.
The specific implementation manner of the packing subunit 1121, the thread selecting subunit 1122, and the thread consensus subunit 1123 may be referred to the description of step S101 in the embodiment corresponding to fig. 3, and will not be repeated here.
The thread consensus subunit 1123 is specifically configured to construct pre-preparation information for the second block through a target block consensus thread, and broadcast the pre-preparation information to the consensus node cluster, so that the consensus node cluster performs pre-voting processing on the second block according to the pre-preparation information to obtain a first pre-voting result; pre-voting treatment is carried out on the second block to obtain a second pre-voting result; broadcasting a second pre-voting result to the consensus node cluster, so that the consensus node cluster performs pre-submitting processing on the second block according to the first pre-voting result and the second pre-voting result to obtain a first pre-submitting result; when the number of the pre-voting approval results in the received first pre-voting result and the second pre-voting result exceeds a second number threshold, pre-submitting the second block to obtain a second pre-submitting result; and when the number of the pre-submitted and approved results in the received first pre-submitted results and second pre-submitted results exceeds a pre-submitted and approved number threshold, determining that the consensus processing result of the second block is a consensus passing result.
The specific implementation manner of the thread consensus subunit 1123 may refer to the description of step S101 in the embodiment corresponding to fig. 3, and will not be repeated here.
Wherein the parallel execution module 12 comprises: the transaction adding unit 121 and the transaction executing unit 122.
A transaction adding unit 121, configured to add the transaction in the second block to the transaction execution pool according to the transaction data sequence number in the process of performing the consensus processing on the second block;
the transaction execution unit 122 is configured to obtain a transaction execution thread with an idle running state in the transaction execution pool, and sequentially obtain a transaction to be executed from the transaction execution pool through the transaction execution thread; the transaction quantity of the transactions to be executed is equal to the thread quantity corresponding to the transaction execution threads with idle running states;
the transaction execution unit 122 is further configured to execute the transaction to be executed in parallel, so as to obtain transaction execution cache data corresponding to the transaction to be executed;
the transaction execution unit 122 is further configured to sequentially add the transaction execution buffer data to the queue to be merged according to the block height corresponding to the transaction to be executed and the transaction data sequence number.
The specific implementation manner of the transaction adding unit 121 and the transaction executing unit 122 may refer to the description of step S102 in the embodiment corresponding to fig. 3, and will not be described herein.
Wherein, conflict merge module 13 includes: a traversing unit 131, a collision detecting unit 132, a first merging unit 133, a second merging unit 134, and a block buffer determining unit 135.
The traversing unit 131 is configured to sequentially traverse the transaction execution cache data related to the second block in the queue to be merged to obtain kth transaction execution cache data; k is a positive integer less than or equal to H; h is the total number of transactions corresponding to the transactions in the second block;
a conflict detection unit 132, configured to perform conflict detection on the buffered data for the kth transaction, to obtain a data conflict detection result;
the first merging unit 133 is configured to, if the conflict detection result corresponding to the kth transaction execution cache data is a data conflict result, perform conflict merge update on the kth transaction execution cache data to obtain kth merge update cache data;
a second merging unit 134, configured to, if the collision detection result corresponding to the kth transaction execution cache data is a data non-collision result, take the kth transaction execution cache data as the kth merged and updated cache data;
the block buffer determining unit 135 is configured to update the H merging update buffer data as the block buffer data of the second block.
The specific implementation manner of the traversing unit 131, the collision detecting unit 132, the first merging unit 133, the second merging unit 134, and the block buffer determining unit 135 may be referred to the description of step S203 to step S206 in the embodiment corresponding to fig. 4, and the detailed description is omitted here.
Wherein the kth transaction execution cache data comprises transaction execution read cache data;
the collision detection unit 132 includes: acquisition subunit 1321 and detection subunit 1322.
An acquiring subunit 1321, configured to acquire latest transaction execution read cache data of a transaction corresponding to the kth transaction execution cache data;
the detection subunit 1322 is configured to determine that the collision detection result corresponding to the kth transaction execution cache data is a data non-collision result if the latest transaction execution read cache data is the same as the transaction execution read cache data;
the detecting subunit 1322 is further configured to determine that the collision detection result corresponding to the kth transaction execution cache data is a data collision result if the latest transaction execution read cache data is not the same as the transaction execution read cache data.
The specific implementation manner of the acquiring subunit 1321 and the detecting subunit 1322 may refer to the description of step S204 in the embodiment corresponding to fig. 4, which is not described herein.
The kth transaction execution cache data further comprises transaction execution write cache data;
the first combining unit 133 includes: the latest execution subunit 1331 and the update subunit 1332.
A latest execution subunit 1331, configured to execute, according to the latest transaction execution read cache data, a transaction corresponding to the kth transaction execution cache data, to obtain latest transaction write cache data;
an updating subunit 1332, configured to update the transaction execution read cache data in the kth transaction execution cache data to the latest transaction execution read cache data, and update the transaction execution write cache data in the kth transaction execution cache data to the latest transaction write cache data;
the updating subunit 1332 is further configured to update the updated kth transaction execution cache data as kth consolidated update cache data.
The specific implementation manner of the latest execution subunit 1331 and the updating subunit 1332 may refer to the description of step S205 in the embodiment corresponding to fig. 4, and will not be described herein.
The acquiring subunit 1321 is specifically configured to find whether there is read cache data of a transaction corresponding to the kth transaction execution cache data in the updated cache data; the updated cache data comprises block cache data in a storage queue and k-1 updated transaction cache data related to the second block, which are respectively corresponding to the combined updated cache data; k-1 updated transaction cache data are transaction execution cache data before the kth transaction execution cache data at a position or an adding time in a queue to be merged; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the updated cache data, taking the read cache data of the transaction corresponding to the kth transaction execution cache data in the updated cache data as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the k transaction execution cache data is not found in the updated cache data, searching whether the read cache data of the transaction corresponding to the k transaction execution cache data exists in the blockchain ledger; if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the blockchain account book, the read cache data of the transaction corresponding to the kth transaction execution cache data in the blockchain account book is used as the latest transaction execution read cache data; if the read cache data of the transaction corresponding to the kth transaction execution cache data is not found in the blockchain account book, taking the default blank data as the latest transaction execution read cache data.
The specific implementation manner of the obtaining subunit 1321 may refer to the description of step S205 in the embodiment corresponding to fig. 4, which is not described herein.
Wherein, the above-mentioned data processing apparatus 1, further include: the module 14 is deleted.
The deleting module 14 is configured to delete the transaction execution cache data related to the second chunk from the queue to be merged after adding the chunk cache of the second chunk to the store queue.
The specific implementation manner of the deletion module 14 may refer to the optional description of step S103 in the embodiment corresponding to fig. 3, which is not described herein.
Referring to fig. 6, fig. 6 is a schematic structural diagram of a computer device according to an embodiment of the application. As shown in fig. 6, the data processing apparatus 1 in the embodiment corresponding to fig. 5 described above may be applied to a computer device 1000, and the computer device 1000 may include: processor 1001, network interface 1004, and memory 1005, and in addition, the above-described computer device 1000 may further include: a user interface 1003, and at least one communication bus 1002. Wherein the communication bus 1002 is used to enable connected communication between these components. The user interface 1003 may include a Display (Display), a Keyboard (Keyboard), and the optional user interface 1003 may further include a standard wired interface, a wireless interface, among others. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (non-volatile memory), such as at least one disk memory. The memory 1005 may also optionally be at least one storage device located remotely from the processor 1001. As shown in fig. 6, an operating system, a network communication module, a user interface module, and a device control application may be included in the memory 1005, which is a type of computer-readable storage medium.
In the computer device 1000 shown in fig. 6, the network interface 1004 may provide a network communication network element; while user interface 1003 is primarily used as an interface for providing input to a user; and the processor 1001 may be used to invoke a device control application stored in the memory 1005 to implement:
acquiring a second block in the process of carrying out the consensus processing of the first block through the consensus pool, and carrying out the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
in the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to a transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged;
if the consensus processing result of the second block is a consensus passing result, and the to-be-combined queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and block cache data of the first block exists, performing conflict combination processing on the transaction execution cache data related to the second block in the to-be-combined queue to obtain the block cache data of the second block, and adding the block cache data of the second block into the storage queue; the block cache data in the store queue is for sequential writing into the blockchain ledger.
It should be understood that the computer device 1000 described in the embodiments of the present application may perform the description of the data processing method in any of the foregoing embodiments corresponding to fig. 3 and fig. 4, which is not repeated herein. In addition, the description of the beneficial effects of the same method is omitted.
Furthermore, it should be noted here that: the embodiment of the present application further provides a computer readable storage medium, in which the computer program executed by the aforementioned data processing apparatus 1 is stored, and the computer program includes program instructions, when executed by the aforementioned processor, can execute the description of the data processing method in any of the foregoing embodiments corresponding to fig. 3 and 4, and therefore, the description will not be repeated here. In addition, the description of the beneficial effects of the same method is omitted. For technical details not disclosed in the embodiments of the computer-readable storage medium according to the present application, please refer to the description of the method embodiments of the present application.
The computer readable storage medium may be the data processing apparatus provided in any one of the foregoing embodiments or an internal storage unit of the computer device, for example, a hard disk or a memory of the computer device. The computer readable storage medium may also be an external storage device of the computer device, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) card, a flash card (flash card) or the like, which are provided on the computer device. Further, the computer-readable storage medium may also include both internal storage units and external storage devices of the computer device. The computer-readable storage medium is used to store the computer program and other programs and data required by the computer device. The computer-readable storage medium may also be used to temporarily store data that has been output or is to be output.
Furthermore, it should be noted here that: embodiments of the present application also provide a computer program product or computer program comprising 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 executes the computer instructions to cause the computer device to perform the method provided by the corresponding embodiment of any of the preceding figures 3, 4.
The terms first, second and the like in the description and in the claims and drawings of embodiments of the application are used for distinguishing between different objects and not for describing a particular sequential order. Furthermore, the term "include" and any variations thereof is intended to cover a non-exclusive inclusion. For example, a process, method, apparatus, article, or device that comprises a list of steps or elements is not limited to the list of steps or modules but may, in the alternative, include other steps or modules not listed or inherent to such process, method, apparatus, article, or device.
Those of ordinary skill in the art will appreciate that the elements and algorithm steps described in connection with the embodiments disclosed herein may be embodied as electronic hardware, as a computer software, or in a combination of the two, and that the elements and steps of the examples have been generally described in terms of network elements in the foregoing description to clearly illustrate the interchangeability of hardware and software. Whether these network elements are implemented in hardware or software depends on the specific application and design constraints of the solution. The skilled person may use different methods for implementing the described network elements for each specific application, but such implementation should not be considered to be beyond the scope of the present application.
The foregoing disclosure is illustrative of the present application and is not to be construed as limiting the scope of the application, which is defined by the appended claims.
Claims (15)
1. A blockchain-based data processing method, comprising:
acquiring a second block in the process of carrying out the consensus processing of the first block through the consensus pool, and carrying out the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
in the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to a transaction data sequence number, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged;
if the consensus processing result of the second block is a consensus passing result, and the to-be-combined queue contains transaction execution cache data corresponding to each transaction in the second block respectively, and the block cache data of the first block exists, performing conflict combination processing on the transaction execution cache data related to the second block in the to-be-combined queue to obtain the block cache data of the second block, and adding the block cache data of the second block to the storage queue; the block cache data in the store queue is for being written sequentially into a blockchain ledger.
2. The method according to claim 1, wherein the obtaining a second block during the consensus process of the first block by the consensus pool, the consensus process of the second block by the consensus pool, comprises:
determining the running state of a consensus pool in the process of performing consensus processing of a first block through the consensus pool;
and if the running state of the consensus pool is the running unsaturated state, assembling a second block based on the transaction pool, and performing consensus processing of the second block through the consensus pool.
3. The method of claim 2, wherein determining the operational status of the consensus pool during the consensus process of the first block through the consensus pool comprises:
detecting the number of blocks in the consensus pool, which are undergoing the consensus processing, as the number of parallel consensus blocks in the process of carrying out the consensus processing of the first block through the consensus pool;
and if the number of the parallel consensus blocks is smaller than a first number threshold, determining that the running state of the consensus pool is an unsaturated running state.
4. The method of claim 2, wherein the consensus pool comprises one or more block consensus threads;
The determining the operation state of the consensus pool in the process of performing the consensus processing of the first block through the consensus pool comprises the following steps:
detecting the running state of one or more block consensus threads in the process of performing the consensus processing of the first block through the consensus pool;
and if the one or more block consensus threads comprise block consensus threads with idle running states, determining that the running states of the consensus pool are running unsaturated states.
5. The method of claim 2, wherein the consensus pool comprises one or more block consensus threads; the second block is assembled based on the transaction pool, and the consensus processing of the second block is carried out through the consensus pool, which comprises the following steps:
obtaining a transaction to be packaged from a transaction pool according to the block configuration information, and packaging the transaction to be packaged to obtain a second block;
acquiring a block consensus thread with an idle running state from the one or more block consensus threads as a target block consensus thread;
and performing consensus processing of the second block through the target block consensus thread.
6. The method of claim 5, wherein the performing, by the target block consensus thread, the consensus process of the second block comprises:
Constructing pre-preparation information aiming at the second block through the target block consensus thread, broadcasting the pre-preparation information to a consensus node cluster, so that the consensus node cluster performs pre-voting processing on the second block according to the pre-preparation information to obtain a first pre-voting result;
pre-voting treatment is carried out on the second block to obtain a second pre-voting result;
broadcasting the second pre-voting result to the consensus node cluster, so that the consensus node cluster performs pre-submitting processing on the second block according to the first pre-voting result and the second pre-voting result to obtain a first pre-submitting result;
when the number of the pre-voting approval results in the received first pre-voting result and the second pre-voting result exceeds a second number threshold, pre-submitting the second block to obtain a second pre-submitting result;
and when the number of the pre-submitted and approved results in the received first pre-submitted results and the second pre-submitted results exceeds a pre-submitted and approved number threshold, determining that the consensus processing result of the second block is a consensus passing result.
7. The method according to claim 1, wherein in the process of performing the consensus processing on the second block, the transactions in the second block are added to a transaction execution pool according to a transaction data sequence number, the transactions in the transaction execution pool are executed in parallel, so as to obtain transaction execution cache data corresponding to the transactions in the transaction execution pool, and the transaction execution cache data corresponding to the transactions in the transaction execution pool is added to a queue to be merged, including:
In the process of carrying out consensus processing on the second block, adding the transaction in the second block into a transaction execution pool according to a transaction data sequence number;
acquiring a transaction execution thread with an idle running state in a transaction execution pool, and sequentially acquiring a transaction to be executed from the transaction execution pool through the transaction execution thread; the transaction quantity of the transactions to be executed is equal to the thread quantity corresponding to the transaction execution threads with the idle running state;
executing the transaction to be executed in parallel to obtain transaction execution cache data corresponding to the transaction to be executed;
and adding the transaction execution cache data to a queue to be merged in sequence according to the block height corresponding to the transaction to be executed and the transaction data sequence number.
8. The method of claim 1, wherein performing conflict merge processing on the transaction execution cache data related to the second chunk in the queue to be merged to obtain the chunk cache data of the second chunk, includes:
sequentially traversing transaction execution cache data related to the second block in the queue to be merged to obtain kth transaction execution cache data; k is a positive integer less than or equal to H; h is the total number of transactions corresponding to the transactions in the second block;
Performing conflict detection on the cached data of the kth transaction to obtain a data conflict detection result;
if the conflict detection result corresponding to the k transaction execution cache data is a data conflict result, carrying out conflict combination updating on the k transaction execution cache data to obtain k combination updating cache data;
if the conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result, the kth transaction execution cache data is used as the kth merging and updating cache data;
and H merging and updating the cache data to serve as the block cache data of the second block.
9. The method of claim 8, wherein the kth transaction execution cache data comprises transaction execution read cache data;
performing collision detection on the buffered data of the kth transaction to obtain a data collision detection result, including:
acquiring latest transaction execution read cache data of a transaction corresponding to the kth transaction execution cache data;
if the latest transaction execution read cache data is the same as the transaction execution read cache data, determining that a conflict detection result corresponding to the kth transaction execution cache data is a data non-conflict result;
And if the latest transaction execution read cache data is different from the transaction execution read cache data, determining that the conflict detection result corresponding to the kth transaction execution cache data is a data conflict result.
10. The method of claim 9, wherein the kth transaction execution cache data further comprises transaction execution write cache data;
and performing conflict merging and updating on the k transaction execution cache data to obtain k merging and updating cache data, wherein the method comprises the following steps of:
executing the transaction corresponding to the kth transaction execution cache data according to the latest transaction execution read cache data to obtain latest transaction write cache data;
updating the transaction execution read cache data in the kth transaction execution cache data into the latest transaction execution read cache data, and updating the transaction execution write cache data in the kth transaction execution cache data into the latest transaction write cache data;
and taking the updated k transaction execution cache data as k merging and updating cache data.
11. The method of claim 9, wherein the obtaining the latest transaction execution read cache data of the transaction corresponding to the kth transaction execution cache data comprises:
Searching whether read cache data of a transaction corresponding to the kth transaction execution cache data exists in the updated cache data; the updated cache data comprises block cache data in the storage queue and k-1 updated transaction cache data related to the second block, which respectively correspond to the merged updated cache data; the k-1 updated transaction cache data are transaction execution cache data before the kth transaction execution cache data at the position or the adding time in the queue to be merged;
if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the updated cache data, the read cache data of the transaction corresponding to the kth transaction execution cache data in the updated cache data is used as the latest transaction execution read cache data;
if the read cache data of the transaction corresponding to the k transaction execution cache data is not found in the updated cache data, searching whether the read cache data of the transaction corresponding to the k transaction execution cache data exists in a blockchain account book;
if the read cache data of the transaction corresponding to the kth transaction execution cache data is found in the blockchain account book, the read cache data of the transaction corresponding to the kth transaction execution cache data in the blockchain account book is used as the latest transaction execution read cache data;
And if the read cache data of the transaction corresponding to the kth transaction execution cache data is not found in the blockchain account book, taking the default blank data as the latest transaction execution read cache data.
12. A blockchain-based data processing device, comprising:
the parallel consensus module is used for acquiring a second block in the process of performing the consensus processing of the first block through the consensus pool, and performing the consensus processing of the second block through the consensus pool; the first block is a parent block of the second block; the consensus process of the first block and the consensus process of the second block are performed in parallel;
the parallel execution module is used for adding the transaction in the second block into a transaction execution pool according to a transaction data sequence number in the process of carrying out consensus processing on the second block, executing the transaction in the transaction execution pool in parallel to obtain transaction execution cache data corresponding to the transaction in the transaction execution pool, and adding the transaction execution cache data corresponding to the transaction in the transaction execution pool into a queue to be merged;
the conflict combining module is configured to, if the result of the consensus processing of the second block is a consensus passing result, and the to-be-combined queue includes transaction execution cache data corresponding to each transaction in the second block, respectively, and there is block cache data of the first block, conflict-combine the transaction execution cache data related to the second block in the to-be-combined queue to obtain block cache data of the second block, and add the block cache data of the second block to the storage queue; the block cache data in the store queue is for being written sequentially into a blockchain ledger.
13. A computer device, comprising: a processor, a memory, and a network interface;
the processor is connected to the memory, the network interface for providing data communication functions, the memory for storing program code, the processor for invoking the program code to perform the method of any of claims 1-11.
14. A computer readable storage medium, characterized in that the computer readable storage medium has stored therein a computer program adapted to be loaded by a processor and to perform the method of any of claims 1-11.
15. A computer program product comprising computer programs/instructions which, when executed by a processor, are adapted to carry out the method of any one of claims 1-11.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310110568.8A CN116977067A (en) | 2023-01-31 | 2023-01-31 | Block chain-based data processing method, device, equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202310110568.8A CN116977067A (en) | 2023-01-31 | 2023-01-31 | Block chain-based data processing method, device, equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN116977067A true CN116977067A (en) | 2023-10-31 |
Family
ID=88477286
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202310110568.8A Pending CN116977067A (en) | 2023-01-31 | 2023-01-31 | Block chain-based data processing method, device, equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN116977067A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117527832A (en) * | 2024-01-03 | 2024-02-06 | 杭州趣链科技有限公司 | Transaction ordering method and device for blockchain, electronic equipment and storage medium |
-
2023
- 2023-01-31 CN CN202310110568.8A patent/CN116977067A/en active Pending
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN117527832A (en) * | 2024-01-03 | 2024-02-06 | 杭州趣链科技有限公司 | Transaction ordering method and device for blockchain, electronic equipment and storage medium |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN113329031B (en) | Method and device for generating state tree of block | |
US20240348442A1 (en) | Maintaining blocks of a blockchain in a partitioned blockchain network | |
CN113570466B (en) | Transaction data processing method and device and readable storage medium | |
EP3353671A1 (en) | Distributed data processing method and system | |
WO2019199768A1 (en) | Fork-tolerant consensus protocol | |
CN110413650B (en) | Method, device, equipment and storage medium for processing service data | |
CN113568981B (en) | Transaction data processing method, device, equipment and medium | |
JP5801482B2 (en) | Method and system for storing and retrieving data from key-value storage | |
CN113409047B (en) | Data processing method, device and equipment based on block chain and readable storage medium | |
CN113326165B (en) | Data processing method and device based on block chain and computer readable storage medium | |
CN111899019A (en) | Method and system for cross validation and sharing of blacklist and multiple parties | |
CN112767151A (en) | Transaction processing method and device applied to verification node in block chain | |
CN116977067A (en) | Block chain-based data processing method, device, equipment and readable storage medium | |
CN113610527A (en) | Alliance chain transaction method, device, system, terminal device and storage medium | |
US20230353393A1 (en) | Blockchain-based methods and apparatuses for processing data, devices and readable storage mediums | |
WO2023142605A1 (en) | Blockchain-based data processing method and related apparatus | |
US11568399B2 (en) | Distributed ledger management system, distributed ledger management method, and node | |
CN117376366A (en) | Block chain transaction processing method, device, medium and electronic equipment | |
CN116701452A (en) | Data processing method, related device, storage medium and program product | |
CN116016374A (en) | Block chain-based data processing method, device, equipment and readable storage medium | |
US20240205032A1 (en) | Blockchain data processing method, apparatus, and device, computer-readable storage medium, and computer program product | |
CN110889040B (en) | Method and device for pushing information | |
CN117390117A (en) | Block chain-based data processing method, device, equipment and readable storage medium | |
CN117421369A (en) | Block chain-based data processing method, device, equipment and readable storage medium | |
CN118535568A (en) | Block chain-based data processing method, device, equipment and readable storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication |