WO2023160092A1 - 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
WO2023160092A1
WO2023160092A1 PCT/CN2022/135613 CN2022135613W WO2023160092A1 WO 2023160092 A1 WO2023160092 A1 WO 2023160092A1 CN 2022135613 W CN2022135613 W CN 2022135613W WO 2023160092 A1 WO2023160092 A1 WO 2023160092A1
Authority
WO
WIPO (PCT)
Prior art keywords
transactions
batch
consensus
batches
round
Prior art date
Application number
PCT/CN2022/135613
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 WO2023160092A1 publication Critical patent/WO2023160092A1/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.
  • blockchain Due to its advantages of openness, non-tamperability, and decentralization, blockchain is increasingly favored by all walks of life.
  • the processing flow of blockchain transactions 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.
  • 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 is provided, which is applied to blockchain nodes, including:
  • a method for processing blockchain transactions is provided, which is applied to blockchain nodes, including:
  • a blockchain node including:
  • the first transaction collection module collects the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer;
  • 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 transaction collection 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 for which the N round of consensus proposals has not yet been collected;
  • the first transaction execution module performs a transaction execution operation on the first batch of transactions, and if there is a third batch of transactions, the transaction consensus module simultaneously executes the third batch of transactions according to the order of batches in parallel Consensus operation, wherein the third batch of transactions is a batch of transactions for which the N round of consensus proposals have 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 proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  • 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 Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
  • 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 transaction collection 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 for which the N round of consensus proposals has not yet been collected;
  • the second transaction execution module if all batches of transactions proposed by the N-th round of consensus have completed consensus, perform transaction execution operations on all batches of transactions proposed by the N-th round of consensus;
  • the second transaction confirmation module sends the transaction execution results of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
  • the second transaction block writing module executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  • 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 can perform easy collection, transaction consensus, transaction execution, and transaction confirmation in batches for each round of consensus proposals.
  • the execution operations of the previous batch of transactions and the collection operations of the next batch of transactions are also performed, thereby shortening the blockchain transaction time in parallel. Processing time, thereby improving the throughput of the blockchain to 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.
  • the blockchain becomes more and more popular in all walks of life, 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.
  • 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 Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, and N is a positive integer.
  • each blockchain node of the blockchain can uniformly batch all transactions proposed by the N-th round of consensus according to the corresponding transaction initiation time based on the smart contract set in advance. subdivided. Alternatively, according to the order of transactions in the N-th round of consensus proposals, all transactions proposed by the N-th round of consensus are divided into batches.
  • S104 execute the consensus operation on the first batch of transactions, and if there is a second batch of transactions, execute the collection operation of the second batch of transactions in parallel in batch order, the second batch of transactions is the Nth round of consensus proposals that have not been completed Collected batches of 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 proposed by the N round of consensus 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 third batch of transactions in parallel, perform consensus operations on the third batch of transactions in batch order, the third batch of transactions has been collected for the Nth round of consensus proposals Batch transactions that have completed and 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 proposed by the N-th round of consensus 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 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 proposed by the N-th round of consensus 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 proposed by the Nth round of consensus can be recorded in one block.
  • the blockchain nodes can execute collection, transaction consensus, transaction execution, and transaction confirmation in batches for each round of consensus proposals.
  • the execution operations of the previous batch of transactions and the collection operations of the next batch of transactions are also performed, thereby shortening the blockchain transaction time in parallel. Processing time, thereby improving the throughput of the blockchain to 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 feedback strategy for transaction execution results can be determined based on the number of transactions in the N-th round of consensus proposals. For example, when the number of transactions in the N-th round of consensus proposals 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 N-round consensus proposal does not exceed the preset threshold, you can choose to complete the transaction execution and get transaction confirmation for all batches of transactions proposed by the N-round consensus proposal, and then send the N-round consensus proposal The transaction execution results of all batches of transactions are uniformly fed back to the corresponding blockchain client.
  • 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 proposed by each round of consensus are confirmed.
  • each round of consensus proposes that the subsequent batch of transactions cannot be executed earlier than the previous batch of transactions.
  • 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.
  • the transactions proposed by each round of consensus 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 area Processing efficiency of blockchain 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 consensus proposals 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 consensus proposals of round N and round N+1 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 for all batches of transactions proposed in the N-round consensus proposal after all batches of transactions in the N-round consensus proposal have completed consensus .
  • 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 Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions.
  • S404 execute the consensus operation on the first batch of transactions, and if there is a second batch of transactions, execute the collection operation of the second batch of transactions in parallel in batch order, the second batch of transactions is the Nth round of consensus proposals that have not been completed Collected batches of transactions.
  • S408 sending the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the blockchain to perform transaction confirmation on all the batches of transactions proposed by the Nth round of consensus.
  • Fig. 5 is a time slot relationship diagram for the N-th round and the N+1-th round of consensus proposals based on the method shown in Fig. 4 . It should be understood that the execution operations of all batches of transactions proposed by the N-th round of consensus can be performed at least after the execution of all batches of transactions proposed by the N-1 consensus round is completed.
  • the method shown in Figure 4 uses the first thread to collect transactions in batch order for each round of consensus proposals, that is, the first thread does not collect other batches of transactions before collecting one batch of transactions;
  • the round of consensus proposals 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; All batches of transactions are executed uniformly; through the fourth thread, all batches of transactions in each round of consensus proposals are uniformly confirmed; through the fifth thread, all batches of transactions in each round of consensus proposals are uniformly written block operation.
  • 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 Figure 4 can also execute transaction collection and transaction consensus for each round of consensus proposals in batches.
  • the consensus operation is performed on the intermediate batch of transactions proposed by each round of consensus
  • the collection operation of the next batch of transactions is also performed, so that the processing time of the blockchain transaction can also be shortened in parallel, thereby improving the area.
  • the throughput of the block chain can meet the needs of high-concurrency business scenarios.
  • 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 Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
  • the first transaction consensus module 620 executes a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the 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 whose collection has not been completed for the N round of consensus proposals.
  • 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, the transaction consensus module simultaneously executes the third batch of transactions in batch order Consensus operation, wherein, the third batch of transactions is a batch of transactions for which the N round of consensus proposals have 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 proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  • the blockchain nodes in the embodiments of this specification can execute the transaction collection, transaction consensus and transaction execution of each round of consensus proposals in batches. Specifically, while executing the consensus operation on the intermediate batch of transactions, the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions are also performed, thereby shortening the processing time of blockchain transactions in parallel, and further The throughput of the blockchain has been improved to meet the needs of high-concurrency business scenarios.
  • the first transaction collection module 610 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the first transaction collection module 610 executes in parallel the second batch of transactions in batch order collection operation.
  • the first transaction collection module 610 performs batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the first transaction collection module 610 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the first transaction collection module 610 executes the first batch of transactions in batch order Consensus operations on batches of transactions that have been collected but have not yet completed consensus in the N+1 round of consensus proposals.
  • 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 transaction confirmation of all batches of transactions proposed by the consensus round, the transaction execution results of all batches of transactions proposed by the Nth round of consensus are fed back to the corresponding blockchain client.
  • the first transaction collection module 610 collects all batches of transactions in the N-th round of consensus proposals 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 N-th round of consensus proposals through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of a batch of transactions consensus operation.
  • the first transaction execution module 630 executes the execution operations of all batches of transactions in the N-th round consensus proposal through the third thread, and the third thread does not execute other batches before executing the execution operation of one batch of transactions
  • Transaction execution operation: the first transaction confirmation module 640 executes the transaction confirmation of all batches of transactions in the Nth round of consensus proposals 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 consensus proposals 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 in the embodiment of this specification, including:
  • the second transaction collection module 710 collects the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
  • 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, the transaction collection 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 the N round of consensus proposals have not yet completed collection;
  • the second transaction execution module 730 if all batches of transactions proposed by the N-th round of consensus have completed consensus, perform transaction execution operations on all batches of transactions proposed by the N-th round of consensus;
  • the second transaction confirmation module 740 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 second transaction block writing module 750 executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  • the second transaction collection module 710 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the second transaction collection module 710 executes in parallel the processing of the second batch of transactions in batch order collection operation.
  • the second transaction collection module 710 performs batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the second transaction collection module 710 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
  • the second transaction collection module 710 executes the batch order Consensus operations on batches of transactions that have been collected but have not yet completed consensus in the N+1 round of consensus proposals.
  • 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 proposed by the Nth round of consensus, feeds back the transaction execution results of all batches of transactions proposed by the Nth round of consensus to the corresponding blockchain client end.
  • the second transaction collection module 710 collects all batches of transactions in the N-th round of consensus proposals 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 proposals through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of a batch of transactions consensus operation.
  • the second transaction execution module 730 executes the execution operation of all batches of transactions in the Nth round of consensus proposals through the third thread; the second transaction confirmation module 740 executes all batches of transactions in the Nth round of consensus proposals through the fourth thread Transaction confirmation for batch transactions.
  • the second transaction block writing module 750 executes block writing operations on all batches of transactions in the N-th round of consensus proposals 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 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 transaction execution results of all batches of transactions proposed by the Nth round of consensus are sent in the block chain to perform transaction confirmation on all batches of transactions proposed by the Nth round of consensus.
  • 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 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 transaction execution results of all batches of transactions proposed by the Nth round of consensus are sent in the block chain to perform transaction confirmation on all batches of transactions proposed by the Nth round of consensus.
  • 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.

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, which are involved in an Nth round of consensus proposal, of a blockchain; executing a consensus operation on the first batch of transactions, and if there is a second batch of transactions, executing, in parallel, a collection operation on the second batch of transactions according to a batch sequence, wherein the second batch of transactions is a batch of transactions which have not been collected in the Nth round of consensus proposal; performing a transaction execution operation on the first batch of transactions, and if there is a third batch of transactions, executing, in parallel, a consensus operation on the third batch of transactions according to the batch sequence, wherein the third batch of transactions is a batch of transactions which have been collected in the Nth round of consensus proposal and have not been subjected to consensus; sending in the blockchain a transaction execution result of the first batch of transactions, so as to perform transaction confirmation on the first batch of transactions; and after the transaction confirmations of all batches of transactions in the Nth round of consensus proposal are obtained, executing a block writing operation on all the batches of transactions in the Nth round of consensus proposal.

Description

一种区块链交易的处理方法、区块链节点及电子设备A processing method of block chain transaction, block chain node and electronic equipment
本申请要求于2022年2月24日提交中国专利局、申请号为202210176770.6、发明名称为“一种区块链交易的处理方法、区块链节点及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the China Patent Office on February 24, 2022, with the application number 202210176770.6, 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 blockchain transactions 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 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, which is applied to blockchain nodes, including:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
第二方面,提供一种区块链交易的处理方法,应用于区块链节点,包括:In the second aspect, a method for processing blockchain transactions is provided, which is applied to blockchain nodes, including:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
第三方面,提供一种区块链节点,包括:In the third aspect, a blockchain node is provided, including:
第一交易收集模块,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;The first transaction collection module collects the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer;
第一交易共识模块,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 transaction collection 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 for which the N round of consensus proposals has not yet been collected;
第一交易执行模块,对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易,则所述交易共识模块同时并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;The first transaction execution module performs a transaction execution operation on the first batch of transactions, and if there is a third batch of transactions, the transaction consensus module simultaneously executes the third batch of transactions according to the order of batches in parallel Consensus operation, wherein the third batch of transactions is a batch of transactions for which the N round of consensus proposals have 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;
第一交易写块模块,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The first transaction block writing module executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
第四方面,提供一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行: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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
第五方面,提供一种算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤: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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第 三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
第六方面,提供一种区块链节点,包括:In the sixth aspect, a blockchain node is provided, including:
第二交易收集模块,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;The second transaction collection module collects the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
第二交易共识模块,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 transaction collection 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 for which the N round of consensus proposals has not yet been collected;
第二交易执行模块,如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;The second transaction execution module, if all batches of transactions proposed by the N-th round of consensus have completed consensus, perform transaction execution operations on all batches of transactions proposed by the N-th round of consensus;
第二交易确认模块,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;The second transaction confirmation module sends the transaction execution results of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
第二交易写块模块,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The second transaction block writing module executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
第七方面,提供一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行: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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
第八方面,提供一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤: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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
基于本说明书实施例的方案,区块链节点可以对每轮共识提议分批次执行易收集、交易共识、交易执行以及交易确认。特别是在对每轮共识提议的中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间,进而提高了区块链的吞吐量,以满足业务高并发场景的需求。Based on the solutions in the embodiments of this specification, the blockchain nodes can perform easy collection, transaction consensus, transaction execution, and transaction confirmation in batches for each round of consensus proposals. In particular, while performing consensus operations on the intermediate batch of transactions proposed by each round of consensus, the execution operations of the previous batch of transactions and the collection operations of the next batch of transactions are also performed, thereby shortening the blockchain transaction time in parallel. Processing time, thereby improving the throughput of the blockchain to 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. 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,收集区块链的第N轮共识提议中的第一批次交易,第N轮共识提议中包括多个批次交易,N为正整数。S102. Collect the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, and N is a positive integer.
需要说明的是,本文不对第N轮共识提议的交易批次划分逻辑作具体限定。但凡是将第N轮共识提议中的交易划分成多个批次的方案都应属于本说明书实施例的保护范围。It should be noted that this article does not specifically limit the transaction batch division logic proposed by the N-th round of consensus. However, any scheme that divides the transactions in the N-th round of consensus proposals into multiple batches shall fall within the scope of protection of the embodiments of this specification.
作为示例性介绍:本说明书实施例中,区块链的各区块链节点可以基于提前设定好的智能合约,统一将第N轮共识提议的所有交易按照对应的交易发起时间进行有序的批次划分。或者,按照第N轮共识提议中的交易顺序,对第N轮共识提议的所有交易进行批次划分。As an exemplary introduction: In the embodiment of this specification, each blockchain node of the blockchain can uniformly batch all transactions proposed by the N-th round of consensus according to the corresponding transaction initiation time based on the smart contract set in advance. subdivided. Alternatively, according to the order of transactions in the N-th round of consensus proposals, all transactions proposed by the N-th round of consensus are divided into batches.
S104,对第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对第二批次交易的收集操作,第二批次交易为第N轮共识提议尚未完成收集的批次交易。S104, execute the consensus operation on the first batch of transactions, and if there is a second batch of transactions, execute the collection operation of the second batch of transactions in parallel in batch order, the second batch of transactions is the Nth round of consensus proposals that have not been completed Collected batches of 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.
本说明书实施例中,区块链节点分批收集第N轮共识提议的交易。在收集完成目标批次交易后,即可同时执行:目标批次交易的共识执行操作以及目标批次交易对应的下一批次交易的收集操作。也就是说,本步骤所述的第二批次交易是指第一批次交易的下一批次交易。In the embodiment of this specification, the blockchain nodes collect the transactions proposed by the N round of consensus 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,对第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序对第三批次交易的共识操作,第三批次交易为第N轮共识提议已经收集完毕且尚未完成共识的批次交易。S106, perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions in parallel, perform consensus operations on the third batch of transactions in batch order, the third batch of transactions has been collected for the Nth round of consensus proposals Batch transactions that have completed and 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.
同理,本说明书实施例中,区块链节点分批对第N轮共识提议的交易执行共识操作。在执行完成目标批次交易的共识操作后,即可同时执行:目标批次交易的执行操作以及目标批次交易对应的下一批次交易的共识操作。也就是说,本步骤所述的第三批次交易是指第二批次交易的下一批次交易。Similarly, in the embodiment of this specification, the blockchain nodes perform consensus operations on the transactions proposed by the N-th round of consensus 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.
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,在得到第N轮共识提议的所有批次交易的交易确认后,对第N轮共识提议的所有批次交易执行写块操作。S110. After obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus, perform a block writing operation on all the batches of transactions proposed by the N-th round of consensus.
应理解,本说明书实施例中,区块链节点对第N轮共识提议的交易分批次进行共识操作,但最终可以只执行一次写块操作。也就是说本说明书实施例中,第N轮共识提议的所有批次交易可以通过一个区块进行记录。It should be understood that in the embodiment of this specification, the blockchain nodes perform consensus operations on the transactions proposed by the N-th round of consensus 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 proposed by the Nth round of consensus can be recorded in one block.
基于本说明书实施例的方法,区块链节点可以对每轮共识提议分批次执行易收集、交易共识、交易执行以及交易确认。特别是在对每轮共识提议的中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间,进而提高了区块链的吞吐量,以满足业务高并发场景的需求。Based on the method in the embodiment of this specification, the blockchain nodes can execute collection, transaction consensus, transaction execution, and transaction confirmation in batches for each round of consensus proposals. In particular, while performing consensus operations on the intermediate batch of transactions proposed by each round of consensus, the execution operations of the previous batch of transactions and the collection operations of the next batch of transactions are also performed, thereby shortening the blockchain transaction time in parallel. Processing time, thereby improving the throughput of the blockchain to 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.
或者,为了降低与区块链客户端侧交互的资源开销,也可以在得到第N轮共识提议的所有批次交易的交易确认后,再将第N轮共识提议的所有批次交易的交易执行结果统一反馈至对应的区块链客户端。Or, in order to reduce the resource overhead of interacting with the blockchain client side, it is also possible to execute all batches of transactions proposed by the N-round consensus after the transaction confirmation of all batches of transactions proposed by the N-round consensus The results are uniformly fed back to the corresponding blockchain client.
在实际应用中,可以针对第N轮共识提议中的交易数量,决定交易执行结果的反馈策略。比如,当第N轮共识提议中的交易数量超出预设阈值时,则可以选择在每个批次交易完成交易执行并得到交易确认后,立刻将交易执行结果反馈至的区块链客户端。同理,当第N轮共识提议中的交易数量未超出预设阈值时,则可以选择在第N轮共识提议的所有批次交易完成交易执行并得到交易确认后,再将第N轮共识提议的所有批次交易的交易执行结果统一反馈至对应的区块链客户端。In practical applications, the feedback strategy for transaction execution results can be determined based on the number of transactions in the N-th round of consensus proposals. For example, when the number of transactions in the N-th round of consensus proposals 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 N-round consensus proposal does not exceed the preset threshold, you can choose to complete the transaction execution and get transaction confirmation for all batches of transactions proposed by the N-round consensus proposal, and then send the N-round consensus proposal The transaction execution results of all batches of transactions are uniformly fed back to the corresponding blockchain client.
此外,还应理解的是,本说明书实施例的方法可以连续处理多轮共识提议的交易。In addition, it should also be understood that the method in this embodiment of the specification can continuously process multiple rounds of consensus-proposed transactions.
下面以本说明书实施例方法连续处理第N轮和第N+1轮的共识提议中的交易为示例,对工作原理进行详细介绍。In the following, the working principle will be described in detail by taking the continuous processing of the transaction in the consensus proposal of the Nth round and the N+1 round as an example of the embodiment method of this specification.
参考图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 proposed by each round of consensus 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 consensus proposals 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 consensus proposals of round N and round N+1 can be presented as shown in Figure 2. time slot relationship.
从图2可以看出:It can be seen from Figure 2:
如果在对第一批次交易执行共识操作时,第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals are collected when the consensus operation is performed on the first batch of transactions, then the collection operation of the batches of transactions in the N+1th round of consensus proposals 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 operation of collecting the second batch of transactions in batch order is executed in parallel.
如果对第一批次交易进行交易执行操作时,第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals 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 N+1th round of consensus proposals is performed in batch order .
如果对第一批次交易进行交易执行操作时,第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when executing the transaction execution operation on the first batch of transactions, then execute the collected but not yet completed consensus in the order of batches in the N+1th round of consensus proposals Consensus operation of batch transactions.
如果对所述第一批次交易进行写块操作时,第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals have been collected when the first batch of transactions is written to the block, then the batch transactions in the N+1th round of consensus proposals are executed in batch order. Collect operations.
如果对第一批次交易进行写块操作时,第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when writing blocks for the first batch of transactions, then perform consensus on the collected but not yet completed consensus transactions in the N+1th round of consensus proposals in batch order. Consensus operation of batch 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, each round of consensus proposes that the subsequent batch of transactions 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 proposed by each round of consensus 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 area Processing efficiency of blockchain 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 consensus proposals 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 consensus proposals of round N and round N+1 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 for all batches of transactions proposed in the N-round consensus proposal after all batches of transactions in the N-round consensus proposal 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,收集区块链的第N轮共识提议中的第一批次交易,第N轮共识提议中包括多个批次交易。S402. Collect the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions.
S404,对第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对第二批次交易的收集操作,第二批次交易为第N轮共识提议尚未完成收集的批次交易。S404, execute the consensus operation on the first batch of transactions, and if there is a second batch of transactions, execute the collection operation of the second batch of transactions in parallel in batch order, the second batch of transactions is the Nth round of consensus proposals that have not been completed Collected batches of transactions.
S406,如果第N轮共识提议的所有批次交易都完成共识,对第N轮共识提议的所有批次交易进行交易执行操作。S406. If all batches of transactions proposed by the Nth round of consensus have completed the consensus, execute a transaction execution operation on all batches of transactions proposed by the Nth round of consensus.
S408,在区块链中发送第N轮共识提议的所有批次交易的交易执行结果以对第N轮共识提议的所有批次交易进行交易确认。S408, sending the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the blockchain to perform transaction confirmation on all the batches of transactions proposed by the Nth round of consensus.
S410,在得到第N轮共识提议的所有批次交易的交易确认后,对第N轮共识提议的所有批次交易执行写块操作。S410. After obtaining the transaction confirmations of all the batches of transactions proposed by the Nth round of consensus, perform a block writing operation on all the batches of transactions proposed by the Nth round of consensus.
图5是基于图4所示的方法进行第N轮和第N+1轮共识提议的时隙关系图。应理解,第N轮共识提议的所有批次交易的执行操作至少要在第N-1轮共识提议的所有批次交易的执行操作完成后才能执行。Fig. 5 is a time slot relationship diagram for the N-th round and the N+1-th round of consensus proposals based on the method shown in Fig. 4 . It should be understood that the execution operations of all batches of transactions proposed by the N-th round of consensus can be performed at least after the execution of all batches of transactions proposed by the N-1 consensus round is completed.
同理,图4所示的方法通过第一线程对每轮共识提议按批次顺序收集交易,也就是第一线程在收集完一个批次交易之前不收集其它批次交易;通过二线程对每轮共识提议按批次顺序执行交易的共识操作,也就是第二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作;通过第三线程对每轮共识提议中的所有批次交易统一进行交易执行操作;通过第四线程执行对每轮共识提议中的所有批次交易统一进行交易确认;通过第五线程执行对每轮共识提议中的所有批次交易统一进行写块操作。这里,第一线程、第二线程、第三线程和第四线程和第五线程为并行执行的线程。Similarly, the method shown in Figure 4 uses the first thread to collect transactions in batch order for each round of consensus proposals, that is, the first thread does not collect other batches of transactions before collecting one batch of transactions; The round of consensus proposals 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; All batches of transactions are executed uniformly; through the fourth thread, all batches of transactions in each round of consensus proposals are uniformly confirmed; through the fifth thread, all batches of transactions in each round of consensus proposals are uniformly written block operation. 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 Nth round of consensus proposals are collected when the consensus operation is performed on the first batch of transactions, then the collection operation of the batches of transactions in the N+1th round of consensus proposals 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 Nth round of consensus proposals 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 N+1th round of consensus proposals is performed in batch order .
如果对第一批次交易进行交易执行操作时,第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when executing the transaction execution operation on the first batch of transactions, then execute the collected but not yet completed consensus in the order of batches in the N+1th round of consensus proposals Consensus operation of batch transactions.
如果对第一批次交易进行写块操作时,第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals have been collected when the first batch of transactions is written, then the collection of batches of transactions in the N+1st round of consensus proposals will be performed in batch order .
如果对第一批次交易进行写块操作时,第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when writing blocks for the first batch of transactions, then perform consensus on the collected but not yet completed consensus transactions in the N+1th round of consensus proposals in batch order. Consensus operation of batch transactions.
由此可见,图4所示的方法也可以分批次执行每轮共识提议的交易收集、交易共识。特别是在对每轮共识提议的中间批次交易执行共识操作的同时,还执行下一批次交易的收集操作,从而也可以通过并行方式缩短了区块链交易的处理时间,进而提高了区块链的吞吐量,以满足业务高并发场景的需求。It can be seen that the method shown in Figure 4 can also execute transaction collection and transaction consensus for each round of consensus proposals in batches. In particular, while the consensus operation is performed on the intermediate batch of transactions proposed by each round of consensus, the collection operation of the next batch of transactions is also performed, so that the processing time of the blockchain transaction can also be shortened in parallel, thereby improving the area. The throughput of the block chain can meet the needs of high-concurrency business scenarios.
此外,与上述图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,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数。The first transaction collection module 610 collects the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
第一交易共识模块620,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易。The first transaction consensus module 620 executes a consensus operation on the first batch of transactions, and if there is a second batch of transactions, the 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 whose collection has not been completed for the N round of consensus proposals.
第一交易执行模块630,对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易,则所述交易共识模块同时并行执行按批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;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, the transaction consensus module simultaneously executes the third batch of transactions in batch order Consensus operation, wherein, the third batch of transactions is a batch of transactions for which the N round of consensus proposals have 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,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The first transaction block writing module 650 executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
本说明书实施例的区块链节点可以分批次执行每轮共识提议的交易收集、交易共识以及交易执行。具体地,在对中间批次交易执行共识操作的同时,还执行上一批次交易的执行操作以及下一批次交易的收集操作,从而通过并行方式缩短了区块链交易的处理时间,进而提高了区块链的吞吐量,以满足业务高并发场景的需求。The blockchain nodes in the embodiments of this specification can execute the transaction collection, transaction consensus and transaction execution of each round of consensus proposals in batches. Specifically, while executing the consensus operation on the intermediate batch of transactions, the execution operation of the previous batch of transactions and the collection operation of the next batch of transactions are also performed, thereby shortening the processing time of blockchain transactions in parallel, and further The throughput of the blockchain has been improved to meet the needs of high-concurrency business scenarios.
可选地,如果在对所述第一批次交易执行共识操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the consensus operation is performed on the first batch of transactions, the first transaction collection module 610 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则第一交易收集模块610并行执行按批次顺序对所述第二批次交易的收集操作。Optionally, 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 in parallel the second batch of transactions in batch order collection operation.
可选地,如果对所述第一批次交易进行交易执行操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the transaction execution operation is performed on the first batch of transactions, then the first transaction collection module 610 performs batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第一交易收集模块610执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the block writing operation is performed on the first batch of transactions, then the first transaction collection module 610 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都共识完毕,则第一交易收集模块610执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have completed the consensus when performing block writing operations on the first batch of transactions, then the first transaction collection module 610 executes the first batch of transactions in batch order Consensus operations on batches of transactions that have been collected but have not yet completed consensus in the N+1 round of consensus proposals.
可选地,第一交易确认模块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 transaction confirmation of all batches of transactions proposed by the consensus round, the transaction execution results of all batches of transactions proposed by the Nth round of consensus 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 N-th round of consensus proposals 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 N-th round of consensus proposals through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of a batch of transactions consensus operation. The first transaction execution module 630 executes the execution operations of all batches of transactions in the N-th round consensus proposal through the third thread, and the third thread does not execute other batches before executing the execution operation of one batch of transactions Transaction execution operation: the first transaction confirmation module 640 executes the transaction confirmation of all batches of transactions in the Nth round of consensus proposals 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 consensus proposals 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 in the embodiment of this specification, including:
第二交易收集模块710,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;The second transaction collection module 710 collects the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
第二交易共识模块720,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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, the transaction collection 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 the N round of consensus proposals have not yet completed collection;
第二交易执行模块730,如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;The second transaction execution module 730, if all batches of transactions proposed by the N-th round of consensus have completed consensus, perform transaction execution operations on all batches of transactions proposed by the N-th round of consensus;
第二交易确认模块740,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;The second transaction confirmation module 740, 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;
第二交易写块模块750,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The second transaction block writing module 750 executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
可选地,如果在对所述第一批次交易执行共识操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the consensus operation is performed on the first batch of transactions, the second transaction collection module 710 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果在对所述第一批次交易进行交易执行操作时,存在所述第二批次交易,则第二交易收集模块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 executes in parallel the processing of the second batch of transactions in batch order collection operation.
可选地,如果对所述第一批次交易进行交易执行操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the transaction execution operation is performed on the first batch of transactions, then the second transaction collection module 710 performs batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have been collected when the block writing operation is performed on the first batch of transactions, then the second transaction collection module 710 executes the batch order The collection operation of batch transactions in N+1 rounds of consensus proposals.
可选地,如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都共识完毕,则第二交易收集模块710执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。Optionally, if all batches of transactions in the Nth round of consensus proposals have completed the consensus when performing block writing operations on the first batch of transactions, then the second transaction collection module 710 executes the batch order Consensus operations on batches of transactions that have been collected but have not yet completed consensus in the N+1 round of consensus proposals.
可选地,第二交易确认模块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 proposed by the Nth round of consensus, feeds back the transaction execution results of all batches of transactions proposed by the Nth round of consensus to the corresponding blockchain client end.
可选地,第二交易收集模块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 proposals 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 proposals through the second thread, and the second thread does not execute other batches of transactions before completing the consensus operation of a batch of transactions consensus operation. The second transaction execution module 730 executes the execution operation of all batches of transactions in the Nth round of consensus proposals through the third thread; the second transaction confirmation module 740 executes all batches of transactions in the Nth round of consensus proposals through the fourth thread Transaction confirmation for batch transactions. The second transaction block writing module 750 executes block writing operations on all batches of transactions in the N-th round of consensus proposals 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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数。Collecting the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易。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 yet been collected for the N round of consensus proposals.
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易。Perform transaction execution operations on the first batch of transactions, and execute consensus operations on the third batch of transactions in parallel if there is a third batch of transactions, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected and consensus has not yet been completed.
在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认。Sending the transaction execution results of the first batch of transactions in the block chain to perform transaction confirmation on the first batch of transactions.
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
可选地,处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成区块链交易的处理装置,该处理装置可以作为图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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数。Collecting the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易。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 yet been collected for the N round of consensus proposals.
如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作。If all batches of transactions proposed by the Nth round of consensus have completed the consensus, a transaction execution operation is performed on all batches of transactions proposed by the Nth round of consensus.
在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认。The transaction execution results of all batches of transactions proposed by the Nth round of consensus are sent in the block chain to perform transaction confirmation on all batches of transactions proposed by the Nth round of consensus.
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
上述如本说明书图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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数。Collecting the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易。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 yet been collected for the N round of consensus proposals.
对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易。Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected and consensus has not yet been completed.
在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认。Sending the transaction execution results of the first batch of transactions in the block chain to perform transaction confirmation on the first batch of transactions.
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
可选地,上述指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图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:
收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数。Collecting the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer.
对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易。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 yet been collected for the N round of consensus proposals.
如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作。If all batches of transactions proposed by the Nth round of consensus have completed the consensus, a transaction execution operation is performed on all batches of transactions proposed by the Nth round of consensus.
在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认。The transaction execution results of all batches of transactions proposed by the Nth round of consensus are sent in the block chain to perform transaction confirmation on all batches of transactions proposed by the Nth round of consensus.
在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
应理解,上述指令当被包括多个应用程序的便携式电子设备执行时,能够使图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 (18)

  1. 一种区块链交易的处理方法,应用于区块链节点,包括:A method for processing blockchain transactions, applied to blockchain nodes, comprising:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and execute consensus operations on the third batch of transactions in parallel if there is a third batch of transactions, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
  2. 如权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    如果在对所述第一批次交易执行共识操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals have been collected when the consensus operation is performed on the first batch of transactions, the batches in the N+1th round of consensus proposals are executed in batch order The collection operation for the transaction.
  3. 如权利要求1所述的方法,还包括:The method of 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.
  4. 如权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    如果对所述第一批次交易进行交易执行操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals have been collected when the transaction execution operation is performed on the first batch of transactions, the batches in the N+1th round of consensus proposals are executed in batch order The collection operation for the transaction.
  5. 如权利要求4所述的方法,还包括:The method of claim 4, further comprising:
    如果对所述第一批次交易进行交易执行操作时,所述第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when the transaction execution operation is performed on the first batch of transactions, then the collected But the consensus operation of the batch transaction that has not yet completed the consensus.
  6. 如权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都收集完毕,则执行按批次顺序对第N+1轮共识提议中的批次交易的收集操作。If all batches of transactions in the Nth round of consensus proposals have been collected when the first batch of transactions is written, the batches in the N+1th round of consensus proposals are executed in batch order The collection operation for the transaction.
  7. 如权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    如果对所述第一批次交易进行写块操作时,所述第N轮共识提议中的所有批次交易都共识完毕,则执行按批次顺序对第N+1轮共识提议中的已收集但尚未完成共识的批次交易的共识操作。If all batches of transactions in the Nth round of consensus proposals have completed the consensus when performing the block writing operation on the first batch of transactions, then the collected transactions in the N+1th round of consensus proposals will be executed in batch order. But the consensus operation of the batch transaction that has not yet completed the consensus.
  8. 如权利要求1所述的方法,还包括:The method of claim 1, further comprising:
    在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认,包括: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.
  9. 如权利要求1所述的方法,还包括:The method of claim 1, 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,
    在得到所述第N轮共识提议的所有批次交易的交易确认后,将所述第N轮共识提议的所有批次交易的交易执行结果反馈至对应的区块链客户端。After obtaining the transaction confirmations of all batches of transactions proposed by the Nth round of consensus, the transaction execution results of all batches of transactions proposed by the Nth round of consensus are fed back to the corresponding blockchain client.
  10. 如权利要求1所述的方法,The method of claim 1,
    通过第一线程收集所述第N轮共识提议中的所有批次交易,所述第一线程在收集完一个批次交易之前不收集其它批次交易;Collect all batches of transactions in the Nth round of consensus proposals through the first thread, and the first thread does not collect other batches of transactions before collecting one batch of transactions;
    通过第二线程执行对所述第N轮共识提议中的所有批次交易的共识操作,所述二线程在执行完一个批次交易的共识操作之前不执行其它批次交易的共识操作;Execute consensus operations on all batches of transactions in the Nth round of consensus proposals through the second thread, and the second thread does not perform consensus operations on other batches of transactions before completing the consensus operations on one batch of transactions;
    通过第三线程执行对所述第N轮共识提议中的所有批次交易的执行操作,所述第三线程在执行完一个批次交易的执行操作之前不执行其它批次交易的执行操作;Execute the execution operations of all batches of transactions in the Nth round consensus proposal through the third thread, and the third thread does not execute the execution operations of other batches of transactions before executing the execution operations of one batch of transactions;
    通过第四线程执行所述第N轮共识提议中的所有批次交易的交易确认;Execute the transaction confirmation of all batches of transactions in the Nth round consensus proposal through the fourth thread;
    通过第五线程执行对所述第N轮共识提议中的所有批次交易执行写块操作;Execute block write operations on all batches of transactions in the Nth round of consensus proposals 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.
  11. 如权利要求10所述的方法,The method of claim 10,
    在所述第一线程收集完所述第一批次交易之后,通知所述第二线程对所述第一批次交易进行共识操作;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.
  12. 一种区块链交易的处理方法,应用于区块链节点,包括:A method for processing blockchain transactions, applied to blockchain nodes, comprising:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
    在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
  13. 一种区块链节点,包括:A blockchain node, comprising:
    第一交易收集模块,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;The first transaction collection module collects the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer;
    第一交易共识模块,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 transaction collection module simultaneously executes the collection of the second batch of transactions in batch order in parallel Operation, wherein, the second batch of transactions is a batch of transactions that the N round of consensus proposals has not yet completed collection;
    第一交易执行模块,对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易,则所述交易共识模块同时并行执行按批次顺序对所述第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;The first transaction execution module performs a transaction execution operation on the first batch of transactions, and if there is a third batch of transactions, the transaction consensus module simultaneously executes the third batch of transactions in batch order in parallel Consensus operation, wherein the third batch of transactions is a batch of transactions for which the N round of consensus proposals have 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;
    第一交易写块模块,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The first transaction block writing module executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  14. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行: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:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
  15. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤: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:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    对所述第一批次交易进行交易执行操作,以及如果存在第三批次交易并行执行按批次顺序所述对第三批次交易的共识操作,其中,所述第三批次交易为所述第N轮共识提议已经收集完毕且尚未完成共识的批次交易;Perform transaction execution operations on the first batch of transactions, and if there is a third batch of transactions, execute in parallel the consensus operations on the third batch of transactions in batch order, wherein the third batch of transactions is all Batches of transactions whose consensus proposals for the Nth round have been collected but have 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;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交 易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the Nth round of consensus, perform block write operations on all batches of transactions proposed by the Nth round of consensus.
  16. 一种区块链节点,包括:A blockchain node, comprising:
    第二交易收集模块,收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;The second transaction collection module collects the first batch of transactions in the Nth round of consensus proposals of the blockchain, where the Nth round of consensus proposals includes multiple batches of transactions, where N is a positive integer;
    第二交易共识模块,对所述第一批次交易执行共识操作,以及如果存在第二批次交易,则所述交易收集模块同时并行执行按批次顺序对第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 transaction collection 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 for which the N round of consensus proposals has not yet been collected;
    第二交易执行模块,如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;The second transaction execution module, if all batches of transactions proposed by the N-th round of consensus have completed consensus, perform transaction execution operations on all batches of transactions proposed by the N-th round of consensus;
    第二交易确认模块,在所述区块链中发送所述第一批次交易的交易执行结果以对所述第一批次交易进行交易确认;The second transaction confirmation module sends the transaction execution results of the first batch of transactions in the block chain to confirm the transaction of the first batch of transactions;
    第二交易写块模块,在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。The second transaction block writing module executes a block writing operation on all batches of transactions proposed by the N-th round of consensus after obtaining the transaction confirmations of all the batches of transactions proposed by the N-th round of consensus.
  17. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行: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:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
    在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
  18. 一种计算机可读存储介质,所述计算机可读存储介质上存储有计算机程序,所述计算机程序被处理器执行时实现如下步骤: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:
    收集区块链的第N轮共识提议中的第一批次交易,所述第N轮共识提议中包括多个批次交易,其中,N为正整数;Collect the first batch of transactions in the Nth round consensus proposal of the blockchain, where the Nth round consensus proposal includes multiple batches of transactions, where N is a positive integer;
    对所述第一批次交易执行共识操作,以及如果存在第二批次交易则并行执行按批次顺序对所述第二批次交易的收集操作,其中,所述第二批次交易为所述第N轮共识提议尚未完成收集的批次交易;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 yet been collected for the N round of consensus proposals;
    如果所述第N轮共识提议的所有批次交易都完成共识,对所述第N轮共识提议的所有批次交易进行交易执行操作;If all batches of transactions proposed by the Nth round of consensus have completed the consensus, perform a transaction execution operation on all batches of transactions proposed by the Nth round of consensus;
    在所述区块链中发送所述第N轮共识提议的所有批次交易的交易执行结果以对所述第N轮共识提议的所有批次交易进行交易确认;Send the transaction execution results of all batches of transactions proposed by the Nth round of consensus in the block chain to confirm the transactions of all batches of transactions proposed by the Nth round of consensus;
    在得到所述第N轮共识提议的所有批次交易的交易确认后,对所述第N轮共识提议的所有批次交易执行写块操作。After obtaining the transaction confirmations of all batches of transactions proposed by the N-th round of consensus, perform a block write operation on all batches of transactions proposed by the N-th round of consensus.
PCT/CN2022/135613 2022-02-24 2022-11-30 Method for processing blockchain transactions, and blockchain node and electronic device WO2023160092A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210176770.6 2022-02-24
CN202210176770.6A CN114529413A (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
WO2023160092A1 true WO2023160092A1 (en) 2023-08-31

Family

ID=81624334

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135613 WO2023160092A1 (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) CN114529413A (en)
WO (1) WO2023160092A1 (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
CN114529413A (en) 2022-05-24

Similar Documents

Publication Publication Date Title
WO2023160092A1 (en) Method for processing blockchain transactions, and blockchain node and electronic device
WO2023160088A1 (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
WO2022105805A1 (en) Data processing method and in-memory computing chip
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
JP2008198202A (en) Memory system and command handling method thereof
US11537453B2 (en) Multithreaded lossy queue protocol
WO2020168933A1 (en) Network request processing method, device, terminal and storage medium
US20190007529A1 (en) Methods and systems for autonomous memory
WO2023045203A1 (en) Task scheduling method, chip, and electronic device
CN111142938A (en) Task processing method and task processing device of heterogeneous chip and electronic equipment
CN109213828B (en) Block generation method, device, equipment and storage medium
US10277246B2 (en) Program counter compression method and hardware circuit thereof
CN103995827A (en) High-performance ordering method for MapReduce calculation frame
US20240095172A1 (en) Data packet processing method and appratus
AU2019241002B2 (en) Transaction processing method and system, and server
CN111399911A (en) Artificial intelligence development method and device based on multi-core heterogeneous computation
CN114218135A (en) Source end flow control method and system based on Redis cache
US20130074086A1 (en) Pipelining protocols in misaligned buffer cases
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
WO2020253575A1 (en) Method and device for determining number of decoder iterations, and storage medium and electronic device
CN112433672B (en) Solid state disk reading method and device

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

Country of ref document: EP

Kind code of ref document: A1