WO2022166673A1 - Transaction processing method and apparatus in blockchain, and electronic device - Google Patents

Transaction processing method and apparatus in blockchain, and electronic device Download PDF

Info

Publication number
WO2022166673A1
WO2022166673A1 PCT/CN2022/073652 CN2022073652W WO2022166673A1 WO 2022166673 A1 WO2022166673 A1 WO 2022166673A1 CN 2022073652 W CN2022073652 W CN 2022073652W WO 2022166673 A1 WO2022166673 A1 WO 2022166673A1
Authority
WO
WIPO (PCT)
Prior art keywords
block
transaction
consensus
blockchain
nth
Prior art date
Application number
PCT/CN2022/073652
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 WO2022166673A1 publication Critical patent/WO2022166673A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5027Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resource being a machine, e.g. CPUs, Servers, Terminals
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5061Partitioning or combining of resources
    • 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
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5011Pool
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F2209/00Indexing scheme relating to G06F9/00
    • G06F2209/50Indexing scheme relating to G06F9/50
    • G06F2209/5018Thread allocation

Definitions

  • This document relates to the field of blockchain technology, in particular to a method, device and electronic device for transaction processing in the blockchain.
  • the process of transaction processing can be shown in Figure 1, including the following four stages: collecting transactions ⁇ consensus ⁇ transaction execution ⁇ writing blocks. After the above process, a block can be generated. After a block (the Nth block in Figure 1) is generated, the transaction processing flow of the next block (the N+1th block in Figure 1) is entered.
  • the transaction processing flow of a block in a blockchain system consists of four stages. After the Nth block is generated, the transaction processing flow of the N+1th block is entered. With this transaction processing method, at any point in time, the consensus node can only process one stage corresponding to one block. This method cannot make good use of the processing resources of nodes. For example, it cannot make good use of the parallel computing characteristics of multiple cores, and it is difficult to improve the performance of the blockchain system.
  • Figure 1 shows the general process of transaction processing by consensus nodes in a blockchain system.
  • not all consensus nodes perform the transaction collection operations in the above four phases.
  • master consensus algorithms such as Practical Byzantine Fault Tolerance, PBFT, Practical Byzantine Fault Tolerance Algorithm
  • the consensus master node can perform the above four-stage operations, and the consensus non-master nodes can perform consensus ⁇ transaction execution ⁇ The operations of these three stages of writing blocks; it can also be that each consensus node performs all the operations of the above four stages.
  • the Chinese patent application publication number CN111522648A discloses a transaction processing method.
  • the block chain node executes the block writing operation of the Nth round of transactions and the consensus execution operation of the N+1th round of transactions in parallel.
  • a representative embodiment may be shown in Figure 2 (also Figure 2 of Patent Application Publication No. CN111522648A). As shown in Figure 2, the first thread and the second thread can be executed in parallel.
  • the second thread can execute the block writing operation of the N-1 round of transactions in parallel;
  • the second thread can perform the block writing operation of the Nth round of transactions in parallel; while the first thread performs N+2 rounds of consensus and transaction execution, the second thread can The block write operation of the N+1 round of transactions is performed in parallel.
  • the above examples are mainly aimed at the situation that the consensus stage and the transaction execution stage take a relatively short time in the transaction processing process of the blockchain system, and the block writing stage takes a relatively long time.
  • transactions collected in a certain round may include ordinary transfer transactions or transactions involving smart contracts.
  • the processing time is generally relatively short, while for transactions involving smart contracts, the contract logic may be more complicated, or there may be many transactions involving contracts, so the processing time is relatively long.
  • the processing time of the transaction execution link may be longer than that of the consensus link, and is closer to the processing time of the block writing operation. Even longer processing time than write block operations. In this way, only (consensus + transaction execution) and block writing are decoupled in this example, and there is still room for further optimization.
  • the embodiments of this specification provide a transaction processing method, device, and electronic device in a blockchain.
  • a transaction processing method in a blockchain comprising: a blockchain node executing a transaction execution operation corresponding to an Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in a blockchain system; In the process of executing the transaction execution operation corresponding to the Nth block, the blockchain node executes the consensus operation on the transaction corresponding to the N+1th block in parallel, where N is a positive integer.
  • a transaction processing device applied to a blockchain node comprising: a transaction execution module that executes a transaction execution operation corresponding to an Nth block, wherein the transaction corresponding to the Nth block has been reached in a blockchain system Consensus; the consensus module, in the process of the transaction execution module executing the transaction execution operation corresponding to the Nth block, executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
  • An electronic device comprising: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform the following operations: execute a transaction execution corresponding to an Nth block operation, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system; in the process of executing the transaction execution operation corresponding to the Nth block, the N+1th block is executed in parallel.
  • the block corresponds to the consensus operation of the transaction, where N is a positive integer.
  • the blockchain nodes can process different stages of the transaction corresponding to different blocks in parallel, using the computing power of the multi-core CPU, greatly It improves the operation efficiency and performance of the blockchain system.
  • FIG. 1 is a schematic diagram of a process of processing transactions in a blockchain system provided by the prior art
  • FIG. 2 is a schematic process diagram of a transaction processing method provided by the prior art
  • FIG. 3 is a schematic flowchart of the implementation of a transaction processing method in a blockchain provided by an embodiment of this specification;
  • FIG. 4 is a schematic diagram of an embodiment of a transaction processing method in a blockchain provided by an embodiment of this specification;
  • FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of this specification.
  • FIG. 6 is a schematic structural diagram of a transaction processing apparatus according to an embodiment of the present specification.
  • One or more embodiments of this specification provide a transaction processing method in a blockchain.
  • the schematic diagram of the implementation process is shown in FIG. 3 , including: Step 310 , the blockchain node executes the transaction execution operation corresponding to the Nth block.
  • the transaction corresponding to the Nth block may be a transaction that has reached a consensus in the blockchain system. Furthermore, in step 310, the blockchain node may execute the transaction corresponding to the Nth block that has reached a consensus.
  • the above transaction execution operation can be processed by the transaction execution thread in the blockchain node.
  • the above consensus operations can be handled by consensus threads in blockchain nodes.
  • the transaction processing process in a blockchain system generally includes four different operations: transaction collection, transaction consensus, transaction execution, and block writing.
  • each consensus node may perform all the operations in the above four stages, or some consensus nodes may perform the operations in the last three stages above without performing the operation of collecting transactions.
  • this operation can also be performed by a separate thread in the consensus node, eg, called a transaction collection thread.
  • the consensus node can query whether the transactions collected in the transaction memory pool meet the preset transaction collection conditions through the transaction collection thread. If the preset transaction collection conditions are met, the consensus node packages the transactions collected by the transaction memory pool through the transaction collection thread. In this way, the consensus node can get the proposal to be consensus. Further, the consensus node can perform operations in the consensus stage through the consensus thread.
  • the consensus thread can collect transactions from Get the transaction corresponding to the Nth block in the thread. Further, a consensus proposal can be initiated based on the transaction, so as to perform the operation in the consensus stage, for example, the consensus operation can be performed by the consensus thread in the blockchain node.
  • the blockchain node responds to the consensus proposal sent by other consensus nodes for the transaction corresponding to the Nth block, and based on the consensus proposal of the Nth block
  • This consensus proposes a consensus operation.
  • consensus operations can be performed by consensus threads in blockchain nodes.
  • the consensus node since the consensus node responds to the sent consensus proposal, and the sent consensus proposal may include transactions to be agreed upon, the consensus node may not perform the operation of collecting transactions.
  • the blockchain node After the blockchain node completes the consensus operation on the transaction corresponding to the Nth block, it may perform the operation on the transaction corresponding to the Nth block in step 310 .
  • the transaction execution operation can be performed by the transaction execution thread in the blockchain node.
  • the consensus thread executes the consensus operation of the transaction corresponding to the Nth block, it transmits the consensus result to the transaction execution thread of the blockchain node. Therefore, the processing flow of the transaction corresponding to the same block is still the same. The order of consensus ⁇ transaction execution can be maintained.
  • Step 320 in the process of executing the transaction execution operation corresponding to the Nth block, the blockchain node executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
  • the consensus node can query whether the transactions collected in the transaction memory pool meet the preset transaction collection conditions through the transaction collection thread. If the preset transaction collection conditions are met, the consensus node packages the transactions collected in the transaction memory pool through the transaction collection thread, thereby forming a transaction corresponding to the N+1th block. In this way, the node can get proposals to be consensus. Further, the consensus node can perform the operation in the consensus stage through the consensus thread, that is, the consensus operation on the transaction corresponding to the N+1th block is performed in step 320.
  • the consensus thread can collect transactions from Get the transaction corresponding to the N+1th block in the thread. Further, a consensus proposal can be initiated based on the transaction, so as to enter the operation of the consensus stage, for example, the consensus operation can be performed by the consensus thread in the blockchain node.
  • the blockchain node responds to the consensus proposal sent by other consensus nodes for the transaction corresponding to the N+1th block,
  • the consensus operation is performed based on the consensus proposal, for example, the consensus operation can be performed by the consensus thread in the blockchain node.
  • the consensus node since the consensus node responds to the sent consensus proposal, and the sent consensus proposal may include transactions to be agreed upon, the consensus node may not perform the operation of collecting transactions.
  • the order of transaction collection ⁇ consensus can still be maintained for the processing flow of transactions corresponding to the same block.
  • the blockchain node performs the process of collecting the transaction corresponding to the Nth block, and performs the process of collecting the transaction corresponding to the N+1th block, the blockchain node collects the transaction corresponding to the N+1th block. Then collect the transactions corresponding to the N+1th block. This is especially true when the blockchain node is assigned only one thread to collect transactions. Moreover, in the process of consensus on the transaction corresponding to the Nth block, the blockchain node performs the operation of collecting the transaction corresponding to the N+1th block in parallel.
  • the consensus operation of the blockchain node on the transaction corresponding to the N+1th block may be performed after a consensus is reached on the transaction corresponding to the Nth block. This is especially true when blockchain nodes are assigned only one consensus thread.
  • consensus proposal for the Nth block and the consensus proposal for the N+1th block may be initiated by the same consensus node, or may be initiated by different consensus nodes.
  • consensus operation of the block chain node on the Nth block may be initiated by the block chain node as the consensus master node, and the consensus operation on the N+1th block may be another block.
  • Blockchain nodes are initiated as consensus master nodes and vice versa.
  • the blockchain node After the blockchain node completes the consensus operation on the transaction corresponding to the N+1th block, it can perform the operation on the transaction corresponding to the N+1th block.
  • the transaction execution operation can be performed by the transaction execution thread in the blockchain node.
  • the consensus thread executes the consensus operation of the transaction corresponding to the N+1th block, it transmits the consensus result to the transaction execution thread of the blockchain node. Therefore, for the processing flow of the transaction corresponding to the same block, It is still possible to maintain the order of consensus ⁇ transaction execution.
  • the blockchain node can also write the result of the transaction execution into the Nth block of the blockchain ledger. That is, write block operations.
  • the block chain node executes the transaction execution operation corresponding to the N+1th block in parallel.
  • the blockchain node performs the operation on the transaction corresponding to the N+1th block, which may be performed after performing the operation on the transaction corresponding to the Nth block. This is especially true when a blockchain node is assigned only one transaction execution thread.
  • the blockchain node can also write the result of the transaction execution into the N+1th area of the blockchain ledger. in the block.
  • the block-writing operation corresponding to the N+1th block by the blockchain node may be performed after the block-writing operation corresponding to the Nth block. This is especially true when a blockchain node is assigned only one block writer thread.
  • the blockchain node When the blockchain node performs the collection transaction operation corresponding to the N+1th block, the consensus operation of the Nth block may not be completed, so the consensus operation for the N+1th block cannot be started. At this time, the blockchain node can store the collected transaction corresponding to the N+1th block in the memory, and extract the N+th block from the memory after the corresponding consensus operation of the Nth block is completed. The transaction corresponding to 1 block, and start the consensus operation on the transaction corresponding to the N+1th block.
  • the blockchain node can store the consensus result corresponding to the N+1th block in the memory, and extract the N+th block from the memory after the corresponding transaction execution operation of the Nth block is completed.
  • the consensus result corresponding to 1 block, and the transaction execution operation corresponding to the N+1th block is started.
  • the block chain node executes the transaction execution operation corresponding to the N+1th block
  • the block writing operation of the Nth block may not be completed, so the N+1th block cannot be started yet. write block operations.
  • the blockchain node can store the transaction execution result corresponding to the N+1th block in the memory, and extract the transaction execution result from the memory after the corresponding block write operation of the Nth block is completed. The transaction execution result corresponding to the N+1th block, and the block write operation corresponding to the N+1th block is started.
  • the blockchain nodes can process different stages of the transaction corresponding to different blocks in parallel, using the computing power of the multi-core CPU, greatly It improves the operation efficiency and performance of the blockchain system.
  • FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present specification.
  • the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory.
  • the memory may include memory, such as high-speed random-access memory (Random-Access Memory, RAM), or may also include 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 equipment may also include hardware required for other services.
  • the processor, network interface and memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Component Interconnect) bus. Industry Standard Architecture, extended industry standard structure) bus, etc.
  • the bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one bidirectional arrow is shown in FIG. 5, but it does not mean that there is only one bus or one type of bus.
  • the program may include program code, and the program code includes computer operation instructions.
  • the memory may include memory and non-volatile memory and provide instructions and data to the processor.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and runs it, forming a transaction processing device on a logical level.
  • the processor executes the program stored in the memory, and is specifically configured to execute the following operations: execute the transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system ; During the process of executing the transaction execution operation corresponding to the Nth block, the consensus operation on the transaction corresponding to the N+1th block is performed in parallel, wherein N is a positive integer.
  • the blockchain node can process the different stages of the transaction corresponding to different blocks in parallel, using the multi-core
  • the computing power of the CPU greatly improves the operating efficiency and performance of the blockchain system.
  • the transaction processing method in the blockchain disclosed by the above-mentioned embodiments shown in FIGS. 3 to 4 of this specification may be applied to a processor, or implemented by a processor.
  • a processor may be an integrated circuit chip with signal processing capabilities.
  • each step of the above-mentioned method can be completed by a hardware integrated logic circuit 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), 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 conjunction with one or more embodiments of this specification may be directly embodied as executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor.
  • the software module may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art.
  • 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 device can also execute the transaction processing method in the blockchain shown in FIG. 3 to FIG. 4 , which will not be repeated in this specification.
  • the electronic devices in this specification do not exclude other implementations, such as logic devices or the combination of software and hardware, etc. That is to say, the execution subjects of the following processing procedures are not limited to each logic unit. It can also be a hardware or logic device.
  • the embodiments of the present specification also provide a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions, and the instructions, when used by a portable electronic device including a plurality of application programs When executed, the portable electronic device can be made to execute the method of the embodiment shown in FIG. 3 to FIG. 4 , and is specifically configured to execute the following operations: execute the transaction execution operation corresponding to the Nth block, wherein the Nth block The corresponding transaction has reached a consensus in the blockchain system; in the process of executing the transaction execution operation corresponding to the Nth block, the consensus operation on the transaction corresponding to the N+1th block is performed in parallel, wherein N is a positive integer.
  • FIG. 6 is a schematic structural diagram of a transaction processing apparatus 600 provided by an embodiment of the present specification.
  • the transaction processing apparatus 600 may be a blockchain node, or in other words, the transaction processing apparatus may be deployed on a blockchain node.
  • the transaction processing apparatus 600 includes: a transaction execution module 603, which executes a transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block is already in the block A consensus is reached in the chain system; the consensus module 602, in the process of the transaction execution module executing the transaction execution operation corresponding to the Nth block, executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
  • the consensus module 602 further performs consensus on the transaction corresponding to the Nth block in the blockchain system.
  • the transaction processing apparatus 600 further includes a transaction collection module 601. Before the consensus module 602 makes a consensus on the transaction corresponding to the Nth block in the blockchain system, the transaction collection module 601 collects the transaction collection module 601. Transactions corresponding to N blocks.
  • the transaction processing apparatus 600 further includes a block writing module 604.
  • the block writing module 604 executes the transaction. The result is written into the Nth block of the blockchain ledger.
  • the consensus module 602 performs a consensus operation on the transaction corresponding to the N+1th block after reaching a consensus on the transaction corresponding to the Nth block.
  • the transaction collection module 601 performs an operation of collecting transactions corresponding to the N+1th block in parallel.
  • an operation of collecting the transaction corresponding to the N+1th block is performed.
  • the transaction execution module 603 executes the transaction execution operation corresponding to the N+1th block in parallel.
  • the transaction execution module 603 executes the operation on the transaction corresponding to the N+1th block after performing the operation on the transaction corresponding to the Nth block.
  • the block writing module 604 writes the result of the transaction execution into the Nth block of the blockchain ledger. +1 block.
  • the block writing module 604 performs the block writing operation corresponding to the N+1 th block after the block writing operation corresponding to the N th block.
  • the transaction collection module 601 finishes the operation of collecting transactions corresponding to the N+1th block, the consensus module 602 has not finished the consensus process corresponding to the Nth block, so The transaction collection module also stores the collected transaction corresponding to the N+1th block in the memory.
  • the consensus module 602 finishes executing the consensus operation corresponding to the N+1th block, and the transaction execution module 603 has not finished executing the transaction corresponding to the Nth block, the The consensus module also stores the consensus result for the N+1th block into memory.
  • the transaction execution module 603 finishes executing the transaction execution operation corresponding to the N+1th block, the block writing module 604 has not finished the block writing process corresponding to the Nth block, The transaction execution module also stores the transaction execution result corresponding to the N+1th block in the memory.
  • the blockchain node where the transaction processing device 600 is deployed can utilize the computing power of the multi-core CPU, Processing different stages of transactions corresponding to different blocks in parallel greatly improves the operating efficiency and performance of the blockchain system.
  • a typical implementation device is a computer.
  • the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
  • Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology.
  • Information may be computer readable instructions, data structures, modules of programs, or other data.
  • Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device.
  • computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.

Abstract

Disclosed in embodiments of the present description are a transaction processing method and apparatus in a blockchain, and an electronic device. The method comprises: a blockchain node executes a transaction execution operation corresponding to an N-th block, a transaction corresponding to the N-th block reaching a consensus in a blockchain system; and the blockchain node concurrently executes a consensus operation on a transaction corresponding to an (N+1)-th block during the execution of the transaction execution operation corresponding to the N-th block.

Description

区块链中交易处理的方法、装置及电子设备Method, device and electronic device for transaction processing in blockchain 技术领域technical field
本文件涉及区块链技术领域,尤其涉及区块链中交易处理的方法、装置及电子设备。This document relates to the field of blockchain technology, in particular to a method, device and electronic device for transaction processing in the blockchain.
背景技术Background technique
一些区块链系统中,交易处理的流程可以如图1所示,包括如下四个阶段:收集交易→共识→交易执行→写块。经过上述过程,可以生成一个区块。在生成一个区块(如图1中第N个区块)后,进入下一个区块(如图1中第N+1个区块)的交易处理流程。In some blockchain systems, the process of transaction processing can be shown in Figure 1, including the following four stages: collecting transactions → consensus → transaction execution → writing blocks. After the above process, a block can be generated. After a block (the Nth block in Figure 1) is generated, the transaction processing flow of the next block (the N+1th block in Figure 1) is entered.
如前所述,区块链系统中一个区块的交易处理流程包括四个阶段。在生成第N个区块后,进入第N+1个区块的交易处理流程。这样的交易处理方式,在任一时间点,共识节点仅可以处理一个区块对应的一个阶段。这种方式不能很好地利用节点的处理资源,例如不能很好地利用多核的并行计算特性,区块链系统的性能也难以得到提升。As mentioned earlier, the transaction processing flow of a block in a blockchain system consists of four stages. After the Nth block is generated, the transaction processing flow of the N+1th block is entered. With this transaction processing method, at any point in time, the consensus node can only process one stage corresponding to one block. This method cannot make good use of the processing resources of nodes. For example, it cannot make good use of the parallel computing characteristics of multiple cores, and it is difficult to improve the performance of the blockchain system.
图1所示为区块链系统中的共识节点处理交易的一般过程。在一些区块链系统中,并不是所有的共识节点都执行上述四阶段中的交易收集操作。例如在一些采用有主共识算法(例如Practical Byzantine Fault Tolerance,PBFT,实用拜占庭容错算法)的区块链系统中,共识主节点可以执行上述四阶段的操作,共识非主节点可以执行共识→交易执行→写块这三个阶段的操作;也可以是各个共识节点均执行上述四个阶段的全部操作。在另外一些采用无主共识算法(例如Honey Badger Byzantine Fault Tolerant,HBBFT,蜜獾拜占庭容错算法)的区块链系统中,共识节点不区分主节点或是非主节点,各个共识节点均可以执行上述四个阶段的全部操作。Figure 1 shows the general process of transaction processing by consensus nodes in a blockchain system. In some blockchain systems, not all consensus nodes perform the transaction collection operations in the above four phases. For example, in some blockchain systems that use master consensus algorithms (such as Practical Byzantine Fault Tolerance, PBFT, Practical Byzantine Fault Tolerance Algorithm), the consensus master node can perform the above four-stage operations, and the consensus non-master nodes can perform consensus → transaction execution →The operations of these three stages of writing blocks; it can also be that each consensus node performs all the operations of the above four stages. In other blockchain systems that use masterless consensus algorithms (such as Honey Badger Byzantine Fault Tolerant, HBBFT, Honey Badger Byzantine Fault Tolerant Algorithm), the consensus nodes do not distinguish between master nodes or non-master nodes, and each consensus node can perform the above four all operations in this stage.
申请公布号为CN111522648A的中国专利,公开了一种交易处理方法,区块链节点并行地执行第N轮交易的写块操作和第N+1轮交易的共识执行操作。代表性的实施例可以如图2所示(也是申请公布号为CN111522648A的专利的附图2)。如图2中,第一线程和第二线程可以并行执行,第一线程进行N轮的共识及交易执行过程中,第二线程可以并行地进行第N-1轮交易的写块操作;第一线程进行N+1轮的共识及交易执行过程中,第二线程可以并行的进行第N轮交易的写块操作;第一线程进行N+2轮的共识及交易执行过程中,第二线程可以并行的进行第N+1轮交易的写块操作。上述例子主要是针对区块链系统交易处理过程中,共识阶段和交易执行阶段占用时间均比较短,写块阶段占用时间相对较长的情况。因此,保持同一个轮次中共识操作和交易执行操作的 耦合关系,而与该轮次的写块操作解耦,从而可以采用两个不同线程,分别执行(共识+交易执行)和写块。这样,在执行上一区块的写块操作的过程中,可以并行执行下一区块的(共识+交易执行)操作,特别适用于采用多核CPU的计算机来处理,从而能够提高交易处理效率,使区块链系统能够适用于业务高并发的应用场景。The Chinese patent application publication number CN111522648A discloses a transaction processing method. The block chain node executes the block writing operation of the Nth round of transactions and the consensus execution operation of the N+1th round of transactions in parallel. A representative embodiment may be shown in Figure 2 (also Figure 2 of Patent Application Publication No. CN111522648A). As shown in Figure 2, the first thread and the second thread can be executed in parallel. During the N rounds of consensus and transaction execution by the first thread, the second thread can execute the block writing operation of the N-1 round of transactions in parallel; During the process of N+1 rounds of consensus and transaction execution, the second thread can perform the block writing operation of the Nth round of transactions in parallel; while the first thread performs N+2 rounds of consensus and transaction execution, the second thread can The block write operation of the N+1 round of transactions is performed in parallel. The above examples are mainly aimed at the situation that the consensus stage and the transaction execution stage take a relatively short time in the transaction processing process of the blockchain system, and the block writing stage takes a relatively long time. Therefore, the coupling relationship between the consensus operation and the transaction execution operation in the same round is maintained, and it is decoupled from the block writing operation in this round, so that two different threads can be used to execute (consensus + transaction execution) and write blocks respectively. In this way, in the process of executing the block writing operation of the previous block, the (consensus + transaction execution) operation of the next block can be executed in parallel, which is especially suitable for processing by computers with multi-core CPUs, thereby improving transaction processing efficiency. Make the blockchain system suitable for application scenarios with high business concurrency.
事实上,某一轮次收集的交易中,可能包括普通转账交易,也可能包括涉及智能合约的交易。对于普通转账交易来说,处理时间一般相对较短,而对于涉及智能合约的交易来说,可能合约逻辑较为复杂,或者涉及合约的交易较多,从而存在处理时间相对较长的情况。这样,对于包含大量涉及智能合约的交易来说,或者对于包含复杂逻辑的智能合约来说,交易执行环节的处理时间可能会比共识环节的时间长,与写块操作的处理时间更为接近,甚至比写块操作的处理时间更长。这样,该例子中仅仅将(共识+交易执行)和写块解耦,仍然有进一步的优化空间。In fact, transactions collected in a certain round may include ordinary transfer transactions or transactions involving smart contracts. For ordinary transfer transactions, the processing time is generally relatively short, while for transactions involving smart contracts, the contract logic may be more complicated, or there may be many transactions involving contracts, so the processing time is relatively long. In this way, for transactions involving a large number of smart contracts, or for smart contracts containing complex logic, the processing time of the transaction execution link may be longer than that of the consensus link, and is closer to the processing time of the block writing operation. Even longer processing time than write block operations. In this way, only (consensus + transaction execution) and block writing are decoupled in this example, and there is still room for further optimization.
发明内容SUMMARY OF THE INVENTION
本说明书实施例提供了一种区块链中的交易处理方法、装置及电子设备。The embodiments of this specification provide a transaction processing method, device, and electronic device in a blockchain.
一种区块链中的交易处理方法,包括:区块链节点执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;所述区块链节点执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。A transaction processing method in a blockchain, comprising: a blockchain node executing a transaction execution operation corresponding to an Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in a blockchain system; In the process of executing the transaction execution operation corresponding to the Nth block, the blockchain node executes the consensus operation on the transaction corresponding to the N+1th block in parallel, where N is a positive integer.
一种交易处理装置,应用于区块链节点,包括:交易执行模块,执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;共识模块,在交易执行模块执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作。A transaction processing device applied to a blockchain node, comprising: a transaction execution module that executes a transaction execution operation corresponding to an Nth block, wherein the transaction corresponding to the Nth block has been reached in a blockchain system Consensus; the consensus module, in the process of the transaction execution module executing the transaction execution operation corresponding to the Nth block, executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
一种电子设备,包括:处理器;以及被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器执行以下操作:执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。An electronic device comprising: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform the following operations: execute a transaction execution corresponding to an Nth block operation, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system; in the process of executing the transaction execution operation corresponding to the Nth block, the N+1th block is executed in parallel. The block corresponds to the consensus operation of the transaction, where N is a positive integer.
采用本说明书实施例提供的交易处理方法,在对区块链系统中的交易进行处理时,区块链节点可以并行地处理不同区块对应交易的不同阶段,利用了多核CPU的计算能 力,大大提升了区块链系统的运行效率,提升了性能。By adopting the transaction processing method provided by the embodiment of this specification, when processing transactions in the blockchain system, the blockchain nodes can process different stages of the transaction corresponding to different blocks in parallel, using the computing power of the multi-core CPU, greatly It improves the operation efficiency and performance of the blockchain system.
附图说明Description of drawings
此处所说明的附图用来提供对本说明书的进一步理解,构成本说明书的一部分,本说明书的示意性实施例及其说明用于解释本说明书,并不构成对本说明书的不当限定。在附图中:The accompanying drawings described herein are used to provide further understanding of the specification and constitute a part of the specification. The exemplary embodiments and descriptions of the specification are used to explain the specification and do not constitute an improper limitation of the specification. In the attached image:
图1为现有技术提供的一种区块链系统中处理交易的过程示意图;1 is a schematic diagram of a process of processing transactions in a blockchain system provided by the prior art;
图2为现有技术提供的交易处理方法的过程示意图;FIG. 2 is a schematic process diagram of a transaction processing method provided by the prior art;
图3为本说明书一个实施例提供的一种区块链中的交易处理方法的实施流程示意图;FIG. 3 is a schematic flowchart of the implementation of a transaction processing method in a blockchain provided by an embodiment of this specification;
图4为本说明书一个实施例提供的区块链中的交易处理方法的一种实施例的示意图;4 is a schematic diagram of an embodiment of a transaction processing method in a blockchain provided by an embodiment of this specification;
图5为本说明书一个实施例提供的一种电子设备的结构示意图;FIG. 5 is a schematic structural diagram of an electronic device according to an embodiment of this specification;
图6为本说明书一个实施例提供的交易处理装置的结构示意图。FIG. 6 is a schematic structural diagram of a transaction processing apparatus according to an embodiment of the present specification.
具体实施方式Detailed ways
为使本文件的目的、技术方案和优点更加清楚,下面将结合本说明书具体实施例及相应的附图对本说明书技术方案进行清楚、完整地描述。显然,所描述的实施例仅是本文件一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本文件保护的范围。In order to make the purpose, technical solutions and advantages of this document more clear, the technical solutions of this specification will be described clearly and completely below with reference to the specific embodiments of this specification and the corresponding drawings. Obviously, the described embodiments are only a part of the embodiments of this document, but not all of the embodiments. 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 document.
以下结合附图,详细说明本说明书各实施例提供的技术方案。The technical solutions provided by the embodiments of the present specification will be described in detail below with reference to the accompanying drawings.
本说明书一个或多个实施例提供一种区块链中的交易处理方法,实现流程示意图如图3所示,包括:步骤310,区块链节点执行第N个区块对应的交易执行操作。One or more embodiments of this specification provide a transaction processing method in a blockchain. The schematic diagram of the implementation process is shown in FIG. 3 , including: Step 310 , the blockchain node executes the transaction execution operation corresponding to the Nth block.
其中,所述第N个区块对应的交易可以是在区块链系统中已达成共识的交易。进而,步骤310中,区块链节点可以执行已达成共识的第N个区块对应的交易。The transaction corresponding to the Nth block may be a transaction that has reached a consensus in the blockchain system. Furthermore, in step 310, the blockchain node may execute the transaction corresponding to the Nth block that has reached a consensus.
上述交易执行操作,可以由区块链节点中的交易执行线程来处理。上述共识操作,可以由区块链节点中的共识线程来处理。The above transaction execution operation can be processed by the transaction execution thread in the blockchain node. The above consensus operations can be handled by consensus threads in blockchain nodes.
如背景技术所述,区块链系统中的交易处理过程通常包括收集交易、交易共识、交易执行和写块,这四个不同的操作。前面提到,可以是各个共识节点均执行上述四个阶段的全部操作,也可以是部分共识节点执行上述后三个阶段的操作而不执行收集交易的 操作。这样,对于执行收集交易的共识节点来说,这个操作也可由该共识节点中的一个单独的线程执行,例如称为交易收集线程。具体地,如图4所示,该共识节点在执行第N个区块对应的交易执行操作开始之前,可以通过交易收集线程查询交易内存池中收集的交易是否已满足预设的交易收集条件。若满足该预设的交易收集条件,则该共识节点通过交易收集线程将交易内存池收集到的交易进行打包。这样,该共识节点可以得到待共识的提议。进一步地,该共识节点可以通过共识线程进行共识阶段的操作。As described in the background art, the transaction processing process in a blockchain system generally includes four different operations: transaction collection, transaction consensus, transaction execution, and block writing. As mentioned above, each consensus node may perform all the operations in the above four stages, or some consensus nodes may perform the operations in the last three stages above without performing the operation of collecting transactions. In this way, for a consensus node that performs collection transactions, this operation can also be performed by a separate thread in the consensus node, eg, called a transaction collection thread. Specifically, as shown in FIG. 4 , before executing the transaction execution operation corresponding to the Nth block, the consensus node can query whether the transactions collected in the transaction memory pool meet the preset transaction collection conditions through the transaction collection thread. If the preset transaction collection conditions are met, the consensus node packages the transactions collected by the transaction memory pool through the transaction collection thread. In this way, the consensus node can get the proposal to be consensus. Further, the consensus node can perform operations in the consensus stage through the consensus thread.
具体地,对于共识节点为采用有主共识算法的区块链系统中的共识主节点时,或者共识节点为采用无主共识算法的区块链系统中的共识节点时,共识线程可以从收集交易线程中获取第N个区块对应的交易。进而,可以基于该交易发起共识提议,从而进行共识阶段的操作,例如可以由区块链节点中的共识线程来进行共识操作。Specifically, when the consensus node is the consensus master node in the blockchain system using the master consensus algorithm, or when the consensus node is the consensus node in the blockchain system using the master consensus algorithm, the consensus thread can collect transactions from Get the transaction corresponding to the Nth block in the thread. Further, a consensus proposal can be initiated based on the transaction, so as to perform the operation in the consensus stage, for example, the consensus operation can be performed by the consensus thread in the blockchain node.
此外,对于共识节点为采用有主共识算法的区块链系统中的共识非主节点时,区块链节点响应其它共识节点发来的对第N个区块对应的交易的共识提议,并基于该共识提议进行共识操作。例如可以由区块链节点中的共识线程来进行共识操作。该情况下,由于该共识节点是响应发来的共识提议,而发来的共识提议中可以包括待共识的交易,因此该共识节点可以不执行收集交易的操作。In addition, when the consensus node is the consensus non-master node in the blockchain system using the master consensus algorithm, the blockchain node responds to the consensus proposal sent by other consensus nodes for the transaction corresponding to the Nth block, and based on the consensus proposal of the Nth block This consensus proposes a consensus operation. For example, consensus operations can be performed by consensus threads in blockchain nodes. In this case, since the consensus node responds to the sent consensus proposal, and the sent consensus proposal may include transactions to be agreed upon, the consensus node may not perform the operation of collecting transactions.
由于所述共识线程需要从收集交易线程中获取第N个区块对应的交易,因此对于同一个区块对应交易的处理流程来说,仍然是可以保持收集交易→共识这样的顺序。Since the consensus thread needs to obtain the transaction corresponding to the Nth block from the transaction collection thread, the order of transaction collection→consensus can still be maintained for the processing flow of transactions corresponding to the same block.
所述区块链节点对第N个区块对应的交易完成共识操作后,可以进行步骤310中的对第N个区块对应的交易执行操作。例如可以由区块链节点中的交易执行线程来进行交易执行操作。After the blockchain node completes the consensus operation on the transaction corresponding to the Nth block, it may perform the operation on the transaction corresponding to the Nth block in step 310 . For example, the transaction execution operation can be performed by the transaction execution thread in the blockchain node.
类似地,共识线程执行完第N个区块对应交易的共识操作后,将共识结果传递至区块链节点的交易执行线程,因此,对于同一个区块对应交易的处理流程来说,仍然是可以保持共识→交易执行这样的顺序。Similarly, after the consensus thread executes the consensus operation of the transaction corresponding to the Nth block, it transmits the consensus result to the transaction execution thread of the blockchain node. Therefore, the processing flow of the transaction corresponding to the same block is still the same. The order of consensus → transaction execution can be maintained.
步骤320,区块链节点执行第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作。 Step 320, in the process of executing the transaction execution operation corresponding to the Nth block, the blockchain node executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
类似地,该共识节点在对第N+1个区块对应交易执行共识操作开始之前,可以通过交易收集线程查询交易内存池中收集的交易是否已满足预设的交易收集条件。若满足该预设的交易收集条件,则该共识节点通过交易收集线程将交易内存池收集到的交易进行打包,从而形成第N+1个区块对应的交易。这样,该节点可以得到待共识的提议。进一 步地,该共识节点可以通过共识线程进行共识阶段的操作,即步骤320中的执行对第N+1个区块对应交易的共识操作。Similarly, before starting the consensus operation on the transaction corresponding to the N+1th block, the consensus node can query whether the transactions collected in the transaction memory pool meet the preset transaction collection conditions through the transaction collection thread. If the preset transaction collection conditions are met, the consensus node packages the transactions collected in the transaction memory pool through the transaction collection thread, thereby forming a transaction corresponding to the N+1th block. In this way, the node can get proposals to be consensus. Further, the consensus node can perform the operation in the consensus stage through the consensus thread, that is, the consensus operation on the transaction corresponding to the N+1th block is performed in step 320.
具体地,对于共识节点为采用有主共识算法的区块链系统中的共识主节点时,或者共识节点为采用无主共识算法的区块链系统中的共识节点时,共识线程可以从收集交易线程中获取第N+1个区块对应的交易。进而,可以基于该交易发起共识提议,从而进入共识阶段的操作,例如可以由区块链节点中的共识线程来进行共识操作。Specifically, when the consensus node is the consensus master node in the blockchain system using the master consensus algorithm, or when the consensus node is the consensus node in the blockchain system using the master consensus algorithm, the consensus thread can collect transactions from Get the transaction corresponding to the N+1th block in the thread. Further, a consensus proposal can be initiated based on the transaction, so as to enter the operation of the consensus stage, for example, the consensus operation can be performed by the consensus thread in the blockchain node.
此外,对于共识节点为采用有主共识算法的区块链系统中的共识非主节点时,区块链节点响应其它共识节点发来的对第N+1个区块对应的交易的共识提议,并基于该共识提议进行共识操作,例如可以由区块链节点中的共识线程来进行共识操作。该情况下,由于该共识节点是响应发来的共识提议,而发来的共识提议中可以包括待共识的交易,因此该共识节点可以不执行收集交易的操作。In addition, when the consensus node is the consensus non-master node in the blockchain system using the master consensus algorithm, the blockchain node responds to the consensus proposal sent by other consensus nodes for the transaction corresponding to the N+1th block, The consensus operation is performed based on the consensus proposal, for example, the consensus operation can be performed by the consensus thread in the blockchain node. In this case, since the consensus node responds to the sent consensus proposal, and the sent consensus proposal may include transactions to be agreed upon, the consensus node may not perform the operation of collecting transactions.
由于共识线程需要从收集交易线程中获取第N+1个区块对应的交易,因此对于同一个区块对应交易的处理流程来说,仍然是可以保持收集交易→共识这样的顺序。Since the consensus thread needs to obtain the transaction corresponding to the N+1th block from the transaction collection thread, the order of transaction collection → consensus can still be maintained for the processing flow of transactions corresponding to the same block.
如果区块链节点执行收集第N个区块对应的交易的过程,且执行收集第N+1个区块对应的交易的过程,则区块链节点收集第N+1个区块对应的交易之后收集第N+1个区块对应的交易。这种情况特别适用于区块链节点仅分配了一个收集交易线程的情况。而且,区块链节点在对第N个区块对应的交易进行共识的过程中,并行地执行收集第N+1个区块对应交易的操作。If the blockchain node performs the process of collecting the transaction corresponding to the Nth block, and performs the process of collecting the transaction corresponding to the N+1th block, the blockchain node collects the transaction corresponding to the N+1th block. Then collect the transactions corresponding to the N+1th block. This is especially true when the blockchain node is assigned only one thread to collect transactions. Moreover, in the process of consensus on the transaction corresponding to the Nth block, the blockchain node performs the operation of collecting the transaction corresponding to the N+1th block in parallel.
所述区块链节点对第N+1个区块对应交易的共识操作,可以是在对第N个区块对应的交易达成共识之后执行。这种情况特别适用于区块链节点仅分配了一个共识线程的情况。The consensus operation of the blockchain node on the transaction corresponding to the N+1th block may be performed after a consensus is reached on the transaction corresponding to the Nth block. This is especially true when blockchain nodes are assigned only one consensus thread.
需要说明的是,第N个区块的共识提议和对第N+1个区块的共识提议可以由同一个共识节点发起,也可以由不同共识节点发起。例如,所述区块链节点对第N个区块的共识操作,可以是该区块链节点作为共识主节点发起的,而对第N+1个区块的共识操作,可以是另一区块链节点作为共识主节点发起的,反之亦然。It should be noted that the consensus proposal for the Nth block and the consensus proposal for the N+1th block may be initiated by the same consensus node, or may be initiated by different consensus nodes. For example, the consensus operation of the block chain node on the Nth block may be initiated by the block chain node as the consensus master node, and the consensus operation on the N+1th block may be another block. Blockchain nodes are initiated as consensus master nodes and vice versa.
区块链节点对第N+1个区块对应的交易完成共识操作后,可以进行对第N+1个区块对应的交易执行操作。例如可以由区块链节点中的交易执行线程来进行交易执行操作。After the blockchain node completes the consensus operation on the transaction corresponding to the N+1th block, it can perform the operation on the transaction corresponding to the N+1th block. For example, the transaction execution operation can be performed by the transaction execution thread in the blockchain node.
类似地,共识线程执行完第N+1个区块对应交易的共识操作后,将共识结果传递至区块链节点的交易执行线程,因此,对于同一个区块对应交易的处理流程来说,仍然是 可以保持共识→交易执行这样的顺序。Similarly, after the consensus thread executes the consensus operation of the transaction corresponding to the N+1th block, it transmits the consensus result to the transaction execution thread of the blockchain node. Therefore, for the processing flow of the transaction corresponding to the same block, It is still possible to maintain the order of consensus → transaction execution.
如图4中所示,区块链节点完成对第N个区块对应的交易执行操作后,区块链节点还可以将交易执行的结果写入区块链账本的第N个区块中,即写块操作。类似地,区块链节点执行所述第N个区块对应的写块操作的过程中,并行地执行对第N+1个区块对应的交易执行操作。As shown in Figure 4, after the blockchain node completes the operation on the transaction corresponding to the Nth block, the blockchain node can also write the result of the transaction execution into the Nth block of the blockchain ledger. That is, write block operations. Similarly, in the process of executing the block writing operation corresponding to the Nth block, the block chain node executes the transaction execution operation corresponding to the N+1th block in parallel.
区块链节点对第N+1个区块对应的交易执行操作,可以是在对第N个区块对应的交易执行操作之后执行。这种情况特别适用于区块链节点仅分配了一个交易执行线程的情况。The blockchain node performs the operation on the transaction corresponding to the N+1th block, which may be performed after performing the operation on the transaction corresponding to the Nth block. This is especially true when a blockchain node is assigned only one transaction execution thread.
如图4所示,区块链节点完成对第N+1个区块对应的交易执行操作后,区块链节点还可以将交易执行的结果写入区块链账本的第N+1个区块中。类似地,区块链节点对第N+1个区块对应的写块操作,可以是在对第N个区块对应的写块操作之后执行。这种情况特别适用于区块链节点仅分配了一个写块线程的情况。As shown in Figure 4, after the blockchain node completes the operation on the transaction corresponding to the N+1th block, the blockchain node can also write the result of the transaction execution into the N+1th area of the blockchain ledger. in the block. Similarly, the block-writing operation corresponding to the N+1th block by the blockchain node may be performed after the block-writing operation corresponding to the Nth block. This is especially true when a blockchain node is assigned only one block writer thread.
区块链节点执行第N+1个区块对应的收集交易操作完成时,可能第N个区块的共识操作尚未完成,因此还不能开始对第N+1个区块的共识操作。此时,区块链节点可以将收集的第N+1个区块对应的交易存储到内存中,并在第N个区块的对应的共识操作完成之后,再从内存中提取该第N+1个区块对应的交易,并开始对第N+1个区块对应交易的共识操作。When the blockchain node performs the collection transaction operation corresponding to the N+1th block, the consensus operation of the Nth block may not be completed, so the consensus operation for the N+1th block cannot be started. At this time, the blockchain node can store the collected transaction corresponding to the N+1th block in the memory, and extract the N+th block from the memory after the corresponding consensus operation of the Nth block is completed. The transaction corresponding to 1 block, and start the consensus operation on the transaction corresponding to the N+1th block.
类似地,区块链节点执行第N+1个区块对应的共识操作完成时,可能第N个区块的交易执行操作尚未完成,因此还不能开始对第N+1个区块的交易执行操作。此时,区块链节点可以将第N+1个区块对应的共识结果存储到内存中,并在第N个区块的对应的交易执行操作完成之后,再从内存中提取该第N+1个区块对应的共识结果,并开始执行第N+1个区块对应的交易执行操作。Similarly, when the consensus operation corresponding to the N+1th block is completed by the blockchain node, the transaction execution operation of the Nth block may not be completed, so the transaction execution of the N+1th block cannot be started. operate. At this time, the blockchain node can store the consensus result corresponding to the N+1th block in the memory, and extract the N+th block from the memory after the corresponding transaction execution operation of the Nth block is completed. The consensus result corresponding to 1 block, and the transaction execution operation corresponding to the N+1th block is started.
类似地,所述区块链节点执行第N+1个区块对应的交易执行操作完成时,可能第N个区块的写块操作尚未完成,因此还不能开始对第N+1个区块的写块操作。此时,所述区块链节点可以将第N+1个区块对应的交易执行结果存储到内存中,并在第N个区块的对应的写块操作完成之后,再从内存中提取该第N+1个区块对应的交易执行结果,并开始执行第N+1个区块对应的写块操作。Similarly, when the block chain node executes the transaction execution operation corresponding to the N+1th block, the block writing operation of the Nth block may not be completed, so the N+1th block cannot be started yet. write block operations. At this time, the blockchain node can store the transaction execution result corresponding to the N+1th block in the memory, and extract the transaction execution result from the memory after the corresponding block write operation of the Nth block is completed. The transaction execution result corresponding to the N+1th block, and the block write operation corresponding to the N+1th block is started.
采用本说明书实施例提供的交易处理方法,在对区块链系统中的交易进行处理时,区块链节点可以并行地处理不同区块对应交易的不同阶段,利用了多核CPU的计算能 力,大大提升了区块链系统的运行效率,提升了性能。By adopting the transaction processing method provided by the embodiment of this specification, when processing transactions in the blockchain system, the blockchain nodes can process different stages of the transaction corresponding to different blocks in parallel, using the computing power of the multi-core CPU, greatly It improves the operation efficiency and performance of the blockchain system.
图5是本说明书的一个实施例提供的电子设备的结构示意图。请参考图5,在硬件层面,该电子设备包括处理器,可选地还包括内部总线、网络接口、存储器。其中,存储器可能包含内存,例如高速随机存取存储器(Random-Access Memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少1个磁盘存储器等。当然,该电子设备还可能包括其他业务所需要的硬件。FIG. 5 is a schematic structural diagram of an electronic device provided by an embodiment of the present specification. Referring to FIG. 5 , at the hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The memory may include memory, such as high-speed random-access memory (Random-Access Memory, RAM), or may also include non-volatile memory (non-volatile memory), such as at least one disk memory. Of course, the electronic equipment may also include hardware required for other services.
处理器、网络接口和存储器可以通过内部总线相互连接,该内部总线可以是ISA(Industry Standard Architecture,工业标准体系结构)总线、PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图5中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The processor, network interface and memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnect standard) bus or an EISA (Extended Component Interconnect) bus. Industry Standard Architecture, extended industry standard structure) bus, etc. The bus can be divided into an address bus, a data bus, a control bus, and the like. For ease of representation, only one bidirectional arrow is shown in FIG. 5, 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. The memory may include memory and non-volatile memory and provide instructions and data to the processor.
处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成交易处理装置。处理器,执行存储器所存放的程序,并具体用于执行以下操作:执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。The processor reads the corresponding computer program from the non-volatile memory into the memory and runs it, forming a transaction processing device on a logical level. The processor executes the program stored in the memory, and is specifically configured to execute the following operations: execute the transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system ; During the process of executing the transaction execution operation corresponding to the Nth block, the consensus operation on the transaction corresponding to the N+1th block is performed in parallel, wherein N is a positive integer.
基于图5所示的电子设备可以知道,本说明书实施例的方案在对区块链系统中的交易进行处理时,区块链节点可以并行地处理不同区块对应交易的不同阶段,利用了多核CPU的计算能力,大大提升了区块链系统的运行效率,提升了性能。Based on the electronic device shown in FIG. 5, it can be known that when the solution in the embodiment of this specification processes the transaction in the blockchain system, the blockchain node can process the different stages of the transaction corresponding to different blocks in parallel, using the multi-core The computing power of the CPU greatly improves the operating efficiency and performance of the blockchain system.
上述如本说明书图3~图4所示实施例揭示的区块链中的交易处理方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本说明书一个或多个实 施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本说明书一个或多个实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。The transaction processing method in the blockchain disclosed by the above-mentioned embodiments shown in FIGS. 3 to 4 of this specification may be applied to a processor, or implemented by a processor. A processor may be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the above-mentioned method can be completed by a hardware integrated logic circuit 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), 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 various methods, steps and logical block diagrams disclosed in one or more embodiments of this specification can be implemented or performed. 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 conjunction with one or more embodiments of this specification may be directly embodied as executed by a hardware decoding processor, or executed by a combination of hardware and software modules in the decoding processor. The software module may be located in random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, registers and other storage media mature in the art. 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.
该电子设备还可执行图3~图4的区块链中的交易处理方法,本说明书在此不再赘述。The electronic device can also execute the transaction processing method in the blockchain shown in FIG. 3 to FIG. 4 , which will not be repeated in this specification.
当然,除了软件实现方式之外,本说明书的电子设备并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。Of course, in addition to software implementations, the electronic devices in this specification do not exclude other implementations, such as logic devices or the combination of software and hardware, etc. That is to say, the execution subjects of the following processing procedures are not limited to each logic unit. It can also be a hardware or logic device.
本说明书实施例还提出了一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令,该指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图3~图4所示实施例的方法,并具体用于执行以下操作:执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。The embodiments of the present specification also provide a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions, and the instructions, when used by a portable electronic device including a plurality of application programs When executed, the portable electronic device can be made to execute the method of the embodiment shown in FIG. 3 to FIG. 4 , and is specifically configured to execute the following operations: execute the transaction execution operation corresponding to the Nth block, wherein the Nth block The corresponding transaction has reached a consensus in the blockchain system; in the process of executing the transaction execution operation corresponding to the Nth block, the consensus operation on the transaction corresponding to the N+1th block is performed in parallel, wherein N is a positive integer.
图6是本说明书实施例提供的交易处理装置600的结构示意图。在具体的应用中,交易处理装置600可以是区块链节点,或者说,该交易处理装置可以部署在区块链节点上。请参考图6,在一种实施方式中,交易处理装置600包括:交易执行模块603,执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;共识模块602,在交易执行模块执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作。FIG. 6 is a schematic structural diagram of a transaction processing apparatus 600 provided by an embodiment of the present specification. In a specific application, the transaction processing apparatus 600 may be a blockchain node, or in other words, the transaction processing apparatus may be deployed on a blockchain node. Referring to FIG. 6, in one embodiment, the transaction processing apparatus 600 includes: a transaction execution module 603, which executes a transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block is already in the block A consensus is reached in the chain system; the consensus module 602, in the process of the transaction execution module executing the transaction execution operation corresponding to the Nth block, executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
可选地,所述交易执行模块603执行第N个区块的交易执行操作之前,所述共识模块602还对所述第N个区块对应的交易在区块链系统中进行共识。Optionally, before the transaction execution module 603 executes the transaction execution operation of the Nth block, the consensus module 602 further performs consensus on the transaction corresponding to the Nth block in the blockchain system.
可选地,交易处理装置600还包括交易收集模块601,当共识模块602对所述第N个区块对应的交易在区块链系统中进行共识之前,所述交易收集模块601收集所述第N个区块对应的交易。Optionally, the transaction processing apparatus 600 further includes a transaction collection module 601. Before the consensus module 602 makes a consensus on the transaction corresponding to the Nth block in the blockchain system, the transaction collection module 601 collects the transaction collection module 601. Transactions corresponding to N blocks.
可选地,所述交易处理装置600还包括写块模块604,所述交易执行模块603完成对所述第N个区块对应的交易执行操作后,所述写块模块604将所述交易执行的结果写 入区块链账本的第N个区块中。Optionally, the transaction processing apparatus 600 further includes a block writing module 604. After the transaction execution module 603 completes the execution of the transaction corresponding to the Nth block, the block writing module 604 executes the transaction. The result is written into the Nth block of the blockchain ledger.
可选地,所述共识模块602对第N个区块对应的交易达成共识之后执行对第N+1个区块对应交易的共识操作。Optionally, the consensus module 602 performs a consensus operation on the transaction corresponding to the N+1th block after reaching a consensus on the transaction corresponding to the Nth block.
可选地,所述共识模块602在对所述第N个区块对应的交易进行共识的过程中,所述交易收集模块601并行地执行收集第N+1个区块对应交易的操作。Optionally, when the consensus module 602 agrees on the transaction corresponding to the Nth block, the transaction collection module 601 performs an operation of collecting transactions corresponding to the N+1th block in parallel.
可选地,所述交易收集模块601收集第N个区块对应交易的之后执行收集第N+1个区块对应交易的操作。Optionally, after the transaction collection module 601 collects the transaction corresponding to the Nth block, an operation of collecting the transaction corresponding to the N+1th block is performed.
可选地,所述写块模块604执行所述第N个区块对应的写块操作的过程中,所述交易执行模块603并行地执行对第N+1个区块对应的交易执行操作。Optionally, when the block writing module 604 executes the block writing operation corresponding to the Nth block, the transaction execution module 603 executes the transaction execution operation corresponding to the N+1th block in parallel.
可选地,所述交易执行模块603在对第N个区块对应的交易执行操作之后执行对第N+1个区块对应的交易执行操作。Optionally, the transaction execution module 603 executes the operation on the transaction corresponding to the N+1th block after performing the operation on the transaction corresponding to the Nth block.
可选地,所述交易执行模块603完成对所述第N+1个区块对应的交易执行操作后,所述写块模块604将所述交易执行的结果写入区块链账本的第N+1个区块中。Optionally, after the transaction execution module 603 completes the execution of the transaction corresponding to the N+1th block, the block writing module 604 writes the result of the transaction execution into the Nth block of the blockchain ledger. +1 block.
可选地,所述写块模块604在对第N个区块对应的写块操作之后执行对第N+1个区块对应的写块操作。Optionally, the block writing module 604 performs the block writing operation corresponding to the N+1 th block after the block writing operation corresponding to the N th block.
可选地,如果所述交易收集模块601在执行收集第N+1个区块对应交易的操作结束之后,所述共识模块602对所述第N个区块对应的共识的过程尚未结束,所述交易收集模块还将收集的第N+1个区块对应的交易存储到内存中。Optionally, if the transaction collection module 601 finishes the operation of collecting transactions corresponding to the N+1th block, the consensus module 602 has not finished the consensus process corresponding to the Nth block, so The transaction collection module also stores the collected transaction corresponding to the N+1th block in the memory.
可选地,如果所述共识模块602在执行第N+1个区块对应的共识操作结束之后,所述交易执行模块603对所述第N个区块对应的交易执行过程尚未结束,所述共识模块还将对第N+1个区块的共识结果存储到内存中。Optionally, if the consensus module 602 finishes executing the consensus operation corresponding to the N+1th block, and the transaction execution module 603 has not finished executing the transaction corresponding to the Nth block, the The consensus module also stores the consensus result for the N+1th block into memory.
可选地,如果所述交易执行模块603在执行第N+1个区块对应的交易执行操作结束之后,所述写块模块604对所述第N个区块对应的写块过程尚未结束,所述交易执行模块还将对第N+1个区块对应的交易执行结果存储到内存中。Optionally, if the transaction execution module 603 finishes executing the transaction execution operation corresponding to the N+1th block, the block writing module 604 has not finished the block writing process corresponding to the Nth block, The transaction execution module also stores the transaction execution result corresponding to the N+1th block in the memory.
基于图6所示的交易处理装置600可以知道,本说明书实施例的方案在对区块链系统中的交易进行处理时,部署交易处理装置600的区块链节点可以利用多核CPU的计算能力,并行地处理不同区块对应交易的不同阶段,大大提升了区块链系统的运行效率,提升了性能。Based on the transaction processing device 600 shown in FIG. 6 , it can be known that when the solution in the embodiment of this specification processes the transaction in the blockchain system, the blockchain node where the transaction processing device 600 is deployed can utilize the computing power of the multi-core CPU, Processing different stages of transactions corresponding to different blocks in parallel greatly improves the operating efficiency and performance of the blockchain system.
总之,以上所述仅为本说明书的较佳实施例而已,并非用于限定本说明书的保护范围。凡在本说明书一个或多个实施例的精神和原则之内,所作的任何修改、等同替换、改进等,均应包含在本说明书一个或多个实施例的保护范围之内。In a word, the above descriptions are only preferred embodiments of the present specification, and are not intended to limit the protection scope of the present specification. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of one or more embodiments of this specification shall be included within the protection scope of one or more embodiments of this specification.
上述实施例阐明的系统、装置、模块或单元,具体可以由计算机芯片或实体实现,或者由具有某种功能的产品来实现。一种典型的实现设备为计算机。具体的,计算机例如可以为个人计算机、膝上型计算机、蜂窝电话、相机电话、智能电话、个人数字助理、媒体播放器、导航设备、电子邮件设备、游戏控制台、平板计算机、可穿戴设备或者这些设备中的任何设备的组合。The systems, devices, modules or units described in the above embodiments may be specifically implemented by computer chips or entities, or by products with certain functions. A typical implementation device is a computer. Specifically, the computer can be, for example, a personal computer, a laptop computer, a cellular phone, a camera phone, a smart phone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or A combination of any of these devices.
计算机可读介质包括永久性和非永久性、可移动和非可移动媒体可以由任何方法或技术来实现信息存储。信息可以是计算机可读指令、数据结构、程序的模块或其他数据。计算机的存储介质的例子包括,但不限于相变内存(PRAM)、静态随机存取存储器(SRAM)、动态随机存取存储器(DRAM)、其他类型的随机存取存储器(RAM)、只读存储器(ROM)、电可擦除可编程只读存储器(EEPROM)、快闪记忆体或其他内存技术、只读光盘只读存储器(CD-ROM)、数字多功能光盘(DVD)或其他光学存储、磁盒式磁带,磁带磁盘存储或其他磁性存储设备或任何其他非传输介质,可用于存储可以被计算设备访问的信息。按照本文中的界定,计算机可读介质不包括暂存电脑可读媒体(transitory media),如调制的数据信号和载波。Computer-readable media includes both persistent and non-permanent, removable and non-removable media, and storage of information may be implemented by any method or technology. Information may be computer readable instructions, data structures, modules of programs, or other data. Examples of computer storage media include, but are not limited to, phase-change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), Flash Memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital Versatile Disc (DVD) or other optical storage, Magnetic tape cartridges, magnetic tape disk storage or other magnetic storage devices or any other non-transmission medium that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media, such as modulated data signals and carrier waves.
还需要说明的是,术语“包括”、“包含”或者其任何其他变体意在涵盖非排他性的包含,从而使得包括一系列要素的过程、方法、商品或者设备不仅包括那些要素,而且还包括没有明确列出的其他要素,或者是还包括为这种过程、方法、商品或者设备所固有的要素。在没有更多限制的情况下,由语句“包括一个……”限定的要素,并不排除在包括所述要素的过程、方法、商品或者设备中还存在另外的相同要素。It should also be noted that the terms "comprising", "comprising" or any other variation thereof are intended to encompass a non-exclusive inclusion such that a process, method, article or device comprising a series of elements includes not only those elements, but also Other elements not expressly listed, or which are inherent to such a process, method, article of manufacture, or apparatus are also included. Without further limitation, an element qualified by the phrase "comprising a..." does not preclude the presence of additional identical elements in the process, method, article of manufacture, or device that includes the element.
本说明书中的各个实施例均采用递进的方式描述,各个实施例之间相同相似的部分互相参见即可,每个实施例重点说明的都是与其他实施例的不同之处。尤其,对于系统实施例而言,由于其基本相似于方法实施例,所以描述的比较简单,相关之处参见方法实施例的部分说明即可。Each embodiment in this specification is described in a progressive manner, and the same and similar parts between the various embodiments may be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, as for the system embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and for related parts, please refer to the partial descriptions of the method embodiments.

Claims (16)

  1. 一种区块链中的交易处理方法,包括:A transaction processing method in a blockchain, comprising:
    区块链节点执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;The blockchain node executes the transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system;
    所述区块链节点执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。In the process of executing the transaction execution operation corresponding to the Nth block, the blockchain node executes the consensus operation on the transaction corresponding to the N+1th block in parallel, where N is a positive integer.
  2. 如权利要求1所述的方法,所述区块链节点执行第N个区块的交易执行操作之前,所述方法还包括:The method according to claim 1, before the block chain node executes the transaction execution operation of the Nth block, the method further comprises:
    所述区块链节点对所述第N个区块对应的交易在区块链系统中进行共识。The blockchain node performs consensus on the transaction corresponding to the Nth block in the blockchain system.
  3. 如权利要求2所述的方法,所述区块链节点对所述第N个区块对应的交易在区块链系统中进行共识之前,所述方法还包括:The method according to claim 2, before the blockchain node performs consensus on the transaction corresponding to the Nth block in the blockchain system, the method further comprises:
    所述区块链节点收集所述第N个区块对应的交易。The blockchain node collects the transaction corresponding to the Nth block.
  4. 如权利要求1所述的方法,所述区块链节点完成对所述第N个区块对应的交易执行操作后,所述方法还包括:The method according to claim 1, after the blockchain node completes the operation on the transaction corresponding to the Nth block, the method further comprises:
    所述区块链节点将所述交易执行的结果写入区块链账本的第N个区块中。The blockchain node writes the result of the transaction execution into the Nth block of the blockchain ledger.
  5. 如权利要求1所述的方法,所述对第N+1个区块对应交易的共识操作,在对第N个区块对应的交易达成共识之后执行。The method of claim 1, wherein the consensus operation on the transaction corresponding to the N+1th block is performed after a consensus is reached on the transaction corresponding to the Nth block.
  6. 如权利要求2所述的方法,所述方法还包括:The method of claim 2, further comprising:
    所述区块链节点在对所述第N个区块对应的交易进行共识的过程中,并行地执行收集第N+1个区块对应交易的操作。During the process of consensus on the transaction corresponding to the Nth block, the blockchain node performs an operation of collecting transactions corresponding to the N+1th block in parallel.
  7. 如权利要求6所述的方法,所述区块链节点执行收集第N+1个区块对应交易的操作,在执行收集第N个区块对应交易的操作之后执行。The method according to claim 6, wherein the block chain node performs the operation of collecting the transactions corresponding to the N+1th block, and executes the operation after performing the operation of collecting the transactions corresponding to the Nth block.
  8. 如权利要求7所述的方法,所述区块链节点执行所述第N个区块对应的写块操作的过程中,并行地执行对第N+1个区块对应的交易执行操作。The method according to claim 7, wherein in the process of executing the block write operation corresponding to the Nth block, the block chain node executes the transaction execution operation corresponding to the N+1th block in parallel.
  9. 如权利要求8所述的方法,所述区块链节点对第N+1个区块对应的交易执行操作,在对第N个区块对应的交易执行操作之后执行。The method of claim 8, wherein the blockchain node performs operations on the transaction corresponding to the N+1th block, and performs the operation after performing the operation on the transaction corresponding to the Nth block.
  10. 如权利要求8所述的方法,所述区块链节点完成对所述第N+1个区块对应的交易执行操作后,所述方法还包括:The method according to claim 8, after the blockchain node completes the operation on the transaction corresponding to the N+1th block, the method further comprises:
    所述区块链节点将所述交易执行的结果写入区块链账本的第N+1个区块中。The blockchain node writes the result of the transaction execution into the N+1th block of the blockchain ledger.
  11. 如权利要求10所述的方法,所述区块链节点对第N+1个区块对应的写块操作,在对第N个区块对应的写块操作之后执行。The method of claim 10, wherein the block chain node performs the block write operation corresponding to the N+1th block after the block write operation corresponding to the Nth block.
  12. 如权利要求6所述的方法,如果所述区块链节点在执行收集第N+1个区块对应交易的操作结束之后,对所述第N个区块对应的共识的过程尚未结束,该方法还包括:The method according to claim 6, if the consensus process for the Nth block corresponding to the Nth block has not ended after the block chain node performs the operation of collecting the transactions corresponding to the N+1th block, the Methods also include:
    所述区块链节点将收集的第N+1个区块对应的交易存储到内存中。The blockchain node stores the collected transaction corresponding to the N+1th block in the memory.
  13. 如权利要求8所述的方法,如果所述区块链节点在执行第N+1个区块对应的共识操作结束之后,对所述第N个区块对应的交易执行过程尚未结束,该方法还包括:The method according to claim 8, if the execution process of the transaction corresponding to the Nth block has not ended after the block chain node performs the consensus operation corresponding to the N+1th block, the method Also includes:
    所述区块链节点将第N+1个区块对应的共识结果存储到内存中。The blockchain node stores the consensus result corresponding to the N+1th block in the memory.
  14. 如权利要求10所述的方法,如果所述区块链节点在执行第N+1个区块对应的交易执行操作结束之后,对所述第N个区块对应的写块过程尚未结束,该方法还包括:The method according to claim 10, if the block-writing process corresponding to the N-th block has not ended after the execution of the transaction execution operation corresponding to the N+1-th block by the blockchain node is completed, the Methods also include:
    所述区块链节点将第N+1个区块对应的交易执行结果存储到内存中。The blockchain node stores the transaction execution result corresponding to the N+1th block in the memory.
  15. 一种交易处理装置,应用于区块链节点,包括:A transaction processing device, applied to a blockchain node, includes:
    交易执行模块,执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;The transaction execution module executes the transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system;
    共识模块,在交易执行模块执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作。The consensus module, in the process of the transaction execution module executing the transaction execution operation corresponding to the Nth block, executes the consensus operation on the transaction corresponding to the N+1th block in parallel.
  16. 一种电子设备,包括:An electronic device comprising:
    处理器;以及processor; and
    被安排成存储计算机可执行指令的存储器,所述可执行指令在被执行时使所述处理器执行以下操作:memory arranged to store computer-executable instructions which, when executed, cause the processor to:
    执行第N个区块对应的交易执行操作,其中所述第N个区块对应的交易已在区块链系统中达成共识;Execute the transaction execution operation corresponding to the Nth block, wherein the transaction corresponding to the Nth block has reached a consensus in the blockchain system;
    执行所述第N个区块对应的交易执行操作的过程中,并行地执行对第N+1个区块对应交易的共识操作,其中,N为正整数。In the process of executing the transaction execution operation corresponding to the Nth block, the consensus operation on the transaction corresponding to the N+1th block is performed in parallel, wherein N is a positive integer.
PCT/CN2022/073652 2021-02-03 2022-01-25 Transaction processing method and apparatus in blockchain, and electronic device WO2022166673A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202110146211.6A CN112506671B (en) 2021-02-03 2021-02-03 Transaction processing method and device in block chain and electronic equipment
CN202110146211.6 2021-02-03

Publications (1)

Publication Number Publication Date
WO2022166673A1 true WO2022166673A1 (en) 2022-08-11

Family

ID=74952910

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/073652 WO2022166673A1 (en) 2021-02-03 2022-01-25 Transaction processing method and apparatus in blockchain, and electronic device

Country Status (2)

Country Link
CN (2) CN112506671B (en)
WO (1) WO2022166673A1 (en)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112506671B (en) * 2021-02-03 2021-05-07 支付宝(杭州)信息技术有限公司 Transaction processing method and device in block chain and electronic equipment
CN112884588B (en) * 2021-04-30 2021-08-03 支付宝(杭州)信息技术有限公司 Block chain transaction execution method, block chain node and control device
CN113761071B (en) * 2021-10-09 2023-07-11 支付宝(杭州)信息技术有限公司 Consensus method, block chain system and consensus node
CN113630257B (en) * 2021-10-09 2022-01-04 支付宝(杭州)信息技术有限公司 Consensus method, block chain system and consensus node
CN114663235A (en) * 2021-11-04 2022-06-24 支付宝(杭州)信息技术有限公司 Method and device for executing transaction in block chain

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110020859A (en) * 2019-03-28 2019-07-16 杭州秘猿科技有限公司 A kind of block chain common recognition method, apparatus and electronic equipment executed parallel
CN110648136A (en) * 2019-09-10 2020-01-03 杭州秘猿科技有限公司 Consensus and transaction synchronous parallel processing method and device and electronic equipment
CN111522648A (en) * 2020-07-03 2020-08-11 支付宝(杭州)信息技术有限公司 Transaction processing method and device for block chain and electronic equipment
CN112506671A (en) * 2021-02-03 2021-03-16 支付宝(杭州)信息技术有限公司 Transaction processing method and device in block chain and electronic equipment

Family Cites Families (9)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN100454343C (en) * 2006-01-18 2009-01-21 成都前锋电子电器集团股份有限公司 Data storage system for tax controlled cash register
CN107402824B (en) * 2017-05-31 2020-06-02 创新先进技术有限公司 Data processing method and device
CN107528882B (en) * 2017-07-14 2020-12-25 创新先进技术有限公司 Method and device for processing consensus request in block chain consensus network and electronic equipment
KR20190009958A (en) * 2017-07-20 2019-01-30 주식회사 더블체인 Extendable block chain system and block chain extending method
CN109213790B (en) * 2018-08-10 2021-04-20 南京一目智能科技有限公司 Block chain-based data circulation analysis method and system
US11423016B2 (en) * 2019-06-26 2022-08-23 Indian Institute Of Technology Bombay Method for scaling computation in blockchain by delaying transaction execution
CN110517141B (en) * 2019-08-27 2023-06-13 深圳前海微众银行股份有限公司 Consensus method and device based on block chain system
CN110659988B (en) * 2019-09-10 2022-11-18 杭州秘猿科技有限公司 Parallel processing method and device for block chain consensus and execution and electronic equipment
CN111475501B (en) * 2020-06-24 2020-10-30 支付宝(杭州)信息技术有限公司 Data cleaning method and device for block chain network

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110020859A (en) * 2019-03-28 2019-07-16 杭州秘猿科技有限公司 A kind of block chain common recognition method, apparatus and electronic equipment executed parallel
CN110648136A (en) * 2019-09-10 2020-01-03 杭州秘猿科技有限公司 Consensus and transaction synchronous parallel processing method and device and electronic equipment
CN111522648A (en) * 2020-07-03 2020-08-11 支付宝(杭州)信息技术有限公司 Transaction processing method and device for block chain and electronic equipment
CN112506671A (en) * 2021-02-03 2021-03-16 支付宝(杭州)信息技术有限公司 Transaction processing method and device in block chain and electronic equipment
CN113204432A (en) * 2021-02-03 2021-08-03 支付宝(杭州)信息技术有限公司 Transaction processing method and device in block chain and electronic equipment

Also Published As

Publication number Publication date
CN112506671A (en) 2021-03-16
CN112506671B (en) 2021-05-07
CN113204432A (en) 2021-08-03

Similar Documents

Publication Publication Date Title
WO2022166673A1 (en) Transaction processing method and apparatus in blockchain, and electronic device
TWI752118B (en) A blockchain consensus method and device
WO2020082871A1 (en) Method, device and system for executing blockchain transactions in parallel
CN110648136B (en) Consensus and transaction synchronous parallel processing method and device and electronic equipment
CN112882663B (en) Random writing method, electronic equipment and storage medium
CN109582398B (en) State processing method and device and electronic equipment
CN112181902B (en) Database storage method and device and electronic equipment
WO2023160088A1 (en) Method for processing blockchain transactions, and blockchain node and electronic device
WO2023160092A1 (en) Method for processing blockchain transactions, and blockchain node and electronic device
WO2017020735A1 (en) Data processing method, backup server and storage system
EP3933639B1 (en) Transaction processing method, apparatus, and electronic device for blockchain
CN115408411A (en) Data writing method and device, electronic equipment and storage medium
CN113744062B (en) Method for performing transactions in a blockchain, blockchain node and blockchain
WO2020073801A1 (en) Data reading/writing method and system in 3d image processing, storage medium, and terminal
US7451182B2 (en) Coordinating operations of network and host processors
WO2023093335A1 (en) Data processing circuit, artificial intelligence chip, and data processing method and apparatus
EP3907624A1 (en) Memory and storage controller with integrated memory coherency interconnect
CN115760405A (en) Transaction execution method, device, computer equipment and medium
CN110599139B (en) Block output method and device in block chain consensus algorithm
US20040107308A1 (en) Memory that allows simultaneous read requests
WO2022041672A1 (en) Full backup method and apparatus for distributed database system, and computer-readable storage medium
CN113486109A (en) Data synchronization method and device of heterogeneous database and electronic equipment
CN109271277B (en) Access method, device and system after database downtime
CN112351085A (en) Network resource safety sharing method
US11094368B2 (en) Memory, memory chip and memory data access method

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

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 22748952

Country of ref document: EP

Kind code of ref document: A1