WO2023160088A1 - Method for processing blockchain transactions, and blockchain node and electronic device - Google Patents

Method for processing blockchain transactions, and blockchain node and electronic device Download PDF

Info

Publication number
WO2023160088A1
WO2023160088A1 PCT/CN2022/135434 CN2022135434W WO2023160088A1 WO 2023160088 A1 WO2023160088 A1 WO 2023160088A1 CN 2022135434 W CN2022135434 W CN 2022135434W WO 2023160088 A1 WO2023160088 A1 WO 2023160088A1
Authority
WO
WIPO (PCT)
Prior art keywords
transactions
batch
batches
transaction
consensus
Prior art date
Application number
PCT/CN2022/135434
Other languages
French (fr)
Chinese (zh)
Inventor
李帅
Original Assignee
蚂蚁区块链科技(上海)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 蚂蚁区块链科技(上海)有限公司 filed Critical 蚂蚁区块链科技(上海)有限公司
Publication of WO2023160088A1 publication Critical patent/WO2023160088A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q40/00Finance; Insurance; Tax strategies; Processing of corporate or income taxes
    • G06Q40/04Trading; Exchange, e.g. stocks, commodities, derivatives or currency exchange
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0631Resource planning, allocation, distributing or scheduling for enterprises or organisations
    • G06Q10/06311Scheduling, planning or task assignment for a person or group
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/06Resources, workflows, human or project management; Enterprise or organisation planning; Enterprise or organisation modelling
    • G06Q10/063Operations research, analysis or management
    • G06Q10/0633Workflow analysis
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06QINFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
    • G06Q10/00Administration; Management
    • G06Q10/10Office automation; Time management
    • G06Q10/103Workflow collaboration or project management

Definitions

  • This document relates to the field of blockchain technology, and in particular to a processing method for blockchain transactions, blockchain nodes and electronic equipment.
  • the processing flow of the blockchain for a round of views mainly includes four stages: transaction collection, transaction consensus, transaction execution, and block writing. In the prior art, these four stages are executed serially, resulting in relatively low processing efficiency of blockchain transactions. In addition, every time a round of views is completed, a block write operation needs to be performed, and excessive block write operations will also have a negative impact on the processing efficiency of blockchain transactions.
  • the purpose of the embodiments of this specification is to provide a processing method of blockchain transactions, blockchain nodes and electronic equipment, which can improve the processing efficiency of blockchain transactions.
  • a method for processing blockchain transactions including:
  • a method for processing blockchain transactions including:
  • a blockchain node including:
  • the first transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
  • the first transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the first transaction collection module simultaneously executes the second batch of transactions in batch order in parallel A collection operation, wherein the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
  • the first transaction execution module performs transaction execution operations on the first batch of transactions. If there is a third batch of transactions, the first transaction consensus module simultaneously executes the consensus on the third batch of transactions in parallel. Operation, wherein the third batch of transactions is a batch of transactions for which the target transaction set has been collected and consensus has not yet been completed;
  • the first transaction confirmation module sends the transaction execution results of the first batch of transactions in the blockchain to confirm the first batch of transactions
  • the first transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  • an electronic device comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
  • a computer-readable storage medium is provided.
  • a computer program is stored on the computer-readable storage medium.
  • the computer program is executed by a processor, the following steps are implemented:
  • a blockchain node including:
  • the second transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
  • the second transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the second transaction consensus module simultaneously executes the collection operation of the second batch of transactions in batch order in parallel , wherein, the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
  • the second transaction execution module if all batches of transactions in the target transaction set have reached a consensus, perform a transaction execution operation on all batches of transactions in the target set;
  • the second transaction confirmation module sends the transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set
  • the second transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  • an electronic device comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
  • a computer-readable storage medium is provided.
  • a computer program is stored on the computer-readable storage medium.
  • the computer program is executed by a processor, the following steps are implemented:
  • the blockchain nodes perform transaction collection, transaction consensus, transaction execution, and transaction confirmation in batches for the target transaction set with a large amount of data.
  • the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner.
  • a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes.
  • the whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
  • Fig. 1 is a schematic flow chart of the first method for processing blockchain transactions provided by the embodiment of this specification.
  • Fig. 2 is a schematic diagram of the first time slot of the blockchain transaction processing method provided by the embodiment of this specification.
  • FIG. 3 is a schematic diagram of the second time slot of the blockchain transaction processing method provided by the embodiment of this specification.
  • Fig. 4 is a second schematic flowchart of the processing method of a blockchain transaction provided by the embodiment of this specification.
  • Fig. 5 is a schematic diagram of the third time slot of the blockchain transaction processing method provided by the embodiment of this specification.
  • Fig. 6 is a schematic structural diagram of the first type of blockchain node provided by the embodiment of this specification.
  • Fig. 7 is a schematic structural diagram of the second type of blockchain node provided by the embodiment of this specification.
  • FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of this specification.
  • the current block chain completes the four operations of transaction collection, consensus, execution and block writing in a serial manner, which leads to relatively low processing efficiency of block chain transactions and limits the use of block chains. throughput.
  • a block write operation needs to be performed, and excessive block write operations will also have a negative impact on the processing efficiency of blockchain transactions.
  • the business volume will also show explosive growth.
  • the current transaction processing method is difficult to apply to scenarios with high business concurrency in the future. In response to this problem, this document aims to provide a technical solution that can improve the efficiency of blockchain transaction processing.
  • Fig. 1 is a flow chart of a processing method of a blockchain transaction according to an embodiment of this specification. The method shown in Figure 1 can be executed by the corresponding blockchain nodes below, including the following steps:
  • S102 Collect the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the blockchain.
  • each blockchain node of the blockchain can divide all transactions of the target transaction set into batches in an orderly manner according to the corresponding transaction initiation time based on the smart contract set in advance . Or, according to the order of transactions in the consensus proposal, all transactions of the target transaction set are divided into batches.
  • S104 perform a consensus operation on the first batch of transactions, and if there is a second batch of transactions, perform a collection operation on the second batch of transactions in parallel in batch order, the second batch of transactions is the target transaction set that has not yet been collected Batch transactions.
  • batch transactions that have not been collected in this step may include batch transactions that have not yet started collection, or batch transactions that have started collection but have not yet completed collection.
  • the batch order is the batch division order described in S102 above.
  • the blockchain nodes collect the transactions of the target transaction set in batches. After the target batch of transactions is collected, it can be executed at the same time: the consensus execution operation of the target batch of transactions and the collection operation of the next batch of transactions corresponding to the target batch of transactions. That is to say, the second batch of transactions mentioned in this step refers to the next batch of transactions of the first batch of transactions.
  • S106 perform transaction execution operations on the first batch of transactions, and if there is a consensus operation on the third batch of transactions in parallel execution of the third batch of transactions, the third batch of transactions is that the target transaction set has been collected and Batch transactions that have not yet completed consensus.
  • batches of transactions whose consensus has not been completed in this step may include batches of transactions that have not yet started consensus, or batches of transactions that have started consensus but have not yet completed consensus.
  • the blockchain nodes perform consensus operations on the transactions of the target transaction set in batches. After the consensus operation of the target batch of transactions is completed, it can be executed simultaneously: the execution operation of the target batch of transactions and the consensus operation of the next batch of transactions corresponding to the target batch of transactions. That is to say, the third batch of transactions mentioned in this step refers to the next batch of transactions of the second batch of transactions.
  • the collection operation of the second batch of transactions in batch order can also be executed in parallel.
  • the block chain node as the execution subject of this step can send the transaction confirmation request of the transaction execution result of the first batch of transactions to other block chain nodes in the block chain; if 2f other block chain nodes are received later If the transaction confirmation feedback is sent, the transaction confirmation of the first batch of transactions is confirmed.
  • f is the maximum number of abnormal consensus nodes allowed by the blockchain.
  • the blockchain nodes perform consensus operations on the transactions of the target transaction set in batches, but in the end, only one block writing operation may be performed. That is to say, in the embodiment of this specification, all batches of transactions in the target transaction set can be recorded in one block.
  • the block chain node executes transaction collection, transaction consensus, transaction execution and transaction confirmation in batches for the target transaction set with a large amount of data.
  • the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner.
  • a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes. The whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
  • the transaction execution results of the first batch of transactions can also be fed back to the corresponding blockchain client. That is to say, in the method of the embodiment of this specification, the block chain node can immediately feed back the transaction execution to the block chain client after each batch of transactions completes the transaction execution and gets the transaction confirmation, thereby significantly reducing the transaction time.
  • the transaction confirmation delay on the client side of the block chain improves the user experience.
  • the transaction execution results of all batches of transactions in the target transaction set can be uniformly fed back to The corresponding blockchain client.
  • the feedback strategy for transaction execution results can be determined according to the transaction quantity in the target transaction set. For example, when the number of transactions in the target transaction set exceeds the preset threshold, you can choose to immediately feed back the transaction execution results to the blockchain client after each batch of transactions is executed and confirmed. Similarly, when the number of transactions in the target transaction set does not exceed the preset threshold, you can choose to transfer all batches of transactions in the target transaction set to The transaction execution results are uniformly fed back to the corresponding blockchain client.
  • the method in the embodiment of this specification can process blockchain transactions in batches at the granularity of each round of blockchain views.
  • the target transaction set in the embodiment of this specification is all transactions in the Nth round view of the blockchain.
  • the method of the embodiment of this specification can set the first thread, the second thread, the third thread, the fourth thread and the fifth thread to be executed in parallel, so as to respectively execute the collection, consensus, and transaction of blockchain transactions.
  • These five operations are execution, transaction confirmation, and block writing.
  • the first thread is used to collect transactions in batches, that is, the first thread does not collect other batches of transactions before collecting a batch of transactions;
  • the second thread is used to perform consensus operations on transactions in batches, that is, the first thread The second thread does not execute the consensus operations of other batches of transactions before executing the consensus operation of a batch of transactions;
  • the third thread is used to execute the execution operations of transactions in batches, that is, before executing the execution operations of a batch of transactions The execution operations of other batches of transactions are not executed.
  • the fourth thread performs transaction confirmation in batches, that is, the transaction confirmation of other batches of transactions is not performed before the transaction confirmation of one batch of transactions is completed.
  • the fifth thread executes block writing operations uniformly after all batches of transactions in each round of views are confirmed.
  • the views of round N and round N+1 are divided into three batches of transactions as an example.
  • the views of round N and round N+1 can present the time slots shown in Figure 2 relation.
  • the transactions of each round of views are divided into multiple small batches, which can reduce the time-consuming execution of each batch of transactions, that is, reduce the length of T in Figure 2, thereby improving the block The processing efficiency of chain transactions.
  • first thread, second thread, third thread, fourth thread and fifth thread may belong to different cores of the processor. That is to say, the embodiment of this description can perform the transaction collection operation, consensus operation, and execution operation on the same round of views in a multi-core and multi-thread parallel manner.
  • the operation of feeding back the transaction execution result to the client can be executed immediately after the transaction is executed, one thread can be used to execute the transaction execution operation and the feedback operation of the transaction execution result. That is, the fourth thread mentioned above is the third thread mentioned above, and the views of round N and round N+1 of the blockchain can present the time slot relationship shown in Figure 3 .
  • the method in the embodiment of this specification can also perform the execution operation and block writing operation on all batches of transactions in the N-th round of views in a unified manner after all batches of transactions in the N-th round of views have completed consensus. That is, the processing method of the blockchain transaction in the embodiment of this specification can also be shown in Figure 4, including the following steps:
  • S402. Collect the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the blockchain.
  • S404 perform a consensus operation on the first batch of transactions, and perform a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, the second batch of transactions is the target transaction set that has not yet been collected Batch transactions.
  • S408 sending transaction execution results of all batches of transactions in the target transaction set in the blockchain to perform transaction confirmation on all batches of transactions in the target transaction set.
  • FIG. 5 is a time slot relationship diagram for the Nth round and the N+1th round of views based on the method shown in FIG. 4 . It should be understood that the execution operations of all batches of transactions in the N-th round view can be performed at least after the execution operations of all batches of transactions in the N-1 round view are completed.
  • the method shown in Figure 4 uses the first thread to collect transactions in batch order for each round of views, that is, the first thread does not collect other batches of transactions before collecting a batch of transactions;
  • the view executes the consensus operations of transactions in batch order, that is, the second thread does not execute the consensus operations of other batches of transactions before executing the consensus operations of one batch of transactions; through the third thread, all batches in each round of view
  • the transactions are executed in a unified manner; through the fourth thread, all batches of transactions in each round of views are uniformly confirmed; through the fifth thread, all batches of transactions in each round of views are uniformly written into blocks.
  • the first thread, the second thread, the third thread, the fourth thread, and the fifth thread are threads executed in parallel.
  • the method shown in FIG. 4 can also perform transaction collection and transaction consensus on the target transaction set in batches.
  • the consensus operation is performed on the intermediate batch of transactions
  • the collection operation of the next batch of transactions is also performed, so that the processing time of blockchain transactions can also be shortened in parallel.
  • a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes.
  • the whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
  • the methods in the embodiments of this specification are not limited to taking each round view of the blockchain as the execution granularity. However, when the block chain accumulates to a transaction set that cannot be completed on the chain through a consensus, the method of the embodiment of this specification can be used to realize the data on-chain that only initiates a block writing operation once.
  • FIG. 6 is a schematic structural diagram of a blockchain node 600 according to an embodiment of this specification, including:
  • the first transaction collection module 610 collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions agreed upon by the block chain at one time .
  • the first transaction consensus module 620 performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, executes the collection operation of the second batch of transactions in batch order in parallel, wherein the The second batch of transactions is a batch of transactions for which the target transaction set has not yet been collected.
  • the first transaction execution module 630 performs transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, executes a consensus operation on the third batch of transactions in batch order, wherein the The third batch of transactions is a batch of transactions for which the target transaction set has been collected and consensus has not yet been completed.
  • the first transaction confirmation module 640 sends the transaction execution result of the first batch of transactions in the block chain to perform transaction confirmation on the first batch of transactions.
  • the first transaction block writing module 650 executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  • the block chain node in the embodiment of this specification executes transaction collection, transaction consensus, transaction execution, and transaction confirmation in batches for a target transaction set with a large amount of data.
  • the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner.
  • a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes.
  • the whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
  • the first transaction execution module 630 simultaneously executes the second batch of transactions in batch order The collection operation for the transaction.
  • the target transaction set is all transactions in the Nth round view of the blockchain, where N is a positive integer.
  • the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
  • the first transaction collection module 610 executes the collection operation of the second batch of transactions in parallel in batch order.
  • the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
  • the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
  • the first transaction collection module 610 executes the N+1th round of views in batch order Consensus operations for batches of transactions that have been collected but have not yet completed consensus in .
  • the first transaction confirmation module 640 sends a transaction confirmation request of the transaction execution result of the first batch of transactions to other blockchain nodes of the blockchain. Afterwards, if the transaction confirmation feedback sent by 2f other blockchain nodes is received, it is confirmed that the transaction confirmation of the first batch of transactions is obtained, and f is the maximum number of abnormal consensus nodes allowed by the blockchain.
  • the blockchain node shown in Figure 6 of the embodiment of this specification also includes:
  • the first transaction feedback module after obtaining the transaction confirmation of the first batch of transactions, feeds back the transaction execution results of the first batch of transactions to the corresponding block chain client; or, after obtaining the Nth After the transactions of all batches of transactions in the round view are confirmed, the transaction execution results of all batches of transactions in the Nth round view are fed back to the corresponding blockchain client.
  • the first transaction collection module 610 collects all batches of transactions in the Nth round of views through a first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions.
  • the first transaction consensus module 620 executes consensus operations on all batches of transactions in the Nth round of views through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of one batch of transactions Consensus operation.
  • the first transaction execution module 630 executes execution operations on all batches of transactions in the Nth round view through a third thread, and the third thread does not execute other batches of transactions before executing the execution operation of one batch of transactions.
  • the execution operation; the first transaction confirmation module 640 executes the transaction confirmation of all batches of transactions in the Nth round view through the fourth thread.
  • the first transaction block writing module 650 executes block writing operations on all batches of transactions in the Nth round of views through the fifth thread. Wherein, the first thread, the second thread, the third thread, the fourth thread and the fifth thread are threads executed in parallel.
  • the second thread after the first thread collects the first batch of transactions, notify the second thread to perform a consensus operation on the first batch of transactions; After the consensus operation of a batch of transactions, notify the third thread to perform operations on the first batch of transactions; after the third thread executes the execution operations of the first batch of transactions, notify the The fourth thread performs transaction confirmation on the first batch of transactions.
  • the block chain node shown in FIG. 6 can be used as the execution subject of the processing method shown in FIG. 1 above, so it can realize the functions realized by the processing method in FIG. 1 to FIG. 3 . Since the principle is the same, this article will not repeat them.
  • FIG. 7 is a schematic structural diagram of a block chain node 700 according to an embodiment of this specification, including:
  • the second transaction collection module 710 collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the transaction number of the block chain consensus at one time .
  • the second transaction consensus module 720 performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, executes the collection operation of the second batch of transactions in batch order in parallel, wherein the The second batch of transactions is a batch of transactions for which the target transaction set has not yet been collected.
  • the second transaction execution module 730 if all batches of transactions in the target transaction set have completed the consensus, perform a transaction execution operation on all batches of transactions in the target set.
  • the second transaction confirmation module 740 sends the transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set
  • the second transaction block writing module 750 executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  • the second transaction collection module 710 simultaneously executes the second batch of transactions in batch order The collection operation for the transaction.
  • the target transaction set is all transactions in the Nth round view of the blockchain, where N is a positive integer.
  • the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
  • the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
  • the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
  • the second transaction collection module 710 executes the Nth round of transactions in batch order +1 Consensus operations for batches of transactions that have been collected but not yet completed consensus in a consensus round.
  • the second transaction confirmation module 740 sends a transaction confirmation request of the transaction execution result of the first batch of transactions to other blockchain nodes of the blockchain. Afterwards, if the transaction confirmation feedback sent by 2f other blockchain nodes is received, it is confirmed that the transaction confirmation of the first batch of transactions is obtained, and f is the maximum number of abnormal consensus nodes allowed by the blockchain.
  • the blockchain node shown in Figure 7 of the embodiment of this specification also includes:
  • the second transaction feedback module after obtaining the transaction confirmation of all batches of transactions in the Nth round of consensus, feeds back the transaction execution results of all batches of transactions in the Nth round of consensus to the corresponding block chain client.
  • the second transaction collection module 710 collects all batches of transactions in the N-th round of consensus through a first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions.
  • the second transaction consensus module 720 executes consensus operations on all batches of transactions in the N-th round of consensus through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of one batch of transactions Consensus operation.
  • the second transaction execution module 730 executes the execution operation on all batches of transactions in the N-round consensus through the third thread; the second transaction confirmation module 740 executes all batches in the N-round consensus through the fourth thread A transaction confirmation for a transaction.
  • the second transaction block writing module 750 executes block writing operations on all batches of transactions in the N-th round of consensus through the fifth thread. Wherein, the first thread, the second thread, the third thread, the fourth thread and the fifth thread are threads executed in parallel.
  • the second thread is notified to perform a consensus operation on the first batch of transactions.
  • block chain node node shown in FIG. 7 can be used as the execution body of the processing method shown in FIG. 4 above, so it can realize the functions realized by the processing method in FIG. 4 and FIG. 5 . Since the principle is the same, this article will not repeat them.
  • Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
  • the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory.
  • the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM random-Access Memory
  • non-volatile memory such as at least one disk memory.
  • the electronic device may also include hardware required by other services.
  • the processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc.
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 8 , but it does not mean that there is only one bus or one type of bus.
  • Memory for storing programs.
  • the program may include program code, and the program code includes computer operation instructions.
  • Storage which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to form a processing device for blockchain transactions on a logical level, which can be used as the block shown in Figure 6 A chain node or a component in a blockchain node.
  • the processor executes the program stored in the memory, and is specifically used to perform the following operations:
  • the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to form a processing device for blockchain transactions on a logical level, which can be used as the block shown in Figure 7 A chain node or a component in a blockchain node.
  • the processor executes the program stored in the memory, and is specifically used to perform the following operations:
  • the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
  • a processor may be an integrated circuit chip with signal processing capabilities.
  • each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the method disclosed in the embodiments of this specification may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the electronic equipment in this specification does not exclude other implementations, such as logic devices or the combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, It can also be a hardware or logic device.
  • the embodiment of this specification also proposes a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions.
  • the portable electronic device can execute the method of the embodiment shown in FIG. 1 , and is specifically used to perform the following methods:
  • the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
  • the above instructions when executed by a portable electronic device including multiple application programs, can cause the portable electronic device to execute the method of the embodiment shown in FIG. 4 , and are specifically used to execute the following methods:
  • the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
  • the block chain node shown in FIG. 6 can realize the functions of the embodiments shown in FIG. 1 to FIG.
  • the block chain node shown realizes the functions of the embodiments shown in Fig. 4 and Fig. 5 . Since the principle is the same, this article will not repeat them.

Landscapes

  • Business, Economics & Management (AREA)
  • Human Resources & Organizations (AREA)
  • Engineering & Computer Science (AREA)
  • Strategic Management (AREA)
  • Entrepreneurship & Innovation (AREA)
  • Economics (AREA)
  • General Physics & Mathematics (AREA)
  • Marketing (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Business, Economics & Management (AREA)
  • Operations Research (AREA)
  • Development Economics (AREA)
  • Quality & Reliability (AREA)
  • Tourism & Hospitality (AREA)
  • Finance (AREA)
  • Educational Administration (AREA)
  • Accounting & Taxation (AREA)
  • Game Theory and Decision Science (AREA)
  • Technology Law (AREA)
  • Data Mining & Analysis (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)
  • Retry When Errors Occur (AREA)

Abstract

Provided in the embodiments of the present description are a method for processing blockchain transactions, and a blockchain node and an electronic device. The method comprises: collecting a first batch of transactions from a target transaction set of a blockchain, wherein the target transaction set comprises a plurality of batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions on which a consensus operation can be performed by the blockchain in one step; if there is a second batch of transactions when the first batch of transactions is collected, executing, in parallel, a consensus operation on the second batch of transactions, wherein the second batch of transactions is a set of transactions from the target transaction set which have been collected and have not been subjected to a consensus operation; if there is a third batch of transactions when the first batch of transactions is collected, executing, in parallel, an execution operation on the third batch of transactions, wherein the third batch of transactions is a set of transactions from the target transaction set which have been subjected to a consensus operation and have not been executed; and after transaction confirmation of all batches of transactions in the target transaction set is obtained, performing an instance of a block writing operation on all batches of transactions in the target transaction set.

Description

一种区块链交易的处理方法、区块链节点及电子设备A processing method of block chain transaction, block chain node and electronic equipment
本申请要求于2022年02月24日提交中国专利局、申请号为202210178479.2、发明名称为“一种区块链交易的处理方法、区块链节点及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the China Patent Office on February 24, 2022, with the application number 202210178479.2, and the title of the invention is "a method for processing blockchain transactions, blockchain nodes and electronic equipment", The entire contents of which are incorporated by reference in this application.
技术领域technical field
本文件涉及区块链技术领域,尤其涉及一种区块链交易的处理方法、区块链节点及电子设备。This document relates to the field of blockchain technology, and in particular to a processing method for blockchain transactions, blockchain nodes and electronic equipment.
背景技术Background technique
区块链由于具有开放性、不可篡改、去中心化等优点,越来越受到各行各业的青睐。目前区块链针对一轮视图的处理流程主要包括:交易收集、交易共识、交易执行以及写块四个阶段。现有技术中,这四个阶段是以串行方式执行的,导致区块链交易的处理效率相对较低。此外,每完成一轮视图就需要执行一次写块操作,过多的写块操作也会对区块链交易的处理效率造成负面影响。Due to its advantages of openness, non-tamperability, and decentralization, blockchain is increasingly favored by all walks of life. At present, the processing flow of the blockchain for a round of views mainly includes four stages: transaction collection, transaction consensus, transaction execution, and block writing. In the prior art, these four stages are executed serially, resulting in relatively low processing efficiency of blockchain transactions. In addition, every time a round of views is completed, a block write operation needs to be performed, and excessive block write operations will also have a negative impact on the processing efficiency of blockchain transactions.
在未来阶段,区块链业务会呈爆发性增长,为了满足业务高并发的场景需求,有必要提出一种能够提高区块链交易处理效率的技术方案。In the future stage, the blockchain business will show explosive growth. In order to meet the needs of high-concurrency business scenarios, it is necessary to propose a technical solution that can improve the efficiency of blockchain transaction processing.
发明内容Contents of the invention
本说明书实施例目的是提供一种区块链交易的处理方法、区块链节点及电子设备,能够提高区块链交易的处理效率。The purpose of the embodiments of this specification is to provide a processing method of blockchain transactions, blockchain nodes and electronic equipment, which can improve the processing efficiency of blockchain transactions.
为了实现上述目的,本说明书实施例是这样实现的:In order to achieve the above purpose, the embodiment of this description is achieved as follows:
第一方面,提供一种区块链交易的处理方法,包括:In the first aspect, a method for processing blockchain transactions is provided, including:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
第二方面,提供一种区块链交易的处理方法,包括:In the second aspect, a method for processing blockchain transactions is provided, including:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行 操作;If all batches of transactions in the target transaction set have completed consensus, perform transaction execution operations on all batches of transactions in the target set;
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
第三方面,提供一种区块链节点,包括:In the third aspect, a blockchain node is provided, including:
第一交易收集模块,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;The first transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
第一交易共识模块,对所述第一批次交易执行共识操作,如果存在第二批次交易,则所述第一交易收集模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;The first transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the first transaction collection module simultaneously executes the second batch of transactions in batch order in parallel A collection operation, wherein the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
第一交易执行模块,对所述第一批次交易进行交易执行操作,如果存在第三批次交易,则第一交易共识模块同时并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;The first transaction execution module performs transaction execution operations on the first batch of transactions. If there is a third batch of transactions, the first transaction consensus module simultaneously executes the consensus on the third batch of transactions in parallel. Operation, wherein the third batch of transactions is a batch of transactions for which the target transaction set has been collected and consensus has not yet been completed;
第一交易确认模块,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;The first transaction confirmation module sends the transaction execution results of the first batch of transactions in the blockchain to confirm the first batch of transactions;
第一交易写块模块,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The first transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
第四方面,提供一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:In a fourth aspect, there is provided an electronic device comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
第五方面,提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:In a fifth aspect, a computer-readable storage medium is provided. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
第六方面,提供一种区块链节点,包括:In the sixth aspect, a blockchain node is provided, including:
第二交易收集模块,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;The second transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
第二交易共识模块,对所述第一批次交易执行共识操作,如果存在第二批次交易,则第二交易共识模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;The second transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the second transaction consensus module simultaneously executes the collection operation of the second batch of transactions in batch order in parallel , wherein, the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
第二交易执行模块,如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;The second transaction execution module, if all batches of transactions in the target transaction set have reached a consensus, perform a transaction execution operation on all batches of transactions in the target set;
第二交易确认模块,在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认The second transaction confirmation module sends the transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set
第二交易写块模块,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The second transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
第七方面,提供一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:In a seventh aspect, there is provided an electronic device comprising: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;If all batches of transactions in the target transaction set have completed consensus, perform a transaction execution operation on all batches of transactions in the target set;
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
第八方面,提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:In an eighth aspect, a computer-readable storage medium is provided. A computer program is stored on the computer-readable storage medium. When the computer program is executed by a processor, the following steps are implemented:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;If all batches of transactions in the target transaction set have completed consensus, perform a transaction execution operation on all batches of transactions in the target set;
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
基于本说明书实施例的方案,区块链节点对大数据量的目标交易集分批次执行交易收集、交易共识、交易执行以及交易确认。特别是在中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间。此外,在目标交易集中的所有批次交易完成交易确认后,再统一执行一次写块操作,从而通过降低写块次数的方式提高区块链交易的处理效率。整个方案能够显著提高区块链的吞吐量,可满足业务高并发场景的需求。Based on the solutions in the embodiments of this specification, the blockchain nodes perform transaction collection, transaction consensus, transaction execution, and transaction confirmation in batches for the target transaction set with a large amount of data. In particular, while the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner. In addition, after all batches of transactions in the target transaction set are confirmed, a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes. The whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
附图说明Description of drawings
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments described in the embodiments of this specification. For those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1为本说明书实施例提供的区块链交易的处理方法的第一种流程示意图。Fig. 1 is a schematic flow chart of the first method for processing blockchain transactions provided by the embodiment of this specification.
图2为本说明书实施例提供的区块链交易的处理方法的第一种时隙示意图。Fig. 2 is a schematic diagram of the first time slot of the blockchain transaction processing method provided by the embodiment of this specification.
图3为本说明书实施例提供的区块链交易的处理方法的第二种时隙示意图。FIG. 3 is a schematic diagram of the second time slot of the blockchain transaction processing method provided by the embodiment of this specification.
图4为本说明书实施例提供的区块链交易的处理方法的第二种流程示意图。Fig. 4 is a second schematic flowchart of the processing method of a blockchain transaction provided by the embodiment of this specification.
图5为本说明书实施例提供的区块链交易的处理方法的第三种时隙示意图。Fig. 5 is a schematic diagram of the third time slot of the blockchain transaction processing method provided by the embodiment of this specification.
图6为本说明书实施例提供的第一种区块链节点的结构示意图。Fig. 6 is a schematic structural diagram of the first type of blockchain node provided by the embodiment of this specification.
图7为本说明书实施例提供的第二种区块链节点的结构示意图。Fig. 7 is a schematic structural diagram of the second type of blockchain node provided by the embodiment of this specification.
图8为本说明书实施例提供的电子设备的结构示意图。FIG. 8 is a schematic structural diagram of an electronic device provided by an embodiment of this specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments in this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.
如前所述,目前区块链是以串行方式完成交易的收集、共识、执行和写块这四个操作的,这导致区块链交易的处理效率相对较低,限制了区块链的吞吐量。此外,每完成一轮视图就需要执行一次写块操作,过多的写块操作也会对区块链交易的处理效率造成负面影响。随着区块链越来越受到各行各业的青睐,业务量也会呈爆发性增长。显然,目前的这种交易处理方式难以再适用于以后业务高并发的场景中。针对这一问题,本文件旨在提供一种能够提高区块链交易处理效率的技术方案。As mentioned earlier, the current block chain completes the four operations of transaction collection, consensus, execution and block writing in a serial manner, which leads to relatively low processing efficiency of block chain transactions and limits the use of block chains. throughput. In addition, every time a round of views is completed, a block write operation needs to be performed, and excessive block write operations will also have a negative impact on the processing efficiency of blockchain transactions. As the blockchain becomes more and more popular in all walks of life, the business volume will also show explosive growth. Obviously, the current transaction processing method is difficult to apply to scenarios with high business concurrency in the future. In response to this problem, this document aims to provide a technical solution that can improve the efficiency of blockchain transaction processing.
图1是本说明书实施例区块链交易的处理方法的流程图。图1所示的方法可以由下文相对应的区块链节点执行,包括如下步骤:Fig. 1 is a flow chart of a processing method of a blockchain transaction according to an embodiment of this specification. The method shown in Figure 1 can be executed by the corresponding blockchain nodes below, including the following steps:
S102,收集区块链的目标交易集合中的第一批次交易,目标交易集中包括多个批次交易,且交易数量超出区块链一次共识的交易数量上限。S102. Collect the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the blockchain.
需要说明的是,本文不对目标交易集合的交易批次划分逻辑作具体限定。但凡是将目标交易集合中的交易划分成多个批次的方案都应属于本说明书实施例的保护范围。It should be noted that this article does not specifically limit the transaction batch division logic of the target transaction set. However, any scheme that divides the transactions in the target transaction set into multiple batches shall fall within the scope of protection of the embodiments of this specification.
作为示例性介绍:本说明书实施例中,区块链的各区块链节点可以基于提前设定好的智能合约,统一将目标交易集合的所有交易按照对应的交易发起时间进行有序的批次划分。或者,按照交易在共识提议中的顺序,对目标交易集合的所有交易进行批次划分。As an exemplary introduction: In the embodiment of this specification, each blockchain node of the blockchain can divide all transactions of the target transaction set into batches in an orderly manner according to the corresponding transaction initiation time based on the smart contract set in advance . Or, according to the order of transactions in the consensus proposal, all transactions of the target transaction set are divided into batches.
S104,对第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对第二批次交易的收集操作,第二批次交易为目标交易集合尚未完成收集的批次交易。S104, perform a consensus operation on the first batch of transactions, and if there is a second batch of transactions, perform a collection operation on the second batch of transactions in parallel in batch order, the second batch of transactions is the target transaction set that has not yet been collected Batch transactions.
应理解,本步骤所述的尚未完成收集的批次交易可以包括尚未启动收集的批次交易,或者已经启动收集但尚未完成收集的批次交易。批次顺序即上文S102中所述的批次划分顺序。It should be understood that the batch transactions that have not been collected in this step may include batch transactions that have not yet started collection, or batch transactions that have started collection but have not yet completed collection. The batch order is the batch division order described in S102 above.
本说明书实施例中,区块链节点分批收集目标交易集合的交易。在收集完成目标批次交易后,即可同时执行:目标批次交易的共识执行操作以及目标批次交易对应的下一批次交易的收集操作。也就是说,本步骤所述的第二批次交易是指第一批次交易的下一批次交易。In the embodiment of this specification, the blockchain nodes collect the transactions of the target transaction set in batches. After the target batch of transactions is collected, it can be executed at the same time: the consensus execution operation of the target batch of transactions and the collection operation of the next batch of transactions corresponding to the target batch of transactions. That is to say, the second batch of transactions mentioned in this step refers to the next batch of transactions of the first batch of transactions.
S106,对第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对第三批次交易的共识操作,第三批次交易为目标交易集合已经收集完毕且尚未完成共识的批次交易。S106, perform transaction execution operations on the first batch of transactions, and if there is a consensus operation on the third batch of transactions in parallel execution of the third batch of transactions, the third batch of transactions is that the target transaction set has been collected and Batch transactions that have not yet completed consensus.
应理解,本步骤所述的尚未完成共识的批次交易可以包括尚未启动共识的批次交易,或者已经启动共识但共识尚未完成共识的批次交易。It should be understood that the batches of transactions whose consensus has not been completed in this step may include batches of transactions that have not yet started consensus, or batches of transactions that have started consensus but have not yet completed consensus.
同理,本说明书实施例中,区块链节点分批对目标交易集合的交易执行共识操作。在执行完成目标批次交易的共识操作后,即可同时执行:目标批次交易的执行操作以及目标批次交易对应的下一批次交易的共识操作。也就是说,本步骤所述的第三批次交易是指第二批次交易的下一批次交易。Similarly, in the embodiment of this specification, the blockchain nodes perform consensus operations on the transactions of the target transaction set in batches. After the consensus operation of the target batch of transactions is completed, it can be executed simultaneously: the execution operation of the target batch of transactions and the consensus operation of the next batch of transactions corresponding to the target batch of transactions. That is to say, the third batch of transactions mentioned in this step refers to the next batch of transactions of the second batch of transactions.
此外,如果在对第一批次交易进行交易执行操作时,存在第二批次交易,还可以并行执行按批次顺序对第二批次交易的收集操作。In addition, if there is a second batch of transactions when the transaction execution operation is performed on the first batch of transactions, the collection operation of the second batch of transactions in batch order can also be executed in parallel.
S108,在区块链中发送第一批次交易的交易执行结果以对第一批次交易进行交易确认。S108, sending the transaction execution results of the first batch of transactions in the blockchain to perform transaction confirmation on the first batch of transactions.
具体地,作为本步骤执行主体的区块链节点可以向区块链的其他区块链节点发送第一批次交易的交易执行结果的交易确认请求;之后如果接收到2f个其他区块链节点发送的交易确认反馈,则确认得到对第一批次交易的交易确认。其中,,f为区块链允许的异常共识节点最大数量。Specifically, the block chain node as the execution subject of this step can send the transaction confirmation request of the transaction execution result of the first batch of transactions to other block chain nodes in the block chain; if 2f other block chain nodes are received later If the transaction confirmation feedback is sent, the transaction confirmation of the first batch of transactions is confirmed. Among them, f is the maximum number of abnormal consensus nodes allowed by the blockchain.
S110,在得到目标交易集合的所有批次交易的交易确认后,对目标交易集合的所有批次交易执行一次写块操作。S110, after obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
应理解,本说明书实施例中,区块链节点对目标交易集合的交易分批次进行共识操作,但最终可以只执行一次写块操作。也就是说本说明书实施例中,目标交易集合的所有批次交易可以通过一个区块进行记录。It should be understood that, in the embodiment of this specification, the blockchain nodes perform consensus operations on the transactions of the target transaction set in batches, but in the end, only one block writing operation may be performed. That is to say, in the embodiment of this specification, all batches of transactions in the target transaction set can be recorded in one block.
基于本说明书实施例的方法,区块链节点对大数据量的目标交易集分批次执行交易收集、交易共识、交易执行以及交易确认。特别是在中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间。此外,在目标交易集中的所有批次交易完成交易确认后,再统一执行一次写块操作,从而通过降低写块次数的方式提高区块链交易的处理效率。整个方案能够显著提高区块链的吞吐量,可满足业务高并发场景的需求。Based on the method in the embodiment of this specification, the block chain node executes transaction collection, transaction consensus, transaction execution and transaction confirmation in batches for the target transaction set with a large amount of data. In particular, while the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner. In addition, after all batches of transactions in the target transaction set are confirmed, a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes. The whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
此外,在得到第一批次交易的交易确认后,还可以将第一批次交易的交易执行结果反馈至对应的区块链客户端。也就是说,本说明书实施例的方法中,区块链节点在每个批次交易完成交易执行并得到交易确认后,即可立刻将交易执行反馈至的区块链客户端,从而显著降低区块链客户端侧的交易确认时延,进而提高用户使用体验。In addition, after the transaction confirmation of the first batch of transactions is obtained, the transaction execution results of the first batch of transactions can also be fed back to the corresponding blockchain client. That is to say, in the method of the embodiment of this specification, the block chain node can immediately feed back the transaction execution to the block chain client after each batch of transactions completes the transaction execution and gets the transaction confirmation, thereby significantly reducing the transaction time. The transaction confirmation delay on the client side of the block chain improves the user experience.
或者,为了降低与区块链客户端侧交互的资源开销,也可以在得到目标交易集合的所有批次交易的交易确认后,再将目标交易集合的所有批次交易的交易执行结果统一反馈至对应的区块链客户端。Or, in order to reduce the resource overhead of interacting with the blockchain client side, after obtaining the transaction confirmation of all batches of transactions in the target transaction set, the transaction execution results of all batches of transactions in the target transaction set can be uniformly fed back to The corresponding blockchain client.
在实际应用中,可以针对目标交易集合中的交易数量,决定交易执行结果的反馈策略。比如,当目标交易集合中的交易数量超出预设阈值时,则可以选择在每个批次交易完成交易执行并得到交易确认后,立刻将交易执行结果反馈至的区块链客户端。同理,当目标交易集合中的交易数量未超出预设阈值时, 则可以选择在目标交易集合的所有批次交易完成交易执行并得到交易确认后,再将目标交易集合的所有批次交易的交易执行结果统一反馈至对应的区块链客户端。In practical applications, the feedback strategy for transaction execution results can be determined according to the transaction quantity in the target transaction set. For example, when the number of transactions in the target transaction set exceeds the preset threshold, you can choose to immediately feed back the transaction execution results to the blockchain client after each batch of transactions is executed and confirmed. Similarly, when the number of transactions in the target transaction set does not exceed the preset threshold, you can choose to transfer all batches of transactions in the target transaction set to The transaction execution results are uniformly fed back to the corresponding blockchain client.
下面结合实际的应用场景,对本说明书实施例的处理方法进行示例性介绍。The processing method in the embodiment of this specification is exemplarily introduced below in combination with actual application scenarios.
作为其中一种可行方案,本说明书实施例的方法可以以区块链每轮视图为粒度,分批次处理区块链交易。As one of the feasible solutions, the method in the embodiment of this specification can process blockchain transactions in batches at the granularity of each round of blockchain views.
这里,假设本说明书实施例的目标交易集为区块链在第N轮视图的所有交易。Here, it is assumed that the target transaction set in the embodiment of this specification is all transactions in the Nth round view of the blockchain.
下面对本说明书实施例方法连续处理第N-1轮和第N轮的视图中的交易的原理进行详细介绍(第N轮视图和第N+1轮视图均至少需要两次区块链共识才能完成交易数据的上链)。The following is a detailed introduction to the principle of continuous processing of transactions in the N-1 round and the N-th round of the method of the embodiment of this specification (the N-th round of view and the N+1-th round of view require at least two blockchain consensuses to complete) Uplink of transaction data).
参考图2,本说明书实施例的方法可以设置相互并行执行的第一线程、第二线程、第三线程、第四线程和第五线程,以分别对应执行区块链交易的收集、共识、交易执行、交易确认和写块这五个操作。Referring to Figure 2, the method of the embodiment of this specification can set the first thread, the second thread, the third thread, the fourth thread and the fifth thread to be executed in parallel, so as to respectively execute the collection, consensus, and transaction of blockchain transactions. These five operations are execution, transaction confirmation, and block writing.
其中,第一线程用于按批次收集交易,也就是第一线程在收集完一个批次交易之前不收集其它批次交易;第二线程用于按批次执行交易的共识操作,也就是第二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作;第三线程用于按批次执行交易的执行操作,也就是在执行完一个批次交易的执行操作之前不执行其它批次交易的执行操作。第四线程按批次进行交易确认,也就是在执行完一个批次交易的交易确认之前不执行其它批次交易的交易确认。第五线程则在每轮视图的所有批次交易完成交易确认后,统一执行写块操作。Among them, the first thread is used to collect transactions in batches, that is, the first thread does not collect other batches of transactions before collecting a batch of transactions; the second thread is used to perform consensus operations on transactions in batches, that is, the first thread The second thread does not execute the consensus operations of other batches of transactions before executing the consensus operation of a batch of transactions; the third thread is used to execute the execution operations of transactions in batches, that is, before executing the execution operations of a batch of transactions The execution operations of other batches of transactions are not executed. The fourth thread performs transaction confirmation in batches, that is, the transaction confirmation of other batches of transactions is not performed before the transaction confirmation of one batch of transactions is completed. The fifth thread executes block writing operations uniformly after all batches of transactions in each round of views are confirmed.
以上文所述的第一批次交易为例。在第一线程收集完第一批次交易之后,通知第二线程对所述第一批次交易进行共识操作;在第二线程执行完第一批次交易的共识操作之后,通知第三线程对第一批次交易进行执行操作;在第三线程执行完第一批次交易的执行操作之后,通知第四线程对第一批次交易进行交易确认。Take the first batch of transactions described above as an example. After the first thread has collected the first batch of transactions, notify the second thread to perform consensus operations on the first batch of transactions; after the second thread has completed the consensus operations of the first batch of transactions, notify the third thread to The first batch of transactions is executed; after the third thread executes the execution operations of the first batch of transactions, the fourth thread is notified to confirm the first batch of transactions.
这里以第N轮和第N+1轮的视图均划分有三个批次交易为示例,采用上述线程的工作原理,第N轮和第N+1轮的视图可以呈现图2所示的时隙关系。Here, the views of round N and round N+1 are divided into three batches of transactions as an example. Using the working principle of the above thread, the views of round N and round N+1 can present the time slots shown in Figure 2 relation.
从图2可以看出:It can be seen from Figure 2:
如果在对第一批次交易执行共识操作时目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the consensus operation is performed on the first batch of transactions, the collection operation of batches of transactions in the N+1-th round view is performed in batch order.
如果对第一批次交易进行交易执行操作时,目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the transaction execution operation is performed on the first batch of transactions, the collection operation of batches of transactions in the N+1-th round view is performed in batch order.
如果对第一批次交易进行交易执行操作时,目标交易集合中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the target transaction set have reached consensus when executing the transaction on the first batch of transactions, execute batches that have been collected but have not yet completed consensus in the N+1 round view in batch order Consensus operation of transactions.
如果对第一批次交易进行写块操作时,目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the first batch of transactions is written, the collection operation of the batches of transactions in the N+1-th round view is performed in batch order.
如果对第一批次交易进行写块操作时,目标交易集合中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the target transaction set have reached consensus when writing blocks for the first batch of transactions, execute the batches that have been collected but have not yet completed consensus in the N+1 round of views in batch order Consensus operation of transactions.
此外还应理解的是,保证交易执行的有序性也十分重要。假设某个交易场景中,用户A需要向用户B汇款10000元,再由用户B向用户C汇款5000元。假设用户B初始的余额为3000元,如果交易不按序执行,也就是用户B先向用户C汇款5000元,用户A再向用户B汇入10000元,那么会出现用户B向用户C汇款失败的问题。It should also be understood that orderly execution of transactions is also important. Assume that in a transaction scenario, user A needs to remit 10,000 yuan to user B, and then user B remits 5,000 yuan to user C. Assuming that the initial balance of user B is 3,000 yuan, if the transactions are not executed in sequence, that is, user B first remits 5,000 yuan to user C, and user A remits 10,000 yuan to user B, then user B will fail to remit money to user C The problem.
因此为了避免这种交易逻辑问题发生,每轮视图后一批次交易不能早于前一批次交易进行交易执行。而在实际的交易数据的上链过程中,执行阶段的耗时要大于收集阶段和共识阶段的耗时。这样导致每个中间批次交易在共识完成后,需要等待上一批次交易完成执行,这个等待时间(图2中的T表示等待时间)会决定交易数据的上链效率。Therefore, in order to avoid such transaction logic problems, the subsequent batch of transactions in each round of view cannot be executed earlier than the previous batch of transactions. In the process of actually uploading transaction data to the chain, the execution phase takes more time than the collection and consensus phases. This causes each intermediate batch of transactions to wait for the execution of the previous batch of transactions after the consensus is completed. This waiting time (T in Figure 2 represents the waiting time) will determine the efficiency of transaction data on-chain.
基于本说明书实施例的方法将每轮视图的交易进行多个小批次划分,可以减少每批次交易在执行上的耗时,也就是减少了T在图2中的长度,从而提高区块链交易的处理效率。Based on the method of the embodiment of this specification, the transactions of each round of views are divided into multiple small batches, which can reduce the time-consuming execution of each batch of transactions, that is, reduce the length of T in Figure 2, thereby improving the block The processing efficiency of chain transactions.
应理解,上述第一线程、第二线程、第三线程、第四线程和第五线程可以属于处理器的不同核心。 也就是本说明实施例可以多核多线程并行的方式,对同一轮视图执行交易的收集操作、共识操作以及执行操作。It should be understood that the above-mentioned first thread, second thread, third thread, fourth thread and fifth thread may belong to different cores of the processor. That is to say, the embodiment of this description can perform the transaction collection operation, consensus operation, and execution operation on the same round of views in a multi-core and multi-thread parallel manner.
以上是对本说明书实施例的方法的介绍。应理解,在不脱离本文上述原理基础之上,还可以进行适当的变化,这些变化也应视为本说明书实施例的保护范围。The above is the introduction to the method in the embodiment of this specification. It should be understood that appropriate changes can also be made without departing from the above-mentioned principles herein, and these changes should also be regarded as the protection scope of the embodiments of this specification.
比如,本说明实施例中,由于交易执行结果反馈客户端的操作可以在交易执行后立刻执行,因此可以使用一个线程来执行交易执行操作和交易执行结果的反馈操作。即,上文所述的第四线程即为上文所述的第三线程,区块链第N轮和第N+1轮的视图可以呈现图3所示的时隙关系。For example, in the embodiment of this description, since the operation of feeding back the transaction execution result to the client can be executed immediately after the transaction is executed, one thread can be used to execute the transaction execution operation and the feedback operation of the transaction execution result. That is, the fourth thread mentioned above is the third thread mentioned above, and the views of round N and round N+1 of the blockchain can present the time slot relationship shown in Figure 3 .
再比如,本说明书实施例的方法还可以在第N轮视图中的多有批次交易均完成共识后,再统一执行对第N轮视图的所有批次交易的执行操作和写块操作。即,本说明书实施例区块链交易的处理方法还可以如图4所示,包括以下步骤:For another example, the method in the embodiment of this specification can also perform the execution operation and block writing operation on all batches of transactions in the N-th round of views in a unified manner after all batches of transactions in the N-th round of views have completed consensus. That is, the processing method of the blockchain transaction in the embodiment of this specification can also be shown in Figure 4, including the following steps:
S402,收集区块链的目标交易集合中的第一批次交易,目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。S402. Collect the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the blockchain.
S404,对第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对第二批次交易的收集操作,第二批次交易为目标交易集合尚未完成收集的批次交易。S404, perform a consensus operation on the first batch of transactions, and perform a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, the second batch of transactions is the target transaction set that has not yet been collected Batch transactions.
S406,如果目标交易集合的所有批次交易都完成共识,对目标交易集合的所有批次交易进行交易执行操作。S406, if all batches of transactions in the target transaction set have completed the consensus, perform a transaction execution operation on all batches of transactions in the target transaction set.
S408,在区块链中发送目标交易集合的所有批次交易的交易执行结果以对目标交易集合的所有批次交易进行交易确认。S408, sending transaction execution results of all batches of transactions in the target transaction set in the blockchain to perform transaction confirmation on all batches of transactions in the target transaction set.
S410,在得到目标交易集合的所有批次交易的交易确认后,对目标交易集合的所有批次交易执行一次写块操作。S410. After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
图5是基于图4所示的方法进行第N轮和第N+1轮视图的时隙关系图。应理解,第N轮视图的所有批次交易的执行操作至少要在第N-1轮视图的所有批次交易的执行操作完成后才能执行。FIG. 5 is a time slot relationship diagram for the Nth round and the N+1th round of views based on the method shown in FIG. 4 . It should be understood that the execution operations of all batches of transactions in the N-th round view can be performed at least after the execution operations of all batches of transactions in the N-1 round view are completed.
同理,图4所示的方法通过第一线程对每轮视图按批次顺序收集交易,也就是第一线程在收集完一个批次交易之前不收集其它批次交易;通过二线程对每轮视图按批次顺序执行交易的共识操作,也就是第二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作;通过第三线程对每轮视图中的所有批次交易统一进行交易执行操作;通过第四线程执行对每轮视图中的所有批次交易统一进行交易确认;通过第五线程执行对每轮视图中的所有批次交易统一进行写块操作。这里,第一线程、第二线程、第三线程和第四线程和第五线程为并行执行的线程。Similarly, the method shown in Figure 4 uses the first thread to collect transactions in batch order for each round of views, that is, the first thread does not collect other batches of transactions before collecting a batch of transactions; The view executes the consensus operations of transactions in batch order, that is, the second thread does not execute the consensus operations of other batches of transactions before executing the consensus operations of one batch of transactions; through the third thread, all batches in each round of view The transactions are executed in a unified manner; through the fourth thread, all batches of transactions in each round of views are uniformly confirmed; through the fifth thread, all batches of transactions in each round of views are uniformly written into blocks. Here, the first thread, the second thread, the third thread, the fourth thread, and the fifth thread are threads executed in parallel.
从图5可以看出,对于图4所示的方法:As can be seen from Figure 5, for the method shown in Figure 4:
如果在对第一批次交易执行共识操作时,第N轮视图中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the view of the Nth round are collected when the consensus operation is performed on the first batch of transactions, the collection operation of the batches of transactions in the view of the N+1th round is performed in batch order.
如果在对第一批次交易进行交易执行操作时,存在第二批次交易,则并行执行按批次顺序对第二批次交易的收集操作。If there is a second batch of transactions when the transaction execution operation is performed on the first batch of transactions, the collection operation of the second batch of transactions in batch order is executed in parallel.
如果对第一批次交易进行交易执行操作时,第N轮视图中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the view of the Nth round are collected when the transaction execution operation is performed on the first batch of transactions, the collection operation of the batches of transactions in the view of the N+1th round is performed in batch order.
如果对第一批次交易进行交易执行操作时,第N轮视图中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of views have reached consensus when the transaction execution operation is performed on the first batch of transactions, the batches that have been collected but have not yet completed consensus in the N+1th round of views are executed in batch order. Consensus operation of the transaction.
如果对第一批次交易进行写块操作时,第N轮视图中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the view of the Nth round are collected when the first batch of transactions is written, the collection operation of the batches of transactions in the view of the N+1th round is performed in batch order.
如果对第一批次交易进行写块操作时,第N轮视图中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of views have reached a consensus when writing blocks for the first batch of transactions, execute the batches that have been collected but have not yet completed consensus in the N+1th round of views in batch order. Consensus operation of the transaction.
由此可见,图4所示的方法也可以分批次对目标交易集合执行交易收集、交易共识。特别是在对中间批次交易执行共识操作的同时,还执行下一批次交易的收集操作,从而也可以通过并行方式缩短了区块链交易的处理时间。此外,在目标交易集中的所有批次交易完成交易确认后,再统一执行一次写块操 作,从而通过降低写块次数的方式提高区块链交易的处理效率。整个方案能够显著提高区块链的吞吐量,可满足业务高并发场景的需求。It can be seen that the method shown in FIG. 4 can also perform transaction collection and transaction consensus on the target transaction set in batches. In particular, while the consensus operation is performed on the intermediate batch of transactions, the collection operation of the next batch of transactions is also performed, so that the processing time of blockchain transactions can also be shortened in parallel. In addition, after all batches of transactions in the target transaction set are confirmed, a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes. The whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
应理解,本说明书实施例的方法并不局限于以区块链每轮视图作为执行粒度。但凡是区块链积累到通过一次共识无法完成上链的交易集时,都可以使用本说明书实施例的方法,实现只发起一次写块操作的数据上链。It should be understood that the methods in the embodiments of this specification are not limited to taking each round view of the blockchain as the execution granularity. However, when the block chain accumulates to a transaction set that cannot be completed on the chain through a consensus, the method of the embodiment of this specification can be used to realize the data on-chain that only initiates a block writing operation once.
此外,与上述图1所示的处理方法相对应地,本说明书实施例还提供一种区块链节点。图6是本说明书实施例的区块链节点600的结构示意图,包括:In addition, corresponding to the processing method shown in FIG. 1 above, the embodiment of this specification also provides a blockchain node. Fig. 6 is a schematic structural diagram of a blockchain node 600 according to an embodiment of this specification, including:
第一交易收集模块610,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。The first transaction collection module 610 collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions agreed upon by the block chain at one time .
第一交易共识模块620,对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易。The first transaction consensus module 620 performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, executes the collection operation of the second batch of transactions in batch order in parallel, wherein the The second batch of transactions is a batch of transactions for which the target transaction set has not yet been collected.
第一交易执行模块630,对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易。The first transaction execution module 630 performs transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, executes a consensus operation on the third batch of transactions in batch order, wherein the The third batch of transactions is a batch of transactions for which the target transaction set has been collected and consensus has not yet been completed.
第一交易确认模块640,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认。The first transaction confirmation module 640 sends the transaction execution result of the first batch of transactions in the block chain to perform transaction confirmation on the first batch of transactions.
第一交易写块模块650,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The first transaction block writing module 650 executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
本说明书实施例的区块链节点对大数据量的目标交易集分批次执行交易收集、交易共识、交易执行以及交易确认。特别是在中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间。此外,在目标交易集中的所有批次交易完成交易确认后,再统一执行一次写块操作,从而通过降低写块次数的方式提高区块链交易的处理效率。整个方案能够显著提高区块链的吞吐量,可满足业务高并发场景的需求。The block chain node in the embodiment of this specification executes transaction collection, transaction consensus, transaction execution, and transaction confirmation in batches for a target transaction set with a large amount of data. In particular, while the intermediate batch of transactions executes the consensus operation, it also executes the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions, thereby shortening the processing time of blockchain transactions in a parallel manner. In addition, after all batches of transactions in the target transaction set are confirmed, a block write operation is performed uniformly, thereby improving the processing efficiency of blockchain transactions by reducing the number of block writes. The whole solution can significantly improve the throughput of the blockchain, which can meet the needs of high-concurrency business scenarios.
可选地,如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则第一交易执行模块630同时并行执行按批次顺序对所述第二批次交易的收集操作。Optionally, if the second batch of transactions exists when the transaction execution operation is performed on the first batch of transactions, the first transaction execution module 630 simultaneously executes the second batch of transactions in batch order The collection operation for the transaction.
可选地,目标交易集为所述区块链在第N轮视图的所有交易,其中,N为正整数。Optionally, the target transaction set is all transactions in the Nth round view of the blockchain, where N is a positive integer.
如果在对所述第一批次交易执行共识操作时,所述第N轮视图中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the Nth round of views are collected when the consensus operation is performed on the first batch of transactions, the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则第一交易收集模块610并行执行按批次顺序对所述第二批次交易的收集操作。If the second batch of transactions exists when the transaction execution operation is performed on the first batch of transactions, the first transaction collection module 610 executes the collection operation of the second batch of transactions in parallel in batch order.
如果对所述第一批次交易进行交易执行操作时,所述第N轮视图中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the Nth round of views are collected when the transaction execution operation is performed on the first batch of transactions, the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
如果对所述第一批次交易进行写块操作时,所述第N轮视图中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the Nth round of views are collected when the first batch of transactions is written into blocks, the first transaction collection module 610 executes the N+1th round of views in batch order The collection operation for batch transactions in .
如果对所述第一批次交易进行写块操作时,所述第N轮视图中的所有批次交易都共识完毕,则第一交易收集模块610执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of views have reached a consensus when performing block writing operations on the first batch of transactions, then the first transaction collection module 610 executes the N+1th round of views in batch order Consensus operations for batches of transactions that have been collected but have not yet completed consensus in .
可选地,第一交易确认模块640向所述区块链的其他区块链节点发送所述第一批次交易的交易执行结果的交易确认请求。之后,如果接收到2f个其他区块链节点发送的交易确认反馈,则确认得到对所述第一批次交易的交易确认,,f为区块链允许的异常共识节点最大数量。Optionally, the first transaction confirmation module 640 sends a transaction confirmation request of the transaction execution result of the first batch of transactions to other blockchain nodes of the blockchain. Afterwards, if the transaction confirmation feedback sent by 2f other blockchain nodes is received, it is confirmed that the transaction confirmation of the first batch of transactions is obtained, and f is the maximum number of abnormal consensus nodes allowed by the blockchain.
可选地,本说明书实施例图6所示的区块链节点还包括:Optionally, the blockchain node shown in Figure 6 of the embodiment of this specification also includes:
第一交易反馈模块,在得到所述第一批次交易的交易确认后,将所述第一批次交易的交易执行结果反馈至对应的区块链客户端;或者,在得到所述第N轮视图的所有批次交易的交易确认后,将所述第N轮视图的所有批次交易的交易执行结果反馈至对应的区块链客户端。The first transaction feedback module, after obtaining the transaction confirmation of the first batch of transactions, feeds back the transaction execution results of the first batch of transactions to the corresponding block chain client; or, after obtaining the Nth After the transactions of all batches of transactions in the round view are confirmed, the transaction execution results of all batches of transactions in the Nth round view are fed back to the corresponding blockchain client.
可选地,第一交易收集模块610通过第一线程收集所述第N轮视图中的所有批次交易,所述第一线程在收集完一个批次交易之前不收集其它批次交易。第一交易共识模块620通过第二线程执行对所述第N轮视图中的所有批次交易的共识操作,所述二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作。第一交易执行模块630通过第三线程执行对所述第N轮视图中的所有批次交易的执行操作,所述第三线程在执行完一个批次交易的执行操作之前不执行其它批次交易的执行操作;第一交易确认模块640通过第四线程执行所述第N轮视图中的所有批次交易的交易确认。第一交易写块模块650,通过第五线程执行对所述第N轮视图中的所有批次交易执行写块操作。其中,所述第一线程、所述第二线程、所述第三线程、所述第四线程和所述第五线程为并行执行的线程。Optionally, the first transaction collection module 610 collects all batches of transactions in the Nth round of views through a first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions. The first transaction consensus module 620 executes consensus operations on all batches of transactions in the Nth round of views through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of one batch of transactions Consensus operation. The first transaction execution module 630 executes execution operations on all batches of transactions in the Nth round view through a third thread, and the third thread does not execute other batches of transactions before executing the execution operation of one batch of transactions The execution operation; the first transaction confirmation module 640 executes the transaction confirmation of all batches of transactions in the Nth round view through the fourth thread. The first transaction block writing module 650 executes block writing operations on all batches of transactions in the Nth round of views through the fifth thread. Wherein, the first thread, the second thread, the third thread, the fourth thread and the fifth thread are threads executed in parallel.
可选地,在所述第一线程收集完所述第一批次交易之后,通知所述第二线程对所述第一批次交易进行共识操作;在所述第二线程执行完所述第一批次交易的共识操作之后,通知所述第三线程对所述第一批次交易进行执行操作;在所述第三线程执行完所述第一批次交易的执行操作之后,通知所述第四线程对所述第一批次交易进行交易确认。Optionally, after the first thread collects the first batch of transactions, notify the second thread to perform a consensus operation on the first batch of transactions; After the consensus operation of a batch of transactions, notify the third thread to perform operations on the first batch of transactions; after the third thread executes the execution operations of the first batch of transactions, notify the The fourth thread performs transaction confirmation on the first batch of transactions.
显然,图6所示的区块链节点可以作为上述图1所示的处理方法的执行主体,因此能够实现该处理方法在图1至图3所实现的功能。由于原理相同,本文不再赘述。Apparently, the block chain node shown in FIG. 6 can be used as the execution subject of the processing method shown in FIG. 1 above, so it can realize the functions realized by the processing method in FIG. 1 to FIG. 3 . Since the principle is the same, this article will not repeat them.
此外,与上述图4所示的处理方法相对应地,本说明书实施例还提供一种区块链节点。图7是本说明书实施例的区块链节点700的结构示意图,包括:In addition, corresponding to the processing method shown in FIG. 4 above, the embodiment of this specification also provides a blockchain node. FIG. 7 is a schematic structural diagram of a block chain node 700 according to an embodiment of this specification, including:
第二交易收集模块710,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。The second transaction collection module 710 collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the transaction number of the block chain consensus at one time .
第二交易共识模块720,对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易。The second transaction consensus module 720 performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, executes the collection operation of the second batch of transactions in batch order in parallel, wherein the The second batch of transactions is a batch of transactions for which the target transaction set has not yet been collected.
第二交易执行模块730,如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作。The second transaction execution module 730, if all batches of transactions in the target transaction set have completed the consensus, perform a transaction execution operation on all batches of transactions in the target set.
第二交易确认模块740,在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认The second transaction confirmation module 740, sends the transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set
第二交易写块模块750,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The second transaction block writing module 750 executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
可选地,如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则第二交易收集模块710同时并行执行按批次顺序对所述第二批次交易的收集操作。Optionally, if the second batch of transactions exists when the transaction execution operation is performed on the first batch of transactions, the second transaction collection module 710 simultaneously executes the second batch of transactions in batch order The collection operation for the transaction.
可选地,,目标交易集为所述区块链在第N轮视图的所有交易,其中,N为正整数。Optionally, the target transaction set is all transactions in the Nth round view of the blockchain, where N is a positive integer.
如果在对所述第一批次交易执行共识操作时,所述第N轮共识中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus are collected when the consensus operation is performed on the first batch of transactions, the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
如果对所述第一批次交易进行交易执行操作时,所述第N轮共识中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus are collected when the transaction execution operation is performed on the first batch of transactions, the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
如果对所述第一批次交易进行写块操作时,所述第N轮共识中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus are collected when the first batch of transactions is written, the second transaction collection module 710 executes the N+1th round of consensus in batch order The collection operation for batch transactions in .
可选地,如果对所述第一批次交易进行写块操作时,所述第N轮共识中的所有批次交易都共识完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识中的已收集但尚未完成共识的批次交易的共识操作。Optionally, if all batches of transactions in the Nth round of consensus have completed the consensus when performing block writing operations on the first batch of transactions, then the second transaction collection module 710 executes the Nth round of transactions in batch order +1 Consensus operations for batches of transactions that have been collected but not yet completed consensus in a consensus round.
可选地,第二交易确认模块740向所述区块链的其他区块链节点发送所述第一批次交易的交易执行结果的交易确认请求。之后,如果接收到2f个其他区块链节点发送的交易确认反馈,则确认得到对所述第一批次交易的交易确认,f为区块链允许的异常共识节点最大数量。Optionally, the second transaction confirmation module 740 sends a transaction confirmation request of the transaction execution result of the first batch of transactions to other blockchain nodes of the blockchain. Afterwards, if the transaction confirmation feedback sent by 2f other blockchain nodes is received, it is confirmed that the transaction confirmation of the first batch of transactions is obtained, and f is the maximum number of abnormal consensus nodes allowed by the blockchain.
可选地,本说明书实施例图7所示的区块链节点还包括:Optionally, the blockchain node shown in Figure 7 of the embodiment of this specification also includes:
第二交易反馈模块,在得到所述第N轮共识的所有批次交易的交易确认后,将所述第N轮共识的 所有批次交易的交易执行结果反馈至对应的区块链客户端。The second transaction feedback module, after obtaining the transaction confirmation of all batches of transactions in the Nth round of consensus, feeds back the transaction execution results of all batches of transactions in the Nth round of consensus to the corresponding block chain client.
可选地,第二交易收集模块710通过第一线程收集所述第N轮共识中的所有批次交易,所述第一线程在收集完一个批次交易之前不收集其它批次交易。第二交易共识模块720通过第二线程执行对所述第N轮共识中的所有批次交易的共识操作,所述二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作。第二交易执行模块730通过第三线程执行对所述第N轮共识中的所有批次交易的执行操作;第二交易确认模块740通过第四线程执行所述第N轮共识中的所有批次交易的交易确认。第二交易写块模块750,通过第五线程执行对所述第N轮共识中的所有批次交易执行写块操作。其中,所述第一线程、所述第二线程、所述第三线程、所述第四线程和所述第五线程为并行执行的线程。Optionally, the second transaction collection module 710 collects all batches of transactions in the N-th round of consensus through a first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions. The second transaction consensus module 720 executes consensus operations on all batches of transactions in the N-th round of consensus through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of one batch of transactions Consensus operation. The second transaction execution module 730 executes the execution operation on all batches of transactions in the N-round consensus through the third thread; the second transaction confirmation module 740 executes all batches in the N-round consensus through the fourth thread A transaction confirmation for a transaction. The second transaction block writing module 750 executes block writing operations on all batches of transactions in the N-th round of consensus through the fifth thread. Wherein, the first thread, the second thread, the third thread, the fourth thread and the fifth thread are threads executed in parallel.
可选地,在所述第一线程收集完所述第一批次交易之后,通知所述第二线程对所述第一批次交易进行共识操作。Optionally, after the first thread collects the first batch of transactions, the second thread is notified to perform a consensus operation on the first batch of transactions.
显然,图7所示的区块链节点节点可以作为上述图4所示的处理方法的执行主体,因此能够实现该处理方法在图4和图5所实现的功能。由于原理相同,本文不再赘述。Apparently, the block chain node node shown in FIG. 7 can be used as the execution body of the processing method shown in FIG. 4 above, so it can realize the functions realized by the processing method in FIG. 4 and FIG. 5 . Since the principle is the same, this article will not repeat them.
图8是本说明书的一个实施例电子设备的结构示意图。请参考图8,在硬件层面,该电子设备包括处理器,可选地还包括内部总线、网络接口、存储器。其中,存储器可能包含内存,例如高速随机存取存储器(Random-Access Memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少1个磁盘存储器等。当然,该电子设备还可能包括其他业务所需要的硬件。Fig. 8 is a schematic structural diagram of an electronic device according to an embodiment of the present specification. Please refer to FIG. 8 , at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Wherein, the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Of course, the electronic device may also include hardware required by other services.
处理器、网络接口和存储器可以通过内部总线相互连接,该内部总线可以是ISA(Industry Standard Architecture,工业标准体系结构)总线、PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图8中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc. The bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 8 , but it does not mean that there is only one bus or one type of bus.
存储器,用于存放程序。具体地,程序可以包括程序代码,所述程序代码包括计算机操作指令。存储器可以包括内存和非易失性存储器,并向处理器提供指令和数据。Memory for storing programs. Specifically, the program may include program code, and the program code includes computer operation instructions. Storage, which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
可选地,处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成区块链交易的处理装置,该处理装置可以作为图6所示的区块链节点或者区块链节点中的部件。处理器,执行存储器所存放的程序,并具体用于执行以下操作:Optionally, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to form a processing device for blockchain transactions on a logical level, which can be used as the block shown in Figure 6 A chain node or a component in a blockchain node. The processor executes the program stored in the memory, and is specifically used to perform the following operations:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。Collecting the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易。Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected by the above target transaction collection.
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易。Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed.
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认。Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set.
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
可选地,处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成区块链交易的处理装置,该处理装置可以作为图7所示的区块链节点或者区块链节点中的部件。处理器,执行存储器所存放的程序,并具体用于执行以下操作:Optionally, the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to form a processing device for blockchain transactions on a logical level, which can be used as the block shown in Figure 7 A chain node or a component in a blockchain node. The processor executes the program stored in the memory, and is specifically used to perform the following operations:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。Collecting the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易。Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected by the above target transaction collection.
如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作。If all batches of transactions in the target transaction set have completed the consensus, perform a transaction execution operation on all batches of transactions in the target transaction set.
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认。Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set.
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
上述如本说明书图1或图3所示实施例揭示的处理方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本说明书实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本说明书实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。The above-mentioned processing method disclosed in the embodiment shown in FIG. 1 or FIG. 3 of this specification may be applied to a processor or implemented by the processor. A processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), Field-Programmable Gate Array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be realized or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the method disclosed in the embodiments of this specification may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module can be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
应理解,本说明书实施例的电子设备可以实现图6所示的区块链节点在图1至图3所示的实施例的功能,或者实现图7所示的区块链节点在图4和图5所示的实施例的功能。由于原理相同,本文不再赘述。It should be understood that the electronic device in the embodiment of this specification can realize the functions of the block chain node shown in FIG. 6 in the embodiments shown in FIGS. Figure 5 shows the functionality of the embodiment. Since the principle is the same, this article will not repeat them.
当然,除了软件实现方式之外,本说明书的电子设备并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。Of course, in addition to the software implementation, the electronic equipment in this specification does not exclude other implementations, such as logic devices or the combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, It can also be a hardware or logic device.
此外,本说明书实施例还提出了一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令。In addition, the embodiment of this specification also proposes a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions.
可选地,上述指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图1所示实施例的方法,并具体用于执行以下方法:Optionally, when the above instructions are executed by a portable electronic device including multiple application programs, the portable electronic device can execute the method of the embodiment shown in FIG. 1 , and is specifically used to perform the following methods:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。Collecting the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易。Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected by the above target transaction collection.
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易。Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed.
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认。Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set.
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
可选地,上述指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图4所示实施例的方法,并具体用于执行以下方法:Optionally, the above instructions, when executed by a portable electronic device including multiple application programs, can cause the portable electronic device to execute the method of the embodiment shown in FIG. 4 , and are specifically used to execute the following methods:
收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限。Collecting the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain.
如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行 操作。If all batches of transactions in the target transaction set have completed consensus, perform transaction execution operations on all batches of transactions in the target set.
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易。Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed.
在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认。Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set.
在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
应理解,上述指令当被包括多个应用程序的便携式电子设备执行时,能够使图6所示的区块链节点实现图1至图3所示实施例的功能,或者,能够使图7所示的区块链节点实现图4和图5所示实施例的功能。由于原理相同,本文不再赘述。It should be understood that when the above instructions are executed by a portable electronic device including multiple application programs, the block chain node shown in FIG. 6 can realize the functions of the embodiments shown in FIG. 1 to FIG. The block chain node shown realizes the functions of the embodiments shown in Fig. 4 and Fig. 5 . Since the principle is the same, this article will not repeat them.
本领域技术人员应明白,本说明书的实施例可提供为方法、系统或计算机程序产品。因此,本说明书可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of this specification may be provided as methods, systems or computer program products. Accordingly, this description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of this specification. Other implementations are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. Multitasking and parallel processing are also possible or may be advantageous in certain embodiments.
以上仅为本说明书的实施例而已,并不用于限制本说明书。对于本领域技术人员来说,本说明书可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本说明书的权利要求范围之内。此外,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本文件的保护范围。The above are only examples of this specification, and are not intended to limit this specification. For those skilled in the art, various modifications and changes may occur in this description. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included within the scope of the claims of this specification. In addition, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this document.

Claims (19)

  1. 一种区块链交易的处理方法,包括:A method for processing blockchain transactions, comprising:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
    在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
  2. 根据权利要求1所述的方法,还包括:The method according to claim 1, further comprising:
    如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则并行执行按批次顺序对所述第二批次交易的收集操作。If the second batch of transactions exists when the transaction execution operation is performed on the first batch of transactions, the operation of collecting the second batch of transactions in batch order is executed in parallel.
  3. 根据权利要求1所述的方法,还包括:The method according to claim 1, further comprising:
    所述目标交易集为所述区块链在第N轮视图的所有交易,其中,N为正整数。The target transaction set is all transactions of the block chain in round N, where N is a positive integer.
  4. 根据权利要求3所述的方法,还包括:The method according to claim 3, further comprising:
    如果在对所述第一批次交易执行共识操作时,所述目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the consensus operation is performed on the first batch of transactions, then perform the collection of batches of transactions in the N+1th round view in batch order operate.
  5. 根据权利要求3所述的方法,还包括:The method according to claim 3, further comprising:
    如果对所述第一批次交易进行交易执行操作时,所述目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the transaction execution operation is performed on the first batch of transactions, then execute the collection of batches of transactions in the N+1-th round view in batch order operate.
  6. 根据权利要求3所述的方法,还包括:The method according to claim 3, further comprising:
    如果对所述第一批次交易进行交易执行操作时,所述目标交易集合中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the target transaction set have reached a consensus when the transaction execution operation is performed on the first batch of transactions, then execute the collected but not yet completed Consensus operations for consensus batch transactions.
  7. 根据权利要求3所述的方法,还包括:The method according to claim 3, further comprising:
    如果对所述第一批次交易进行写块操作时,所述目标交易集合中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮视图中的批次交易的收集操作。If all batches of transactions in the target transaction set are collected when the first batch of transactions is written, execute the collection of batches of transactions in the N+1-th round view in batch order operate.
  8. 根据权利要求3所述的方法,还包括:The method according to claim 3, further comprising:
    如果对所述第一批次交易进行写块操作时,所述目标交易集合中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮视图中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the target transaction set have reached a consensus when performing block writing operations on the first batch of transactions, then execute the batch order of the N+1 round of views that have been collected but have not yet been completed Consensus operations for consensus batch transactions.
  9. 根据权利要求1所述的方法,The method according to claim 1,
    在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认,包括:Sending the transaction execution results of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions, including:
    向所述区块链的其他区块链节点发送所述第一批次交易的交易执行结果的交易确认请求;Sending a transaction confirmation request of the transaction execution result of the first batch of transactions to other blockchain nodes of the blockchain;
    如果接收到2f个其他区块链节点发送的交易确认反馈,则确认得到对所述第一批次交易的交易确认,f为所述区块链允许的异常共识节点最大数量。If the transaction confirmation feedback sent by 2f other blockchain nodes is received, it is confirmed that the transaction confirmation of the first batch of transactions is obtained, and f is the maximum number of abnormal consensus nodes allowed by the blockchain.
  10. 如权利要求3所述的方法,还包括:The method of claim 3, further comprising:
    在得到所述第一批次交易的交易确认后,将所述第一批次交易的交易执行结果反馈至对应的区块链客户端;After obtaining the transaction confirmation of the first batch of transactions, feeding back the transaction execution results of the first batch of transactions to the corresponding block chain client;
    或者,or,
    在得到所述目标交易集合的所有批次交易的交易确认后,将所述目标交易集合的所有批次交易的交易执行结果反馈至对应的区块链客户端。After the transaction confirmation of all batches of transactions in the target transaction set is obtained, the transaction execution results of all batches of transactions in the target transaction set are fed back to the corresponding block chain client.
  11. 如权利要求3所述的方法,还包括:The method of claim 3, further comprising:
    通过第一线程收集所述目标交易集合中的所有批次交易,所述第一线程在收集完一个批次交易之前不收集其它批次交易;Collect all batches of transactions in the target transaction set through the first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions;
    通过第二线程执行对所述目标交易集合中的所有批次交易的共识操作,所述二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作;Execute consensus operations on all batches of transactions in the target transaction set through the second thread, and the second thread does not perform consensus operations on other batches of transactions before completing the consensus operation on one batch of transactions;
    通过第三线程执行对所述目标交易集合中的所有批次交易的执行操作,所述第三线程在执行完一个批次交易的执行操作之前不执行其它批次交易的执行操作;Executing execution operations on all batches of transactions in the target transaction set through a third thread, and the third thread does not execute execution operations on other batches of transactions before completing the execution operation of one batch of transactions;
    通过第四线程执行所述目标交易集合中的所有批次交易的交易确认;Execute the transaction confirmation of all batches of transactions in the target transaction set through the fourth thread;
    通过第五线程执行对所述目标交易集合中的所有批次交易执行写块操作;Execute block write operations on all batch transactions in the target transaction set through the fifth thread;
    其中,所述第一线程、所述第二线程、所述第三线程、所述第四线程和所述第五线程为并行执行的线程。Wherein, the first thread, the second thread, the third thread, the fourth thread and the fifth thread are threads executed in parallel.
  12. 如权利要求11所述的方法,还包括:The method of claim 11, further comprising:
    在所述第一线程收集完所述第一批次交易之后,通知所述第二线程对所述第一批次交易进行共识操作;After the first thread collects the first batch of transactions, notify the second thread to perform a consensus operation on the first batch of transactions;
    在所述第二线程执行完所述第一批次交易的共识操作之后,通知所述第三线程对所述第一批次交易进行执行操作;After the second thread executes the consensus operation of the first batch of transactions, notify the third thread to perform operations on the first batch of transactions;
    在所述第三线程执行完所述第一批次交易的执行操作之后,通知所述第四线程对所述第一批次交易进行交易确认。After the third thread executes the execution operation of the first batch of transactions, the fourth thread is notified to perform transaction confirmation on the first batch of transactions.
  13. 一种区块链交易的处理方法,应用于区块链节点,包括:A method for processing blockchain transactions, applied to blockchain nodes, comprising:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;If all batches of transactions in the target transaction set have completed consensus, perform a transaction execution operation on all batches of transactions in the target set;
    在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
  14. 一种区块链节点,包括:A blockchain node, comprising:
    第一交易收集模块,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;The first transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
    第一交易共识模块,对所述第一批次交易执行共识操作,如果存在第二批次交易,则所述第一交易收集模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;The first transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the first transaction collection module simultaneously executes the second batch of transactions in batch order in parallel A collection operation, wherein the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
    第一交易执行模块,对所述第一批次交易进行交易执行操作,如果存在第三批次交易,则第一交易共识模块同时并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;The first transaction execution module performs transaction execution operations on the first batch of transactions. If there is a third batch of transactions, the first transaction consensus module simultaneously executes the consensus on the third batch of transactions in parallel. Operation, wherein the third batch of transactions is a batch of transactions for which the target transaction set has been collected and consensus has not yet been completed;
    第一交易确认模块,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;The first transaction confirmation module sends the transaction execution results of the first batch of transactions in the blockchain to confirm the first batch of transactions;
    第一交易写块模块,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The first transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  15. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:An electronic device includes: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
    在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
  16. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:A computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collect the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and if there is a second batch of transactions, performing a collection operation on the second batch of transactions in parallel in batch order, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行案批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述目标交易集合已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform batch order consensus operations on the third batch of transactions, wherein the third batch of transactions is all Batch transactions whose target transaction set has been collected and consensus has not yet been completed;
    在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;Sending the transaction execution result of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
  17. 一种区块链节点,包括:A blockchain node, comprising:
    第二交易收集模块,收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;The second transaction collection module collects the first batch of transactions in the target transaction set of the block chain, the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in one consensus of the block chain;
    第二交易共识模块,对所述第一批次交易执行共识操作,如果存在第二批次交易,则第二交易共识模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;The second transaction consensus module performs a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the second transaction consensus module simultaneously executes the collection operation of the second batch of transactions in batch order in parallel , wherein, the second batch of transactions is a batch of transactions that have not been collected by the target transaction set;
    第二交易执行模块,如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;The second transaction execution module, if all batches of transactions in the target transaction set have reached a consensus, perform a transaction execution operation on all batches of transactions in the target set;
    第二交易确认模块,在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认The second transaction confirmation module sends the transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set
    第二交易写块模块,在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。The second transaction block writing module executes a block writing operation on all batches of transactions in the target transaction set after obtaining the transaction confirmations of all batches of transactions in the target transaction set.
  18. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:An electronic device includes: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;If all batches of transactions in the target transaction set have completed consensus, perform a transaction execution operation on all batches of transactions in the target set;
    在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
  19. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤:A computer-readable storage medium, where a computer program is stored on the computer-readable storage medium, and when the computer program is executed by a processor, the following steps are implemented:
    收集区块链的目标交易集合中的第一批次交易,所述目标交易集中包括多个批次交易,且交易数量超出所述区块链一次共识的交易数量上限;Collecting the first batch of transactions in the target transaction set of the blockchain, where the target transaction set includes multiple batches of transactions, and the number of transactions exceeds the upper limit of the number of transactions in a consensus of the blockchain;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述目标交易集合尚未完成收集的批次交易;Executing a consensus operation on the first batch of transactions, and performing a collection operation on the second batch of transactions in parallel if there is a second batch of transactions, wherein the second batch of transactions is all Batches of transactions that have not been collected for the above target transaction set;
    如果所述目标交易集合的所有批次交易都完成共识,对所述目标集合的所有批次交易进行交易执行操作;If all batches of transactions in the target transaction set have completed consensus, perform a transaction execution operation on all batches of transactions in the target set;
    在所述区块链中发送所述目标交易集合的所有批次交易的交易执行结果以对所述目标交易集合的所有批次交易进行交易确认;Sending transaction execution results of all batches of transactions in the target transaction set in the block chain to perform transaction confirmation on all batches of transactions in the target transaction set;
    在得到所述目标交易集合的所有批次交易的交易确认后,对所述目标交易集合的所有批次交易执行一次写块操作。After obtaining the transaction confirmations of all batches of transactions in the target transaction set, perform a block write operation on all batches of transactions in the target transaction set.
PCT/CN2022/135434 2022-02-24 2022-11-30 Method for processing blockchain transactions, and blockchain node and electronic device WO2023160088A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210178479.2 2022-02-24
CN202210178479.2A CN114547201A (en) 2022-02-24 2022-02-24 Processing method of block chain transaction, block chain node and electronic equipment

Publications (1)

Publication Number Publication Date
WO2023160088A1 true WO2023160088A1 (en) 2023-08-31

Family

ID=81679201

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135434 WO2023160088A1 (en) 2022-02-24 2022-11-30 Method for processing blockchain transactions, and blockchain node and electronic device

Country Status (2)

Country Link
CN (1) CN114547201A (en)
WO (1) WO2023160088A1 (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114547201A (en) * 2022-02-24 2022-05-27 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment
CN114529413A (en) * 2022-02-24 2022-05-24 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221639A (en) * 2020-01-09 2020-06-02 杭州趣链科技有限公司 Block pipeline execution method of block chain platform
CN112887436A (en) * 2021-04-28 2021-06-01 支付宝(杭州)信息技术有限公司 Consensus method, consensus node and block chain system of pipeline mode
US20210318859A1 (en) * 2020-04-13 2021-10-14 International Business Machines Corporation Optimization of execution of smart contracts
CN114529413A (en) * 2022-02-24 2022-05-24 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment
CN114547201A (en) * 2022-02-24 2022-05-27 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN111221639A (en) * 2020-01-09 2020-06-02 杭州趣链科技有限公司 Block pipeline execution method of block chain platform
US20210318859A1 (en) * 2020-04-13 2021-10-14 International Business Machines Corporation Optimization of execution of smart contracts
CN112887436A (en) * 2021-04-28 2021-06-01 支付宝(杭州)信息技术有限公司 Consensus method, consensus node and block chain system of pipeline mode
CN114529413A (en) * 2022-02-24 2022-05-24 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment
CN114547201A (en) * 2022-02-24 2022-05-27 蚂蚁区块链科技(上海)有限公司 Processing method of block chain transaction, block chain node and electronic equipment

Also Published As

Publication number Publication date
CN114547201A (en) 2022-05-27

Similar Documents

Publication Publication Date Title
WO2023160088A1 (en) Method for processing blockchain transactions, and blockchain node and electronic device
WO2023160092A1 (en) Method for processing blockchain transactions, and blockchain node and electronic device
TWI714847B (en) Method, device and electronic equipment for processing consensus request in blockchain consensus network
US9582334B2 (en) Resource management in MapReduce architecture and architectural system
WO2016011811A1 (en) Memory management method and apparatus, and storage medium
CN113918101B (en) Method, system, equipment and storage medium for writing data cache
CN111324427B (en) Task scheduling method and device based on DSP
CN111142938A (en) Task processing method and task processing device of heterogeneous chip and electronic equipment
WO2023045203A1 (en) Task scheduling method, chip, and electronic device
CN111125013A (en) Data warehousing method, device, equipment and medium
CN103995827A (en) High-performance ordering method for MapReduce calculation frame
CN115099352A (en) Model training system, model training method and device
AU2019241002B2 (en) Transaction processing method and system, and server
US9753769B2 (en) Apparatus and method for sharing function logic between functional units, and reconfigurable processor thereof
CN114218135A (en) Source end flow control method and system based on Redis cache
US20240095172A1 (en) Data packet processing method and appratus
CN110597627A (en) Database operation acceleration device and method based on virtual FPGA
CN114912618A (en) Quantum computing task scheduling method and device and quantum computer operating system
CN104461931A (en) Method for output processing of trace logs of multi-kernel storage device and multi-kernel environment
WO2023160086A1 (en) Transaction processing method of blockchain, blockchain node, and electronic device
CN113867796B (en) Protocol conversion bridge for improving reading performance by using multi-state machine and implementation method
US20220207040A1 (en) Systems, methods, and devices for acceleration of merge join operations
WO2020253575A1 (en) Method and device for determining number of decoder iterations, and storage medium and electronic device
WO2024093280A1 (en) Task management method, apparatus and system, and communication device and storage medium
CN113485805B (en) Distributed computing adjustment method, device and equipment based on heterogeneous acceleration platform

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 22928348

Country of ref document: EP

Kind code of ref document: A1