WO2023160086A1 - Transaction processing method of blockchain, blockchain node, and electronic device - Google Patents

Transaction processing method of blockchain, blockchain node, and electronic device Download PDF

Info

Publication number
WO2023160086A1
WO2023160086A1 PCT/CN2022/135403 CN2022135403W WO2023160086A1 WO 2023160086 A1 WO2023160086 A1 WO 2023160086A1 CN 2022135403 W CN2022135403 W CN 2022135403W WO 2023160086 A1 WO2023160086 A1 WO 2023160086A1
Authority
WO
WIPO (PCT)
Prior art keywords
consensus
transaction
round
node
execution
Prior art date
Application number
PCT/CN2022/135403
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 WO2023160086A1 publication Critical patent/WO2023160086A1/en

Links

Images

Classifications

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

Definitions

  • This document belongs to the field of block chain technology, and in particular relates to a block chain transaction processing method, block chain nodes and electronic equipment.
  • blockchain Due to its advantages of openness, non-tamperability, and decentralization, blockchain is increasingly favored by all walks of life.
  • the processing flow of blockchain transactions mainly includes four stages: transaction consensus, transaction execution, transaction execution confirmation, and transaction writing block.
  • these four stages are executed sequentially, that is to say, after the blockchain client initiates the transaction, the execution result of the transaction cannot be known immediately (the transaction needs to complete the consensus before being executed), which affects user experience.
  • the purpose of the embodiments of this specification is to provide a processing method of blockchain transactions, blockchain nodes and electronic equipment, which can improve the efficiency of confirmation of execution results of blockchain transactions.
  • a blockchain transaction processing method including:
  • the consensus node of the blockchain executes the transaction execution operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
  • the consensus node executes the consensus operation of the first transaction set in the N round consensus proposal
  • the consensus node After the execution of the transaction execution operation is completed, the consensus node initiates a transaction execution determination operation for the first transaction set;
  • the consensus node After the consensus node has reached a consensus on all the transaction sets proposed by the N-round consensus and completed the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus.
  • a block chain transaction processing device including:
  • the transaction consensus module executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
  • the transaction execution module executes the transaction execution operation of the first transaction set
  • the transaction execution confirmation module after the execution of the transaction execution operation is completed, initiates the transaction execution confirmation operation of the first transaction set;
  • the block writing module executes a block writing operation on all transaction sets proposed by the N-th round of consensus after reaching a consensus on all transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation.
  • an electronic device including: a memory, a processor, and a computer program stored on the memory and operable on the processor is proposed, and the computer program is executed by the processor:
  • a computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including a plurality of application programs, the The electronic device performs the following operations:
  • the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving the finalization of the transaction.
  • the confirmation efficiency is high, so that the client user can know the transaction execution result as soon as possible, which improves the user experience to a certain extent.
  • the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
  • FIG. 1 is a schematic flowchart of a transaction processing method according to an embodiment of this specification.
  • FIG. 2 is a schematic flow diagram of a traditional PBFT protocol.
  • Fig. 3 is a schematic diagram of the first type of process for executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
  • FIG. 4 is a schematic diagram of a second flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
  • Fig. 5 is a schematic diagram of a third flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method according to the embodiment of this specification.
  • Fig. 6 is a schematic diagram of a fourth flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
  • FIG. 7 is a schematic diagram of a fifth flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
  • FIG. 8 is a schematic structural diagram of a blockchain node in an embodiment of this specification.
  • FIG. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
  • the processing flow of blockchain transactions mainly includes four stages: transaction consensus, transaction execution, transaction execution confirmation, and transaction block writing.
  • these four stages are executed sequentially, that is to say, after the blockchain client initiates a transaction, the transaction must first complete the consensus before execution. In this way, the client cannot immediately know the execution result of the transaction, and this delay problem can be perceived by the client user. If the delay is serious, it will affect the user experience.
  • this document aims to propose a technical solution to improve the efficiency of confirmation of execution results of blockchain transactions.
  • Fig. 1 is a flow chart of a processing method of a blockchain transaction according to an embodiment of this specification. The method shown in Figure 1 can be executed by the corresponding blockchain nodes below, including the following steps:
  • the consensus node of the blockchain executes the consensus operation of the first transaction set in the consensus proposal of the Nth round, where N is a positive integer.
  • the first transaction set may include all transactions requiring consensus in the Nth round of consensus proposals, or some transactions requiring consensus in the Nth round of consensus proposals, which is not specifically limited here.
  • the consensus node is the consensus master node of the blockchain, it is necessary to create the N-round consensus proposal and send the N-round consensus proposal to the consensus backup node of the blockchain.
  • the consensus backup node obtains the N round of consensus proposals
  • the blockchain consensus nodes (including the consensus master node and the consensus backup node) begin to perform consensus operations on the first transaction set.
  • the consensus node is the consensus backup node of the blockchain, it will perform consensus operations on the first transaction set after receiving the Nth round of consensus proposals sent by the consensus master node of the blockchain.
  • the consensus node executes the transaction execution operation of the first transaction set.
  • the consensus node can execute the transaction execution operation on the first transaction set without reaching a consensus on the first transaction set.
  • the consensus node can execute the transaction execution operation of the first transaction set in parallel when executing the consensus operation of the first transaction set after the N-round consensus proposal is initiated.
  • the consensus operations performed by consensus nodes mainly include: consensus verification and consensus message sending and receiving. That is to say, in the parallel mode, consensus nodes can at least use the time of waiting to receive consensus messages sent by other consensus nodes to perform transaction execution operations, thereby improving the processing efficiency of blockchain transactions.
  • the consensus node After the transaction execution operation is completed, the consensus node initiates a confirmation operation on the transaction execution of the first transaction set.
  • the transaction execution determination operation refers to the operation of confirming the transaction execution result.
  • the consensus node After the consensus node completes the transaction execution operation of the first transaction set, it will send the transaction execution confirmation message of the first transaction set to other consensus nodes in the blockchain, and the transaction execution confirmation message carries the transaction execution confirmation message of the first transaction set. Hash information; similarly, when other consensus nodes complete the transaction execution operation of the first transaction set, they will also send the transaction execution confirmation message of the first transaction set to the consensus node in this step.
  • the consensus node in this step receives the transaction execution confirmation message carrying the hash information of the same first transaction set sent by 2f other consensus nodes, it can confirm the transaction execution of the first transaction set (f is the area Amount of Byzantine Fault Tolerance set by the blockchain). It should be understood that after the transaction execution in the first transaction set is confirmed, the transaction execution result in the first transaction set can be fed back to the corresponding client and be perceived by the client user in advance.
  • the consensus node After the consensus node reaches a consensus on all the transaction sets proposed by the N-round consensus and completes the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus.
  • the block writing operation in the traditional serial mode can only be executed after the transaction execution results of all transaction sets proposed by the N round of consensus are confirmed, while the above steps based on the embodiment of the present invention can complete the transaction execution operation and transaction execution confirmation in advance In this way, the block writing operation will also be executed in advance, thereby shortening the time-consuming of blockchain transactions on the chain, and improving the transaction processing efficiency of the blockchain.
  • the consensus node can generate a temporary block proposed by the N-round consensus after completing the transaction confirmation operation for all transaction sets proposed by the N-round consensus; at this time, if If a consensus has not been reached on all transaction sets proposed by the N round of consensus, the consensus node will wait; if a consensus has been reached on all transaction sets proposed by the N round consensus, the consensus node will directly transfer the temporary area The block is written into the blockchain, thus saving the time-consuming operation of writing blocks.
  • the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, so that Improve the confirmation efficiency of transaction finalization, so that client users can know the transaction execution results as soon as possible, which improves the user experience to a certain extent.
  • the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
  • the consensus nodes of the blockchain perform consensus operations based on the Practical Byzantine Fault Tolerance (PBFT) protocol.
  • PBFT Practical Byzantine Fault Tolerance
  • the consensus process of the traditional PBFT protocol mainly includes:
  • the main consensus node receives a request from the Client and assigns a number to the request.
  • the consensus main node broadcasts a pre-prepare message to the consensus backup node.
  • This pre-prepare message mainly includes the current consensus view (view), the consensus main The node's digest (digest) and the above block hash information, etc.
  • each consensus backup node After receiving the pre-prepare message, each consensus backup node verifies the information in the pre-prepare message. If the test is successful, it goes directly to the prepare phase. If the verification fails, the consensus process ends.
  • each of the consensus backup nodes participating in the consensus checks whether the pre-prepare message is legal. If the pre-prepare message is legal, then the consensus proposal is determined to be prepared on the replica, and the consensus backup node adds the pre-prepare message to the local Log, and sends the prepare message to other consensus backup nodes participating in the consensus.
  • Each of all consensus nodes sends a commit message to other consensus nodes after entering the prepared state, and adds the commit message sent by itself to the local Log (representing its own approval).
  • a consensus node finds that there is a quorum (quorum is a set of a certain number of replicas required to ensure all replica data consistency requirements and fault tolerance requirements) agreeing to number assignment, it will broadcast a commit message to all other nodes. At the same time, it will also receive commit messages from other nodes one after another.
  • each node receives 2f commit messages not including those sent by itself (f is the number of malicious nodes in the alliance chain, and the 2f commit messages do not include those sent by itself commit message), it means that the consensus node has a certificate named committed certificate, and the request has reached the committed state on this consensus node. At this time, only through this consensus node, it can be concluded that the request has reached the prepared state in a quorum, that is, all consensus nodes of the same quorum have agreed to the allocation of number n. When the request initiated by the Client reaches the committed state, it means that the consensus of the whole network has been reached.
  • the consensus master node in this application scenario needs to select the first transaction set from its own transaction pool to initiate the Nth round of consensus proposal, and in the Pre-Prepare phase, pass The Pre-Prepare message sends the transaction data of the first transaction set to the consensus backup node of the blockchain.
  • the consensus node determines the transaction data of the first transaction set, it can execute the transaction execution operation on the first transaction set. That is to say, in this application scenario, the consensus master node can execute transactions on the first transaction set as early as the Pre-Prepare stage, and the consensus backup node needs to obtain the transaction data of the first transaction set through the Pre-Prepare message After that, execute the transaction execution operation on the first transaction set in the Prepare phase.
  • each consensus node of the blockchain can generate a temporary block of the first transaction set before the Commit phase.
  • the Commit message can be reused to complete the transaction execution confirmation operation. That is, each consensus node of the blockchain sends the hash information of the temporary block of the first transaction set to other blockchain nodes of the blockchain through a Commit message in the Commit phase. Afterwards, any consensus node will confirm the transaction execution of the first transaction set if it receives the Commit message from 2f other consensus nodes carrying the hash information of the temporary block of the same first transaction set.
  • P1 is the consensus master node proposed by the N-round consensus
  • P2, P3, and P4 are the consensus proposed by the N-round consensus
  • the traditional transaction on-chain process based on the PBFT protocol is to execute the consensus operation of the pre-prepare stage, the consensus operation of the prepare stage, the consensus operation of the Commit stage, and Transaction execution operation ⁇ transaction execution confirmation operation (represented by shaded squares) and write block operation (represented by unfilled squares).
  • the application scenario of the embodiment of this specification is shown in Figure 3 based on the transaction on-chain process of the PBFT protocol. That is, before the consensus operation of the Commit phase of the PBFT protocol, P1 directly generates the temporary area proposed by the Nth round of consensus, and sends a Commit message carrying the hash information of the temporary block proposed by the Nth round of consensus in the Commit phase to other consensus nodes. It should be understood that since the consensus proposal of the Nth round only includes the first transaction set, the hash information of the temporary block proposed by the Nth round consensus is the hash information of the first transaction set.
  • the Commit message sent by 2f other consensus nodes carrying the hash information of the temporary block of the same N-round consensus proposal can confirm the final execution of all transactions in the N-round consensus proposal, and directly transfer the N-round consensus proposal
  • the proposed interim block is written to the blockchain.
  • the above is an example of how the consensus node executes the transaction execution operation and the transaction execution confirmation operation when the consensus proposal contains only one transaction set.
  • the method of the embodiment of the present invention can also be shown in Figure 4, where the consensus master node and the consensus backup node perform transaction execution operations together in the Prepare phase; or as shown in Figure 5, the consensus master node and the consensus backup node Execute the transaction execution operation after the Prepare phase, and enter the Commit phase after completing the transaction execution operation. It should be understood that no matter what the changes are, within the consensus stage of a certain transaction set, the parallel execution of transaction execution operations and transaction execution confirmation on the transaction set shall fall within the scope of protection of this document.
  • the consensus nodes can complete consensus operations on multiple intersections of the N-round consensus proposals in batches as shown in Figure 6 , transaction execution operation and transaction execution confirmation operation.
  • FIG. 6 takes the N-round consensus proposal including the first intersection, the second transaction set and the third transaction set as an example.
  • the consensus node is set with the first CPU thread responsible for performing consensus operations (it can also be a CPU core, which will not be described here), the second CPU thread responsible for performing transaction execution operations and transaction execution confirmation operations, and the second CPU thread responsible for performing block writing operations.
  • the third CPU thread, the first CPU thread, the second CPU thread and the third CPU thread are parallel to each other.
  • the consensus node executes the consensus operation of the first transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution confirmation operation of the first transaction set through the second CPU thread.
  • the consensus node starts to execute the consensus operation of the second transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution of the second transaction set through the second CPU thread Confirm the action.
  • the consensus node starts to execute the consensus operation of the third transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution of the third transaction set through the second CPU thread Confirm the action.
  • the consensus node starts to execute the block writing operation on the first transaction set, the second transaction set and the third transaction set through the third CPU thread.
  • the consensus node can also As shown in Figure 7, on the basis of completing consensus operations, transaction execution operations, and transaction execution confirmation operations for multiple intersections of the N-th round of consensus proposals in batches, set more CPU threads to implement:
  • the transaction set executes the transaction execution operation, if there is a second transaction set that has not yet completed the consensus in the consensus proposal of the Nth round, then the consensus operation is performed on the second transaction set in parallel.
  • the transaction processing method shown in Figure 7 further utilizes the advantages of CPU multi-core and multi-threading to improve the efficiency of blockchain transactions in a parallel manner.
  • the transaction execution operations of the second transaction set should be executed after the transaction execution operations of the first transaction set are completed.
  • the transaction execution operations of the third transaction set should be executed after Execute after the transaction execution operation of the second transaction set is completed.
  • the method in this application scenario executes the consensus operation on the first transaction set proposed by the N-th round of consensus, it also executes the transaction execution operation on the first transaction set in parallel, thereby improving the transaction execution confirmation efficiency of the first transaction set , so that client users can know the transaction execution results as soon as possible, which can improve user experience to a certain extent.
  • the parallel operation of consensus operation and transaction execution operation also shortens the time-consuming on-chain of blockchain transactions, which means that the business throughput of blockchain has also been improved.
  • the execution of the transaction by the consensus node will not waste time. This is because the consensus proposal timeout period set by the existing blockchain is generally several seconds to tens of seconds, and the consensus node has sufficient time to complete the transaction execution operation during the timeout period.
  • the consensus node can also cache the generated temporary block for use in subsequent rounds of consensus proposals.
  • the timeout of the Nth round of consensus proposal as an example, after the consensus node generates the temporary block of the Nth round of consensus proposal, if the timeout of the Nth round of consensus proposal ends, the temporary block of the first transaction set can be cached first , and when performing the consensus operation on the transaction set proposed by the N+1 round consensus, if the consensus proposal of the N+1 round is consistent with the transaction set proposed by the N round consensus (that is, the consensus node of the N+1 round consensus proposal Initiate a consensus proposal of the same transaction set), skip the transaction execution operation on the second transaction set, and use the cached temporary block of the first transaction set as the temporary block of the second transaction set.
  • the consensus node can choose to delete the cached temporary block of the first transaction set to clear the cache space.
  • the above process is applicable to the scenario where the consensus master node recovers and re-initiates the consensus proposal after a downtime in the consensus stage, or the consensus proposal timeout triggers the view switch of the blockchain, and the new consensus master node restarts the transaction set proposed by the original consensus Scenarios for initiating consensus proposals.
  • FIG. 8 is a schematic structural diagram of a block chain node 800 according to an embodiment of the present invention, including:
  • the transaction consensus module 810 executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
  • the transaction execution module 820 executes the transaction execution operation of the first transaction set
  • the transaction execution confirmation module 830 after the execution of the transaction execution operation, initiates the transaction execution confirmation operation of the first transaction set;
  • the block writing module 840 executes a block writing operation on all transaction sets proposed by the N-th round of consensus after reaching a consensus on all transaction sets proposed by the N-th round of consensus and completing transaction confirmation operations.
  • the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving transaction finalization.
  • the confirmation efficiency is high, so that the client user can know the transaction execution result as soon as possible, which improves the user experience to a certain extent.
  • the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
  • the transaction execution confirmation module 830 is specifically configured to: send the transaction execution confirmation message of the first transaction set to other consensus nodes of the blockchain, the transaction execution confirmation message carrying the hash of the first transaction set and receiving the transaction execution confirmation message carrying the hash information of the first transaction set sent by other consensus nodes, and receiving the hash information of the same first transaction set sent by 2f other consensus nodes After the transaction execution confirmation message of the information, the transaction execution of the first transaction set is confirmed, and f is the number of Byzantine fault tolerance set by the blockchain.
  • the block writing module 840 is specifically configured to: generate a temporary block proposed by the N-round consensus after completing the transaction confirmation operation for all transaction sets proposed by the N-round consensus; If all transaction sets proposed by the Nth round of consensus have reached a consensus, the consensus node will wait; if a consensus has been reached on all transaction sets proposed by the Nth round of consensus, then the consensus node will The temporary block proposed by the consensus round is written into the blockchain.
  • the transaction execution module 820 executes the transaction execution operation of the first transaction set in parallel.
  • the consensus node performs a consensus operation based on the practical Byzantine fault-tolerant PBFT protocol; if the consensus node is the consensus master node of the block chain, the transaction execution module 820 executes the first transaction set in the transaction consensus module 810. During the consensus operation of the Pre-Prepare stage of the PBFT protocol, the transaction execution operation of the first transaction set is executed in parallel; if the consensus node is used as the consensus backup node of the block chain, the transaction execution module 820 is When the consensus module 810 executes the consensus operation of the Prepare phase of the PBFT protocol on the first transaction set, it executes the transaction execution operation of the first transaction set in parallel.
  • the transaction execution module 820 completes the transaction execution operation performed on the first transaction set before the transaction consensus module 810 executes the consensus operation of the guaranteed Commit phase of the PBFT protocol on the first transaction set; the transaction execution confirmation module 830 When the transaction execution module 820 executes the consensus operation of the Commit stage of the PBFT on the first transaction set, it sends the Commit message as the transaction execution confirmation message of the first transaction set to other members of the block chain.
  • a consensus node wherein the Commit message sent by the consensus node carries hash information of the first transaction set generated by the consensus node.
  • the consensus node if the consensus proposal of the Nth round only includes the first transaction set, the consensus node generates the The temporary block proposed by the N-round consensus, wherein the Commit message sent by the consensus node carries the hash information of the temporary block proposed by the N-round consensus generated by the consensus node, and the N-round consensus
  • the hash information of the proposed temporary block is used as the hash information of the first transaction set.
  • the N-th round of consensus proposes multiple transaction sets including the first transaction set
  • the consensus node executes the transaction execution operation on the first transaction set
  • a second transaction set if there is a second transaction set, Then, a consensus operation is performed on the second transaction set in parallel, where the second transaction set is a transaction set that has not yet completed consensus in the N round of consensus proposals.
  • block chain node of the embodiment of the present invention also includes:
  • the caching module after the transaction execution module 820 generates the temporary block proposed by the N round consensus, if the N round consensus proposal ends overtime, then cache the temporary block proposed by the N round consensus; Specifically, when the transaction execution module 820 performs the consensus operation on the consensus proposal of the N+1 round, if the consensus proposal of the N+1 round is consistent with the transaction set proposed by the consensus proposal of the Nth round, skip the operation of the consensus proposal of the N+1 round.
  • the transaction set proposed by the N+1 round of consensus executes the transaction execution process, and the temporary block proposed by the Nth round of consensus is used as the temporary block proposed by the N+1 round of consensus.
  • the cache module deletes the temporary block that can delete the cached temporary block of the consensus proposal of the N round.
  • the blockchain node in the embodiment of this specification can be used as the execution body of the transaction processing method shown in FIG. 1 above, so it can realize the functions realized by the transaction processing method in FIG. 1 . Since the principle is the same, this article will not repeat them.
  • FIG. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
  • the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory.
  • the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory.
  • RAM random-Access Memory
  • non-volatile memory such as at least one disk memory.
  • the electronic device may also include hardware required by other services.
  • the processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc.
  • the bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 9 , but it does not mean that there is only one bus or one type of bus.
  • Memory for storing programs.
  • the program may include program code, and the program code includes computer operation instructions.
  • Storage which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
  • the processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a blockchain transaction processing device on a logical level.
  • the transaction processing device can refer to a blockchain node or a A component in a blockchain node.
  • the processor executes the program stored in the memory, and is specifically used to perform the following operations:
  • the consensus node of the block chain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving the transaction finality.
  • Optimized confirmation efficiency so that client users can know the transaction execution results as soon as possible, which improves the user experience to a certain extent.
  • the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
  • each step of the above method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software.
  • the above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
  • DSP Digital Signal Processor
  • ASIC Application Specific Integrated Circuit
  • FPGA Field-Programmable Gate Array
  • a general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like.
  • the steps of the methods disclosed in the embodiments of this specification can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor.
  • the software module may be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register.
  • the storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
  • the electronic equipment in this specification does not exclude other implementations, such as logic devices or the combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, It can also be a hardware or logic device.
  • the embodiment of this specification also proposes a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions.
  • the portable electronic device can be made to execute the method of the embodiment shown in Figure 1, and is specifically used to perform the following steps:

Abstract

Embodiments of the present description provide a transaction processing method of a blockchain, a blockchain node, and an electronic device. The method comprises: a consensus node of a blockchain executes a consensus operation of a first transaction set in an Nth round of consensus proposal, wherein N is a positive integer; the consensus node executes a transaction execution operation of the first transaction set; after the execution of the transaction execution operation is completed, the consensus node initiates a transaction execution determination operation for the first transaction set; and after a consensus is reached for all the transaction sets in the Nth round of consensus proposal and the transaction execution determination operations are finished, the consensus node executes a block writing operation for all the transaction sets in the Nth round of consensus proposal.

Description

一种区块链的交易处理方法、区块链节点及电子设备A block chain transaction processing method, block chain node and electronic equipment
本申请要求于2022年02月24日提交中国专利局、申请号为202210178246.2、发明名称为“一种区块链的交易处理方法、区块链节点及电子设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。This application claims the priority of the Chinese patent application submitted to the China Patent Office on February 24, 2022, with the application number 202210178246.2, and the title of the invention is "a blockchain transaction processing method, blockchain node and electronic equipment", The entire contents of which are incorporated by reference in this application.
技术领域technical field
本文件属于区块链技术领域,尤其涉及一种区块链的交易处理方法、区块链节点及电子设备。This document belongs to the field of block chain technology, and in particular relates to a block chain transaction processing method, block chain nodes and electronic equipment.
背景技术Background technique
区块链由于具有开放性、不可篡改、去中心化等优点,越来越受到各行各业的青睐。目前区块链交易的处理流程主要包括:交易共识、交易执行、交易执行确认以及交易写块四个阶段。现有技术中,这四个阶段是按序串行执行的,也就是说区块链客户端发起交易后,无法立刻获知交易的执行结果(交易需要先完成共识后再被执行),从而影响了用户体验。Due to its advantages of openness, non-tamperability, and decentralization, blockchain is increasingly favored by all walks of life. At present, the processing flow of blockchain transactions mainly includes four stages: transaction consensus, transaction execution, transaction execution confirmation, and transaction writing block. In the existing technology, these four stages are executed sequentially, that is to say, after the blockchain client initiates the transaction, the execution result of the transaction cannot be known immediately (the transaction needs to complete the consensus before being executed), which affects user experience.
在未来阶段,区块链业务会呈爆发性增长,客户端确认交易执行结果的延迟问题也会突显出来。为此,有必要提出一种可以提高区块链交易的执行结果确认效率的技术方案。In the future stage, the blockchain business will show explosive growth, and the delay problem of the client confirming the transaction execution result will also be highlighted. For this reason, it is necessary to propose a technical solution that can improve the efficiency of confirmation of execution results of blockchain transactions.
发明内容Contents of the invention
本说明书实施例目的是提供一种区块链交易的处理方法、区块链节点及电子设备,能够提高区块链交易的执行结果确认效率。The purpose of the embodiments of this specification is to provide a processing method of blockchain transactions, blockchain nodes and electronic equipment, which can improve the efficiency of confirmation of execution results of blockchain transactions.
为了实现上述目的,本说明书实施例是这样实现的:In order to achieve the above purpose, the embodiment of this description is achieved as follows:
第一方面,提出了一种区块链的交易处理方法,包括:In the first aspect, a blockchain transaction processing method is proposed, including:
区块链的共识节点执行第N轮共识提议中第一交易集的交易执行操作,其中,N为正整数;The consensus node of the blockchain executes the transaction execution operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
所述共识节点执行第N轮共识提议中第一交易集的共识操作;The consensus node executes the consensus operation of the first transaction set in the N round consensus proposal;
所述共识节点在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, the consensus node initiates a transaction execution determination operation for the first transaction set;
所述共识节点在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After the consensus node has reached a consensus on all the transaction sets proposed by the N-round consensus and completed the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus.
第二方面,提出了一种区块链的交易处理装置,包括:In the second aspect, a block chain transaction processing device is proposed, including:
交易共识模块,执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;The transaction consensus module executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
交易执行模块,执行所述第一交易集的交易执行操作;The transaction execution module executes the transaction execution operation of the first transaction set;
交易执行确认模块,在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;The transaction execution confirmation module, after the execution of the transaction execution operation is completed, initiates the transaction execution confirmation operation of the first transaction set;
写块模块,在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。The block writing module executes a block writing operation on all transaction sets proposed by the N-th round of consensus after reaching a consensus on all transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation.
第三方面,提出了一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:In a third aspect, an electronic device including: a memory, a processor, and a computer program stored on the memory and operable on the processor is proposed, and the computer program is executed by the processor:
执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
执行所述第一交易集的交易执行操作;executing a transaction execution operation of the first transaction set;
在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, initiate the transaction execution determination operation of the first transaction set;
在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation, perform a block write operation on all the transaction sets proposed by the N-th round of consensus.
第四方面,提出了一种计算机可读存储介质,所述计算机可读存储介质存储一个或多个程序,所述一个或多个程序当被包括多个应用程序的电子设备执行时,使得所述电子设备执行以下操作:In a fourth aspect, a computer-readable storage medium is proposed, the computer-readable storage medium stores one or more programs, and when the one or more programs are executed by an electronic device including a plurality of application programs, the The electronic device performs the following operations:
执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
执行所述第一交易集的交易执行操作;executing a transaction execution operation of the first transaction set;
在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, initiate the transaction execution determination operation of the first transaction set;
在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation, perform a block write operation on all the transaction sets proposed by the N-th round of consensus.
基于本说明书实施例的方案,区块链的共识节点在完成交易的共识操作前,即可提前对交易执行交易执行操作,并在交易执行操作完成后发起交易执行确定操作,从而提高交易最终化的确认效率,进而使客户端用户能够尽早得知交易执行结果,在一定程度上改善了用户体验。此外,交易执行确认的提前也会更早的执行写块操作,使得区块链的交易上链效率也得了提升,进而提高了区块链的业务吞吐量,符合未来区块链业务高并发的发展趋势。Based on the scheme of the embodiment of this specification, the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving the finalization of the transaction. The confirmation efficiency is high, so that the client user can know the transaction execution result as soon as possible, which improves the user experience to a certain extent. In addition, the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
附图说明Description of drawings
为了更清楚地说明本说明书实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本说明书实施例中记载的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。In order to more clearly illustrate the technical solutions in the embodiments of this specification or the prior art, the following will briefly introduce the drawings that need to be used in the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments described in the embodiments of this specification. For those skilled in the art, other drawings can also be obtained based on these drawings without any creative effort.
图1为本说明书实施例的交易处理方法的流程示意图。FIG. 1 is a schematic flowchart of a transaction processing method according to an embodiment of this specification.
图2为传统PBFT协议的流程示意图。FIG. 2 is a schematic flow diagram of a traditional PBFT protocol.
图3为本说明书实施例的交易处理方法执行PBFT协议交易上链的第一种流程示意图。Fig. 3 is a schematic diagram of the first type of process for executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
图4为本说明书实施例的交易处理方法执行PBFT协议交易上链的第二种流程示意图。FIG. 4 is a schematic diagram of a second flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
图5为本说明书实施例的交易处理方法执行PBFT协议交易上链的第三种流程示意图。Fig. 5 is a schematic diagram of a third flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method according to the embodiment of this specification.
图6为本说明书实施例的交易处理方法执行PBFT协议交易上链的第四种流程示意图。Fig. 6 is a schematic diagram of a fourth flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
图7为本说明书实施例的交易处理方法执行PBFT协议交易上链的第五种流程示意图。FIG. 7 is a schematic diagram of a fifth flow chart of executing a PBFT protocol transaction on-chain in the transaction processing method of the embodiment of this specification.
图8为本说明书实施例的区块链节点的结构示意图。FIG. 8 is a schematic structural diagram of a blockchain node in an embodiment of this specification.
图9为本说明书实施例的电子设备的结构示意图。FIG. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present specification.
具体实施方式Detailed ways
为了使本技术领域的人员更好地理解本说明书中的技术方案,下面将结合本说明书实施例中的附图,对本说明书实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本说明书一部分实施例,而不是全部的实施例。基于本说明书中的实施例,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本说明书保护的范围。In order to enable those skilled in the art to better understand the technical solutions in this specification, the technical solutions in the embodiments of this specification will be clearly and completely described below in conjunction with the drawings in the embodiments of this specification. Obviously, the described The embodiments are only some of the embodiments in this specification, not all of them. Based on the embodiments in this specification, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the protection scope of this specification.
如前所述,区块链交易的处理流程主要包括:交易共识、交易执行、交易执行确认以及交易写块四个阶段。现有技术中,这四个阶段是按序串行执行的,也就是说,区块链的客户端发起交易后,交易先 要完成共识再进行执行。这一样来,客户端无法立刻获知交易的执行结果,而这个延迟问题是能够被客户端用户感知到的,如果延迟严重则会影响用户体验。针对这一问题,本文件旨在提出一种提高区块链交易的执行结果确认效率的技术方案。As mentioned above, the processing flow of blockchain transactions mainly includes four stages: transaction consensus, transaction execution, transaction execution confirmation, and transaction block writing. In the existing technology, these four stages are executed sequentially, that is to say, after the blockchain client initiates a transaction, the transaction must first complete the consensus before execution. In this way, the client cannot immediately know the execution result of the transaction, and this delay problem can be perceived by the client user. If the delay is serious, it will affect the user experience. In response to this problem, this document aims to propose a technical solution to improve the efficiency of confirmation of execution results of blockchain transactions.
图1是本说明书实施例区块链交易的处理方法的流程图。图1所示的方法可以由下文相对应的区块链节点执行,包括如下步骤:Fig. 1 is a flow chart of a processing method of a blockchain transaction according to an embodiment of this specification. The method shown in Figure 1 can be executed by the corresponding blockchain nodes below, including the following steps:
S102,区块链的共识节点执行第N轮共识提议中第一交易集的共识操作,N为正整数。S102, the consensus node of the blockchain executes the consensus operation of the first transaction set in the consensus proposal of the Nth round, where N is a positive integer.
其中,第一交易集可以包含有第N轮共识提议中全部需要共识的交易,也可以包含第N轮共识提议中部分需要共识的交易,这里本文不作具体限定。Among them, the first transaction set may include all transactions requiring consensus in the Nth round of consensus proposals, or some transactions requiring consensus in the Nth round of consensus proposals, which is not specifically limited here.
本步骤中,若共识节点作为区块链的共识主节点,则需要创建第N轮共识提议,并第N轮共识提议发送至区块链的共识备份节点。当共识备份节点获得第N轮共识提议后,区块链的共识节点(包含共识主节点和共识备份节点)开始对第一交易集执行共识操作。同理,若共识节点为区块链的共识备份节点,则在接收到区块链的共识主节点发送的第N轮共识提议后,再对对第一交易集执行共识操作。In this step, if the consensus node is the consensus master node of the blockchain, it is necessary to create the N-round consensus proposal and send the N-round consensus proposal to the consensus backup node of the blockchain. When the consensus backup node obtains the N round of consensus proposals, the blockchain consensus nodes (including the consensus master node and the consensus backup node) begin to perform consensus operations on the first transaction set. Similarly, if the consensus node is the consensus backup node of the blockchain, it will perform consensus operations on the first transaction set after receiving the Nth round of consensus proposals sent by the consensus master node of the blockchain.
S104,共识节点执行第一交易集的交易执行操作。S104, the consensus node executes the transaction execution operation of the first transaction set.
应理解,本说明书实施例中,共识节点不需要第一交易集达成共识,即可对第一交易集执行交易执行操作。It should be understood that, in the embodiment of this specification, the consensus node can execute the transaction execution operation on the first transaction set without reaching a consensus on the first transaction set.
具体地,共识节点可以在第N轮共识提议发起后,执行第一交易集的共识操作时,并行执行第一交易集的交易执行操作。应理解,共识节点执行的共识操作主要包括:共识校验以及共识消息的收发。也就是说,在并行方式下,共识节点至少可以利用等待接收其他共识节点发送共识消息的时间来执行交易执行操作,从而提高区块链交易的处理效率。Specifically, the consensus node can execute the transaction execution operation of the first transaction set in parallel when executing the consensus operation of the first transaction set after the N-round consensus proposal is initiated. It should be understood that the consensus operations performed by consensus nodes mainly include: consensus verification and consensus message sending and receiving. That is to say, in the parallel mode, consensus nodes can at least use the time of waiting to receive consensus messages sent by other consensus nodes to perform transaction execution operations, thereby improving the processing efficiency of blockchain transactions.
S106,共识节点在交易执行操作执行完毕后,发起对第一交易集的交易执行确定操作。S106. After the transaction execution operation is completed, the consensus node initiates a confirmation operation on the transaction execution of the first transaction set.
应理解,交易执行确定操作是指确认交易执行结果的操作。在该过程中,共识节点在完成第一交易集的交易执行操作后,会向区块链的其它共识节点发送第一交易集的交易执行确认消息,交易执行确认消息携带有第一交易集的哈希信息;同理,其它共识节点在完成第一交易集的交易执行操作,也会向本步骤中的共识节点发送第一交易集的交易执行确认消息。It should be understood that the transaction execution determination operation refers to the operation of confirming the transaction execution result. In this process, after the consensus node completes the transaction execution operation of the first transaction set, it will send the transaction execution confirmation message of the first transaction set to other consensus nodes in the blockchain, and the transaction execution confirmation message carries the transaction execution confirmation message of the first transaction set. Hash information; similarly, when other consensus nodes complete the transaction execution operation of the first transaction set, they will also send the transaction execution confirmation message of the first transaction set to the consensus node in this step.
当本步骤中的共识节点收到2f个其它共识节点发送的携带有相同第一交易集的哈希信息的交易执行确认消息后,即可确认第一交易集的交易执行(f为所述区块链设置的拜占庭容错数量)。应理解,在第一交易集的交易执行被确认后,第一交易集中的交易执行结果即可反馈至对应的客户端,并被客户端用户提前感知。When the consensus node in this step receives the transaction execution confirmation message carrying the hash information of the same first transaction set sent by 2f other consensus nodes, it can confirm the transaction execution of the first transaction set (f is the area Amount of Byzantine Fault Tolerance set by the blockchain). It should be understood that after the transaction execution in the first transaction set is confirmed, the transaction execution result in the first transaction set can be fed back to the corresponding client and be perceived by the client user in advance.
S108,共识节点在对第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对第N轮共识提议的所有交易集执行写块操作。S108. After the consensus node reaches a consensus on all the transaction sets proposed by the N-round consensus and completes the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus.
应理解,传统串行方式的写块操作需要在第N轮共识提议的所有交易集的交易执行结果确认后才能执行,而基于本发明实施例的上述步骤可以提前完成交易执行操作和交易执行确认操作,这样一来写块操作也会随之提前执行,进而缩短了区块链交易上链的耗时,可提高区块链的交易处理效率。It should be understood that the block writing operation in the traditional serial mode can only be executed after the transaction execution results of all transaction sets proposed by the N round of consensus are confirmed, while the above steps based on the embodiment of the present invention can complete the transaction execution operation and transaction execution confirmation in advance In this way, the block writing operation will also be executed in advance, thereby shortening the time-consuming of blockchain transactions on the chain, and improving the transaction processing efficiency of the blockchain.
此外,为了进一步提高区块链交易的处理效率,共识节点在对第N轮共识提议的所有交易集都完成交易执行确认操作后,可以生成第N轮共识提议的临时区块;此时,如果尚未对第N轮共识提议的所有交易集都达成共识,则共识节点进行等待;如果已经对第N轮共识提议的所有交易集都达成共识,则共识节点直接将第N轮共识提议的临时区块写入至区块链中,从而节省写块操作的耗时。In addition, in order to further improve the processing efficiency of blockchain transactions, the consensus node can generate a temporary block proposed by the N-round consensus after completing the transaction confirmation operation for all transaction sets proposed by the N-round consensus; at this time, if If a consensus has not been reached on all transaction sets proposed by the N round of consensus, the consensus node will wait; if a consensus has been reached on all transaction sets proposed by the N round consensus, the consensus node will directly transfer the temporary area The block is written into the blockchain, thus saving the time-consuming operation of writing blocks.
由此可见,基于本说明书实施例的方法,区块链的共识节点在完成交易的共识操作前,即可提前对交易执行交易执行操作,并在交易执行操作完成后发起交易执行确定操作,从而提高交易最终化的确认效率,进而使客户端用户能够尽早得知交易执行结果,在一定程度上改善了用户体验。此外,交易执行确认的提前也会更早的执行写块操作,使得区块链的交易上链效率也得了提升,进而提高了区块链的业务吞吐量,符合未来区块链业务高并发的发展趋势。It can be seen that, based on the method of the embodiment of this specification, the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, so that Improve the confirmation efficiency of transaction finalization, so that client users can know the transaction execution results as soon as possible, which improves the user experience to a certain extent. In addition, the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
下面结合实际的应用场景对本说明书实施例的方法进行详细介绍。The methods in the embodiments of this specification will be described in detail below in combination with actual application scenarios.
本应用场景中,区块链的共识节点基于实用拜占庭容错(PBFT,Practical Byzantine Fault Tolerance)协议执行共识操作。In this application scenario, the consensus nodes of the blockchain perform consensus operations based on the Practical Byzantine Fault Tolerance (PBFT) protocol.
其中,传统PBFT协议的共识流程主要包括:Among them, the consensus process of the traditional PBFT protocol mainly includes:
预准备pre-prepare阶段:Pre-prepare pre-prepare stage:
主共识节点收到来自Client的一个请求,并分配一个编号给这个请求,共识主节点广播一条pre-prepare消息给共识备份节点,这个pre-prepare消息主要包含当前共识的视图(view)、共识主节点的摘要(digest)以及上以区块哈信息等。The main consensus node receives a request from the Client and assigns a number to the request. The consensus main node broadcasts a pre-prepare message to the consensus backup node. This pre-prepare message mainly includes the current consensus view (view), the consensus main The node's digest (digest) and the above block hash information, etc.
每一个共识备份节点在接收到pre-prepare消息后,对pre-prepare消息中的信息进行校验。如果检验成功,则直接进入prepare阶段。如果检验失败,则共识流程结束。After receiving the pre-prepare message, each consensus backup node verifies the information in the pre-prepare message. If the test is successful, it goes directly to the prepare phase. If the verification fails, the consensus process ends.
prepare阶段:prepare stage:
所有参与共识的共识备份节点中的每一个在接收到pre-prepare消息后,检查pre-prepare消息是否合法。如果pre-prepare消息合法,那么该共识提议在replica上的状态被确定为prepared,共识备份节点将该pre-prepare消息添加到本地Log中,并发送prepare消息给其他参与共识的共识备份节点。After receiving the pre-prepare message, each of the consensus backup nodes participating in the consensus checks whether the pre-prepare message is legal. If the pre-prepare message is legal, then the consensus proposal is determined to be prepared on the replica, and the consensus backup node adds the pre-prepare message to the local Log, and sends the prepare message to other consensus backup nodes participating in the consensus.
commit阶段:Commit stage:
所有共识节点中的每一个在进入prepared状态后,发送commit消息给其他共识节点,并将自己发送的commit消息添加到本地Log中(代表自己的认可)。当一个共识节点发现有一个quorum(quorum是为了能够确保所有replica数据一致性要求和容错要求需要的一定数量replica的集合)同意编号分配时,它就会广播一条commit消息给其它所有节点。与此同时也会陆续收到来自其他节点的commit消息,如果每个节点收到了不包含自身发送的2f个commit消息(f是联盟链中作恶节点的数量,2f个commit消息中不包含自身发送的commit消息),就说名该共识节点拥有了一个名为committed certificate的证书,请求在这个共识节点上达到了committed状态。此时只通过这一个共识节点,就能断定该请求已经在一个quorum中到达了prepared状态,即同一个quorum的所有共识节点都同意了编号n的分配。当Client发起的请求到达commited状态后,说明已经达成全网共识。Each of all consensus nodes sends a commit message to other consensus nodes after entering the prepared state, and adds the commit message sent by itself to the local Log (representing its own approval). When a consensus node finds that there is a quorum (quorum is a set of a certain number of replicas required to ensure all replica data consistency requirements and fault tolerance requirements) agreeing to number assignment, it will broadcast a commit message to all other nodes. At the same time, it will also receive commit messages from other nodes one after another. If each node receives 2f commit messages not including those sent by itself (f is the number of malicious nodes in the alliance chain, and the 2f commit messages do not include those sent by itself commit message), it means that the consensus node has a certificate named committed certificate, and the request has reached the committed state on this consensus node. At this time, only through this consensus node, it can be concluded that the request has reached the prepared state in a quorum, that is, all consensus nodes of the same quorum have agreed to the allocation of number n. When the request initiated by the Client reaches the committed state, it means that the consensus of the whole network has been reached.
以上是传统PBFT协议的流程介绍。本应用场景在对某一交易集执行PBFT协议的共识阶段,引入对该交易集的交易执行操作和交易执行确定操作。The above is the process introduction of the traditional PBFT protocol. In this application scenario, in the consensus stage of executing the PBFT protocol for a certain transaction set, the transaction execution operation and transaction execution confirmation operation of the transaction set are introduced.
这里以第N轮共识提议为例,在上述基础之上,本应用场景的共识主节点需要从自身交易池中选取出第一交易集发起第N轮共识提议,并在Pre-Prepare阶段,通过Pre-Prepare消息将第一交易集的交易数据发送至区块链的共识备份节点。Here we take the Nth round of consensus proposal as an example. On the basis of the above, the consensus master node in this application scenario needs to select the first transaction set from its own transaction pool to initiate the Nth round of consensus proposal, and in the Pre-Prepare phase, pass The Pre-Prepare message sends the transaction data of the first transaction set to the consensus backup node of the blockchain.
这里需要说明的是,共识节点在确定第一交易集的交易数据后,即可对第一交易集执行交易执行操作。也就是说,在本应用场景中,共识主节点最早在Pre-Prepare阶段即可对第一交易集执行交易执行操作,而共识备份节点则需要通过Pre-Prepare消息获得第一交易集的交易数据后,在Prepare阶段对第一交易集执行交易执行操作。What needs to be explained here is that after the consensus node determines the transaction data of the first transaction set, it can execute the transaction execution operation on the first transaction set. That is to say, in this application scenario, the consensus master node can execute transactions on the first transaction set as early as the Pre-Prepare stage, and the consensus backup node needs to obtain the transaction data of the first transaction set through the Pre-Prepare message After that, execute the transaction execution operation on the first transaction set in the Prepare phase.
通过上述设计,区块链的各个共识节点可以在Commit阶段前生成第一交易集的临时区块。这样一来,可以复用Commit消息完成交易执行确认操作。即,区块链的各共识节点在Commit阶段,通过Commit消息将第一交易集的临时区块的哈希信息发送至区块链的其他区块链节点。之后,任意共识节点若接收到2f个其他共识节点发送的携带有相同第一交易集临时区块的哈希信息的Commit消息,则确认第一交易集的交易执行。Through the above design, each consensus node of the blockchain can generate a temporary block of the first transaction set before the Commit phase. In this way, the Commit message can be reused to complete the transaction execution confirmation operation. That is, each consensus node of the blockchain sends the hash information of the temporary block of the first transaction set to other blockchain nodes of the blockchain through a Commit message in the Commit phase. Afterwards, any consensus node will confirm the transaction execution of the first transaction set if it receives the Commit message from 2f other consensus nodes carrying the hash information of the temporary block of the same first transaction set.
这里为方便理解,假设有区块链4个共识节点:P1、P2、P3、P4,其中,P1为第N轮共识提议的共识主节点,P2、P3、P4为第N轮共识提议的共识备份节点,P1发起的第N轮共识提议中只包括第一交易集。传统的基于PBFT协议的交易上链流程如可以如图2所示,是以串行方式依次对第一交易集执行pre-prepare阶段的共识操作、prepare阶段的共识操作、Commit阶段的共识操作、交易执行操作\交易执行确认操作(阴影填充的方块表示)以及写块操作(无填充的方块表示)。For the convenience of understanding here, it is assumed that there are four consensus nodes in the blockchain: P1, P2, P3, and P4. Among them, P1 is the consensus master node proposed by the N-round consensus, and P2, P3, and P4 are the consensus proposed by the N-round consensus As a backup node, only the first transaction set is included in the Nth round of consensus proposals initiated by P1. As shown in Figure 2, the traditional transaction on-chain process based on the PBFT protocol is to execute the consensus operation of the pre-prepare stage, the consensus operation of the prepare stage, the consensus operation of the Commit stage, and Transaction execution operation\transaction execution confirmation operation (represented by shaded squares) and write block operation (represented by unfilled squares).
本说明书实施例的应用场景基于PBFT协议的交易上链流程则如图3所示。也就是P1在对执行PBFT 协议的Commit阶段的共识操作前,直接生成第N轮共识提议的临时区,并在Commit阶段发送携带有该第N轮共识提议的临时区块的哈希信息Commit消息给其他共识节点。应理解,由于第N轮共识提议中只包括第一交易集,因此第N轮共识提议的临时区块的哈希信息即为第一交易集的哈希信息,共识节点在Commit阶段若接收到2f个其它共识节点发送的携带有相同第N轮共识提议的临时区块的哈希信息的Commit消息,即可确认第N轮共识提议中所有交易的最终化执行,并直接将第N轮共识提议的临时区块写入至区块链中。The application scenario of the embodiment of this specification is shown in Figure 3 based on the transaction on-chain process of the PBFT protocol. That is, before the consensus operation of the Commit phase of the PBFT protocol, P1 directly generates the temporary area proposed by the Nth round of consensus, and sends a Commit message carrying the hash information of the temporary block proposed by the Nth round of consensus in the Commit phase to other consensus nodes. It should be understood that since the consensus proposal of the Nth round only includes the first transaction set, the hash information of the temporary block proposed by the Nth round consensus is the hash information of the first transaction set. If the consensus node receives The Commit message sent by 2f other consensus nodes carrying the hash information of the temporary block of the same N-round consensus proposal can confirm the final execution of all transactions in the N-round consensus proposal, and directly transfer the N-round consensus proposal The proposed interim block is written to the blockchain.
对比图2和图3可以看出,本说明书实施例的应用场景在不引入额外消息开销的基础之上,在共识阶段即可完成交易执行操作和后续的交易执行确认操作。Comparing Figure 2 and Figure 3, it can be seen that the application scenario of the embodiment of this specification can complete the transaction execution operation and subsequent transaction execution confirmation operation in the consensus stage without introducing additional message overhead.
当然,以上是对以共识提议仅包含有一个交易集时,共识节点如何执行交易执行操作和交易执行确认操作的示例。除了图2所示外,本发明实施例方法还可以如图4所示,共识主节点在Prepare阶段和共识备份节点一起执行交易执行操作;或者如图5所示,共识主节点和共识备份节点在Prepare阶段后执行交易执行操作,并在完成交易执行操作后再进入Commit阶段。应理解,不管何种变化,但凡是在某一交易集的共识阶段内,并行对该交易集并行执行交易执行操作和交易执行确认都应属于本文件的保护范围之内。Of course, the above is an example of how the consensus node executes the transaction execution operation and the transaction execution confirmation operation when the consensus proposal contains only one transaction set. In addition to what is shown in Figure 2, the method of the embodiment of the present invention can also be shown in Figure 4, where the consensus master node and the consensus backup node perform transaction execution operations together in the Prepare phase; or as shown in Figure 5, the consensus master node and the consensus backup node Execute the transaction execution operation after the Prepare phase, and enter the Commit phase after completing the transaction execution operation. It should be understood that no matter what the changes are, within the consensus stage of a certain transaction set, the parallel execution of transaction execution operations and transaction execution confirmation on the transaction set shall fall within the scope of protection of this document.
基于上述原理延伸至第N轮共识提议包括第一交易集在内的多个交易集时,共识节点则可以如图6所示,分批次对第N轮共识提议的多个交集完成共识操作、交易执行操作和交易执行确认操作。When the above principles are extended to multiple transaction sets including the first transaction set proposed by the N-round consensus, the consensus nodes can complete consensus operations on multiple intersections of the N-round consensus proposals in batches as shown in Figure 6 , transaction execution operation and transaction execution confirmation operation.
图6以第N轮共识提议包括第一交集、第二交易集合和第三交易集为示例。共识节点设置有负责执行共识操作的第一CPU线程(也可以是CPU核心,这里不再举例赘述),负责执交易执行操作和交易执行确认操作的第二CPU线程,以及负责执行写块操作的第三CPU线程,第一CPU线程、第二CPU线程和第三CPU线程之间相互并行。FIG. 6 takes the N-round consensus proposal including the first intersection, the second transaction set and the third transaction set as an example. The consensus node is set with the first CPU thread responsible for performing consensus operations (it can also be a CPU core, which will not be described here), the second CPU thread responsible for performing transaction execution operations and transaction execution confirmation operations, and the second CPU thread responsible for performing block writing operations. The third CPU thread, the first CPU thread, the second CPU thread and the third CPU thread are parallel to each other.
首先,共识节点通过第一CPU线程执行第一交易集的共识操作,同时通过第二CPU线程执行第一交易集的交易执行操作和交易执行确认操作。在第一交易集完成共识且交易执行结果被确认后,共识节点开始通过第一CPU线程执行第二交易集的共识操作,同时通过第二CPU线程执行第二交易集的交易执行操作和交易执行确认操作。在第二交易集完成共识且交易执行结果被确认后,共识节点开始通过第一CPU线程执行第三交易集的共识操作,同时通过第二CPU线程执行第三交易集的交易执行操作和交易执行确认操作。在第三交易集完成共识且交易执行结果被确认后,共识节点开始通过第三CPU线程生再对第一交易集、第二交易集和第三交易集执行写块操作。First, the consensus node executes the consensus operation of the first transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution confirmation operation of the first transaction set through the second CPU thread. After the first transaction set completes the consensus and the transaction execution result is confirmed, the consensus node starts to execute the consensus operation of the second transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution of the second transaction set through the second CPU thread Confirm the action. After the second transaction set completes the consensus and the transaction execution result is confirmed, the consensus node starts to execute the consensus operation of the third transaction set through the first CPU thread, and at the same time executes the transaction execution operation and transaction execution of the third transaction set through the second CPU thread Confirm the action. After the third transaction set completes the consensus and the transaction execution result is confirmed, the consensus node starts to execute the block writing operation on the first transaction set, the second transaction set and the third transaction set through the third CPU thread.
此外,如果第N轮共识提议包括第一交易集在内的多个交易集(依然以第N轮共识提议包括第一交集、第二交易集合和第三交易集为示例),共识节点还可以如图7所示那样,在分批次对第N轮共识提议的多个交集完成共识操作、交易执行操作和交易执行确认操作的基础之上,设置更多的CPU线程实现:在对第一交易集执行交易执行操作时,如果第N轮共识提议中存在尚未完成共识的第二交易集,则并行对第二交易集执行共识操作。同理,在对第二交易集执行交易执行操作时,如果第N轮共识提议中存在尚未完成共识的第三交易集,则并行对第三交易集执行共识操作。可以看出,图7所示的交易处理方式相比于图6所示的交易处理方式,进一步利用CPU多核多线程的优势,以并行方式提高区块链交易的上链效率。这里,如果需要保证区块链交易执行的有序性,第二交易集的交易执行操作应在第一交易集的交易执行操作完成后执行,同理第三交易集的交易执行操作应在第二交易集的交易执行操作完成后执行。In addition, if the N-round consensus proposal includes multiple transaction sets including the first transaction set (still take the N-round consensus proposal including the first intersection, second transaction set, and third transaction set as an example), the consensus node can also As shown in Figure 7, on the basis of completing consensus operations, transaction execution operations, and transaction execution confirmation operations for multiple intersections of the N-th round of consensus proposals in batches, set more CPU threads to implement: When the transaction set executes the transaction execution operation, if there is a second transaction set that has not yet completed the consensus in the consensus proposal of the Nth round, then the consensus operation is performed on the second transaction set in parallel. Similarly, when performing transaction execution operations on the second transaction set, if there is a third transaction set that has not yet completed consensus in the consensus proposal of the Nth round, the consensus operation will be executed on the third transaction set in parallel. It can be seen that compared with the transaction processing method shown in Figure 6, the transaction processing method shown in Figure 7 further utilizes the advantages of CPU multi-core and multi-threading to improve the efficiency of blockchain transactions in a parallel manner. Here, if it is necessary to ensure the orderly execution of blockchain transactions, the transaction execution operations of the second transaction set should be executed after the transaction execution operations of the first transaction set are completed. Similarly, the transaction execution operations of the third transaction set should be executed after Execute after the transaction execution operation of the second transaction set is completed.
综上所述,本应用场景的方法在对第N轮共识提议的第一交易集执行共识操作时,还并行对第一交易集执行交易执行操作,从而提高第一交易集的交易执行确认效率,进而使客户端用户能够尽早得知交易执行结果,可在一定程度上改善用户体验。另一方面,共识操作和交易执行操作并行也缩短了区块链交易的上链耗时,这意味着区块链的业务吞吐量也随着得到了提升。To sum up, when the method in this application scenario executes the consensus operation on the first transaction set proposed by the N-th round of consensus, it also executes the transaction execution operation on the first transaction set in parallel, thereby improving the transaction execution confirmation efficiency of the first transaction set , so that client users can know the transaction execution results as soon as possible, which can improve user experience to a certain extent. On the other hand, the parallel operation of consensus operation and transaction execution operation also shortens the time-consuming on-chain of blockchain transactions, which means that the business throughput of blockchain has also been improved.
此外,即便是共识提议超时触发区块链的视图切换(更换共识主节点),共识节点执行交易执行操作也不会带来时间上的浪费。这是因为现有的区块链设置的共识提议超时时间一般为数秒至数十秒,共 识节点在超时计时的期间,有充分时间来完成交易执行操作。In addition, even if the consensus proposal times out and triggers the view switch of the blockchain (replacing the consensus master node), the execution of the transaction by the consensus node will not waste time. This is because the consensus proposal timeout period set by the existing blockchain is generally several seconds to tens of seconds, and the consensus node has sufficient time to complete the transaction execution operation during the timeout period.
当然,如果共识提议超时结束,共识节点还可以将生成的临时区块进行缓存,以在后续轮次的共识提议中使用。这里,以第N轮共识提议超时为例,共识节点在生成第N轮共识提议的临时区块后,如果第N轮共识提议超时结束,则可以对第一交易集的临时区块先进行缓存,并在对第N+1轮共识提议的交易集执行共识操作时,若第N+1轮共识提议与第N轮共识提议的交易集一致(即,第N+1轮共识提议的共识节点发起了相同交易集的共识提议),则跳过对第二交易集执行交易执行操作,并将缓存的第一交易集的临时区块沿用为第二交易集的临时区块。也就是说,如果第N+1轮共识提议达成共识,则将之前缓存第一交易集的临时区块写入区块链中。当然,如果第N+1轮共识提议与第N轮共识提议的交易集不一致,则共识节点可以选择删除掉缓存的第一交易集的临时区块,以清理缓存空间。上述过程适用于共识主节点在共识阶段发生宕机后恢复并重新发起共识提议的场景,或者,共识提议超时触发区块链的视图切换,由新的共识主节点对原先共识提议的交易集重新发起共识提议的场景。Of course, if the consensus proposal ends after the timeout, the consensus node can also cache the generated temporary block for use in subsequent rounds of consensus proposals. Here, taking the timeout of the Nth round of consensus proposal as an example, after the consensus node generates the temporary block of the Nth round of consensus proposal, if the timeout of the Nth round of consensus proposal ends, the temporary block of the first transaction set can be cached first , and when performing the consensus operation on the transaction set proposed by the N+1 round consensus, if the consensus proposal of the N+1 round is consistent with the transaction set proposed by the N round consensus (that is, the consensus node of the N+1 round consensus proposal Initiate a consensus proposal of the same transaction set), skip the transaction execution operation on the second transaction set, and use the cached temporary block of the first transaction set as the temporary block of the second transaction set. That is to say, if the N+1 consensus proposal reaches a consensus, the temporary block that previously cached the first transaction set will be written into the blockchain. Of course, if the consensus proposal in round N+1 is inconsistent with the transaction set proposed in round N, the consensus node can choose to delete the cached temporary block of the first transaction set to clear the cache space. The above process is applicable to the scenario where the consensus master node recovers and re-initiates the consensus proposal after a downtime in the consensus stage, or the consensus proposal timeout triggers the view switch of the blockchain, and the new consensus master node restarts the transaction set proposed by the original consensus Scenarios for initiating consensus proposals.
对应于图1所示的交易处理方法,本发明实施例还提供一种区块链节点。图8是本发明实施例区块链节点800的结构示意图,包括:Corresponding to the transaction processing method shown in FIG. 1 , an embodiment of the present invention also provides a blockchain node. Fig. 8 is a schematic structural diagram of a block chain node 800 according to an embodiment of the present invention, including:
交易共识模块810,执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;The transaction consensus module 810 executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
交易执行模块820,执行所述第一交易集的交易执行操作;The transaction execution module 820, executes the transaction execution operation of the first transaction set;
交易执行确认模块830,在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;The transaction execution confirmation module 830, after the execution of the transaction execution operation, initiates the transaction execution confirmation operation of the first transaction set;
写块模块840,在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。The block writing module 840 executes a block writing operation on all transaction sets proposed by the N-th round of consensus after reaching a consensus on all transaction sets proposed by the N-th round of consensus and completing transaction confirmation operations.
基于本说明书实施例的装置,区块链的共识节点在完成交易的共识操作前,即可提前对交易执行交易执行操作,并在交易执行操作完成后发起交易执行确定操作,从而提高交易最终化的确认效率,进而使客户端用户能够尽早得知交易执行结果,在一定程度上改善了用户体验。此外,交易执行确认的提前也会更早的执行写块操作,使得区块链的交易上链效率也得了提升,进而提高了区块链的业务吞吐量,符合未来区块链业务高并发的发展趋势。Based on the device in the embodiment of this specification, the consensus node of the blockchain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving transaction finalization. The confirmation efficiency is high, so that the client user can know the transaction execution result as soon as possible, which improves the user experience to a certain extent. In addition, the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
可选地,交易执行确认模块830具体用于:向区块链的其它共识节点发送所述第一交易集的交易执行确认消息,所述交易执行确认消息携带有所述第一交易集的哈希信息;以及,接收其它共识节点发送的携带有第一交易集的哈希信息的交易执行确认消息,并在接收到2f个其它共识节点发送的携带有相同所述第一交易集的哈希信息的交易执行确认消息后,确认所述第一交易集的交易执行,f为所述区块链设置的拜占庭容错数量。Optionally, the transaction execution confirmation module 830 is specifically configured to: send the transaction execution confirmation message of the first transaction set to other consensus nodes of the blockchain, the transaction execution confirmation message carrying the hash of the first transaction set and receiving the transaction execution confirmation message carrying the hash information of the first transaction set sent by other consensus nodes, and receiving the hash information of the same first transaction set sent by 2f other consensus nodes After the transaction execution confirmation message of the information, the transaction execution of the first transaction set is confirmed, and f is the number of Byzantine fault tolerance set by the blockchain.
可选地,写块模块840具体用于:在对所述第N轮共识提议的所有交易集都完成交易执行确认操作后,生成所述第N轮共识提议的临时区块;如果尚未对所述第N轮共识提议的所有交易集都达成共识,则所述共识节点进行等待;如果已经对所述第N轮共识提议的所有交易集都达成共识,则所述共识节点将所述第N轮共识提议的临时区块写入所述区块链中。Optionally, the block writing module 840 is specifically configured to: generate a temporary block proposed by the N-round consensus after completing the transaction confirmation operation for all transaction sets proposed by the N-round consensus; If all transaction sets proposed by the Nth round of consensus have reached a consensus, the consensus node will wait; if a consensus has been reached on all transaction sets proposed by the Nth round of consensus, then the consensus node will The temporary block proposed by the consensus round is written into the blockchain.
可选地,交易共识模块810在执行第N轮共识提议中第一交易集的共识操作的同事,交易执行模块820并行执行所述第一交易集的交易执行操作。Optionally, when the transaction consensus module 810 executes the consensus operation of the first transaction set in the N-th round of consensus proposals, the transaction execution module 820 executes the transaction execution operation of the first transaction set in parallel.
作为示例性介绍:As an example introduction:
所述共识节点基于实用拜占庭容错PBFT协议执行共识操作;若所述共识节点作为所述区块链的共识主节点,则交易执行模块820在交易共识模块810对所述第一交易集执行所述PBFT协议的预准备Pre-Prepare阶段的共识操作时,并行执行所述第一交易集的交易执行操作;若所述共识节点作为所述区块链的共识备份节点,则交易执行模块820在交易共识模块810对所述第一交易集执行所述PBFT协议的准备Prepare阶段的共识操作时,并行执行所述第一交易集的交易执行操作。The consensus node performs a consensus operation based on the practical Byzantine fault-tolerant PBFT protocol; if the consensus node is the consensus master node of the block chain, the transaction execution module 820 executes the first transaction set in the transaction consensus module 810. During the consensus operation of the Pre-Prepare stage of the PBFT protocol, the transaction execution operation of the first transaction set is executed in parallel; if the consensus node is used as the consensus backup node of the block chain, the transaction execution module 820 is When the consensus module 810 executes the consensus operation of the Prepare phase of the PBFT protocol on the first transaction set, it executes the transaction execution operation of the first transaction set in parallel.
可选地,交易执行模块820在交易共识模块810对所述第一交易集执行所述PBFT协议的保证Commit阶段的共识操作前,完成对第一交易集执行的交易执行操作;交易执行确认模块830交易执行 模块820在对所述第一交易集执行所述PBFT的Commit阶段的共识操作时,将Commit消息作为所述第一交易集的交易执行确认消息以发送至所述区块链的其它共识节点,其中,所述共识节点发送的Commit消息携带有所述共识节点生成的所述第一交易集的哈希信息。Optionally, the transaction execution module 820 completes the transaction execution operation performed on the first transaction set before the transaction consensus module 810 executes the consensus operation of the guaranteed Commit phase of the PBFT protocol on the first transaction set; the transaction execution confirmation module 830 When the transaction execution module 820 executes the consensus operation of the Commit stage of the PBFT on the first transaction set, it sends the Commit message as the transaction execution confirmation message of the first transaction set to other members of the block chain. A consensus node, wherein the Commit message sent by the consensus node carries hash information of the first transaction set generated by the consensus node.
可选地,如果所述第N轮共识提议只包括所述第一交易集,则所述共识节点在对所述第一交易集执行所述PBFT协议的Commit阶段的共识操作前,生成所述第N轮共识提议的临时区块,其中,所述共识节点发送的Commit消息携带有所述共识节点生成的所述第N轮共识提议的临时区块的哈希信息,所述第N轮共识提议的临时区块的哈希信息作为所述第一交易集的哈希信息。Optionally, if the consensus proposal of the Nth round only includes the first transaction set, the consensus node generates the The temporary block proposed by the N-round consensus, wherein the Commit message sent by the consensus node carries the hash information of the temporary block proposed by the N-round consensus generated by the consensus node, and the N-round consensus The hash information of the proposed temporary block is used as the hash information of the first transaction set.
可选地,如果第N轮共识提议包括所述第一交易集在内的多个交易集,所述共识节点在对所述第一交易集执行交易执行操作时,如果存在第二交易集,则并行对所述第二交易集执行共识操作,其中,所述第二交易集是所述第N轮共识提议中尚未完成共识的交易集。Optionally, if the N-th round of consensus proposes multiple transaction sets including the first transaction set, when the consensus node executes the transaction execution operation on the first transaction set, if there is a second transaction set, Then, a consensus operation is performed on the second transaction set in parallel, where the second transaction set is a transaction set that has not yet completed consensus in the N round of consensus proposals.
此外,本发明实施例的区块链节点还包括:In addition, the block chain node of the embodiment of the present invention also includes:
缓存模块,在交易执行模块820生成所述第N轮共识提议的临时区块后,若所述第N轮共识提议超时结束,则对所述第N轮共识提议的临时区块进行缓存;对应地,交易执行模块820在对第N+1轮共识提议的共识操作时,若所述第N+1轮共识提议与所述第N轮共识提议的交易集一致,则跳过对所述第N+1轮共识提议的交易集执行交易执行操作的流程,并将所述第N轮共识提议的临时区块沿用为所述第N+1轮共识提议的临时区块。当然,若所述第N+1轮共识提议与所述第N轮共识提议的交易集不一致,则缓存模块删可以除掉缓存的第N轮共识提议的临时区块的临时区块。The caching module, after the transaction execution module 820 generates the temporary block proposed by the N round consensus, if the N round consensus proposal ends overtime, then cache the temporary block proposed by the N round consensus; Specifically, when the transaction execution module 820 performs the consensus operation on the consensus proposal of the N+1 round, if the consensus proposal of the N+1 round is consistent with the transaction set proposed by the consensus proposal of the Nth round, skip the operation of the consensus proposal of the N+1 round. The transaction set proposed by the N+1 round of consensus executes the transaction execution process, and the temporary block proposed by the Nth round of consensus is used as the temporary block proposed by the N+1 round of consensus. Certainly, if the consensus proposal of the N+1 round is inconsistent with the transaction set of the consensus proposal of the N round, the cache module deletes the temporary block that can delete the cached temporary block of the consensus proposal of the N round.
显然,本说明书实施例的区块链节点可以作为上述图1所示的交易处理方法的执行主体,因此能够实现交易处理方法在图1所实现的功能。由于原理相同,本文不再赘述。Apparently, the blockchain node in the embodiment of this specification can be used as the execution body of the transaction processing method shown in FIG. 1 above, so it can realize the functions realized by the transaction processing method in FIG. 1 . Since the principle is the same, this article will not repeat them.
图9是本说明书的一个实施例电子设备的结构示意图。请参考图9,在硬件层面,该电子设备包括处理器,可选地还包括内部总线、网络接口、存储器。其中,存储器可能包含内存,例如高速随机存取存储器(Random-Access Memory,RAM),也可能还包括非易失性存储器(non-volatile memory),例如至少1个磁盘存储器等。当然,该电子设备还可能包括其他业务所需要的硬件。FIG. 9 is a schematic structural diagram of an electronic device according to an embodiment of the present specification. Please refer to FIG. 9 , at the hardware level, the electronic device includes a processor, and optionally also includes an internal bus, a network interface, and a memory. Wherein, the memory may include a memory, such as a high-speed random-access memory (Random-Access Memory, RAM), and may also include a non-volatile memory (non-volatile memory), such as at least one disk memory. Of course, the electronic device may also include hardware required by other services.
处理器、网络接口和存储器可以通过内部总线相互连接,该内部总线可以是ISA(Industry Standard Architecture,工业标准体系结构)总线、PCI(Peripheral Component Interconnect,外设部件互连标准)总线或EISA(Extended Industry Standard Architecture,扩展工业标准结构)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图9中仅用一个双向箭头表示,但并不表示仅有一根总线或一种类型的总线。The processor, the network interface and the memory can be connected to each other through an internal bus, which can be an ISA (Industry Standard Architecture, industry standard architecture) bus, a PCI (Peripheral Component Interconnect, peripheral component interconnection standard) bus or an EISA (Extended Industry Standard Architecture, extended industry standard architecture) bus, etc. The bus can be divided into address bus, data bus, control bus and so on. For ease of representation, only one double-headed arrow is used in FIG. 9 , but it does not mean that there is only one bus or one type of bus.
存储器,用于存放程序。具体地,程序可以包括程序代码,所述程序代码包括计算机操作指令。存储器可以包括内存和非易失性存储器,并向处理器提供指令和数据。Memory for storing programs. Specifically, the program may include program code, and the program code includes computer operation instructions. Storage, which can include internal memory and nonvolatile storage, provides instructions and data to the processor.
处理器从非易失性存储器中读取对应的计算机程序到内存中然后运行,在逻辑层面上形成区块链的交易处理装置,该交易处理装置可以是指区块链节点,也可以是指区块链节点中的部件。处理器,执行存储器所存放的程序,并具体用于执行以下操作:The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it, forming a blockchain transaction processing device on a logical level. The transaction processing device can refer to a blockchain node or a A component in a blockchain node. The processor executes the program stored in the memory, and is specifically used to perform the following operations:
执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数。Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer.
执行所述第一交易集的交易执行操作。Executing transaction execution operations of the first transaction set.
在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作。After the execution of the transaction execution operation is completed, an operation of determining the execution of the transactions in the first transaction set is initiated.
在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation, perform a block write operation on all the transaction sets proposed by the N-th round of consensus.
基于本说明书实施例的电子设备,区块链的共识节点在完成交易的共识操作前,即可提前对交易执行交易执行操作,并在交易执行操作完成后发起交易执行确定操作,从而提高交易最终化的确认效率,进而使客户端用户能够尽早得知交易执行结果,在一定程度上改善了用户体验。此外,交易执行确认的提前也会更早的执行写块操作,使得区块链的交易上链效率也得了提升,进而提高了区块链的业务吞吐量,符合未来区块链业务高并发的发展趋势。Based on the electronic device in the embodiment of this specification, the consensus node of the block chain can execute the transaction execution operation on the transaction in advance before completing the consensus operation of the transaction, and initiate the transaction execution confirmation operation after the transaction execution operation is completed, thereby improving the transaction finality. Optimized confirmation efficiency, so that client users can know the transaction execution results as soon as possible, which improves the user experience to a certain extent. In addition, the advance confirmation of transaction execution will also execute the block writing operation earlier, which improves the transaction efficiency of the blockchain, thereby improving the business throughput of the blockchain, which is in line with the high concurrency of blockchain business in the future. development trend.
上述如本说明书图1所示实施例揭示的交易处理方法可以应用于处理器中,或者由处理器实现。处理器可能是一种集成电路芯片,具有信号的处理能力。在实现过程中,上述方法的各步骤可以通过处理器中的硬件的集成逻辑电路或者软件形式的指令完成。上述的处理器可以是通用处理器,包括中央处理器(Central Processing Unit,CPU)、网络处理器(Network Processor,NP)等;还可以是数字信号处理器(Digital Signal Processor,DSP)、专用集成电路(Application Specific Integrated Circuit,ASIC)、现场可编程门阵列(Field-Programmable Gate Array,FPGA)或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件。可以实现或者执行本说明书实施例中的公开的各方法、步骤及逻辑框图。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。结合本说明书实施例所公开的方法的步骤可以直接体现为硬件译码处理器执行完成,或者用译码处理器中的硬件及软件模块组合执行完成。软件模块可以位于随机存储器,闪存、只读存储器,可编程只读存储器或者电可擦写可编程存储器、寄存器等本领域成熟的存储介质中。该存储介质位于存储器,处理器读取存储器中的信息,结合其硬件完成上述方法的步骤。The above-mentioned transaction processing method disclosed in the embodiment shown in FIG. 1 of this specification can 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 method can be completed by an integrated logic circuit of hardware in a processor or an instruction in the form of software. The above-mentioned processor can be a general-purpose processor, including a central processing unit (Central Processing Unit, CPU), a network processor (Network Processor, NP), etc.; it can also be a digital signal processor (Digital Signal Processor, DSP), a dedicated integrated Circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of this specification can be realized or executed. A general-purpose processor may be a microprocessor, or the processor may be any conventional processor, or the like. The steps of the methods disclosed in the embodiments of this specification can be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in the decoding processor. The software module may be located in a mature storage medium in the field such as random access memory, flash memory, read-only memory, programmable read-only memory or electrically erasable programmable memory, register. The storage medium is located in the memory, and the processor reads the information in the memory, and completes the steps of the above method in combination with its hardware.
应理解,本说明书实施例的电子设备可以实现上述共识方法在图1所示的实施例的功能。由于原理相同,本文不再赘述。It should be understood that the electronic device in the embodiment of this specification can implement the functions of the above-mentioned consensus method shown in the embodiment shown in FIG. 1 . Since the principle is the same, this article will not repeat them.
当然,除了软件实现方式之外,本说明书的电子设备并不排除其他实现方式,比如逻辑器件抑或软硬件结合的方式等等,也就是说以下处理流程的执行主体并不限定于各个逻辑单元,也可以是硬件或逻辑器件。Of course, in addition to the software implementation, the electronic equipment in this specification does not exclude other implementations, such as logic devices or the combination of software and hardware, etc., that is to say, the execution subject of the following processing flow is not limited to each logic unit, It can also be a hardware or logic device.
此外,本说明书实施例还提出了一种计算机可读存储介质,该计算机可读存储介质存储一个或多个程序,该一个或多个程序包括指令,该指令当被包括多个应用程序的便携式电子设备执行时,能够使该便携式电子设备执行图1所示实施例的方法,并具体用于执行以下步骤:In addition, the embodiment of this specification also proposes a computer-readable storage medium, where the computer-readable storage medium stores one or more programs, and the one or more programs include instructions. When the electronic device executes, the portable electronic device can be made to execute the method of the embodiment shown in Figure 1, and is specifically used to perform the following steps:
执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数。Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer.
执行所述第一交易集的交易执行操作。Executing transaction execution operations of the first transaction set.
在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作。After the execution of the transaction execution operation is completed, an operation of determining the execution of the transactions in the first transaction set is initiated.
在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation, perform a block write operation on all the transaction sets proposed by the N-th round of consensus.
本领域技术人员应明白,本说明书的实施例可提供为方法、系统或计算机程序产品。因此,本说明书可采用完全硬件实施例、完全软件实施例或结合软件和硬件方面的实施例的形式。而且,本说明书可采用在一个或多个其中包含有计算机可用程序代码的计算机可用存储介质(包括但不限于磁盘存储器、CD-ROM、光学存储器等)上实施的计算机程序产品的形式。Those skilled in the art should understand that the embodiments of this specification may be provided as methods, systems or computer program products. Accordingly, this description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present description may take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) having computer-usable program code embodied therein.
上述对本说明书特定实施例进行了描述。其它实施例在所附权利要求书的范围内。在一些情况下,在权利要求书中记载的动作或步骤可以按照不同于实施例中的顺序来执行并且仍然可以实现期望的结果。另外,在附图中描绘的过程不一定要求示出的特定顺序或者连续顺序才能实现期望的结果。在某些实施方式中,多任务处理和并行处理也是可以的或者可能是有利的。The foregoing describes specific embodiments of the present specification. Other implementations are within the scope of the following claims. In some cases, the actions or steps recited in the claims can be performed in an order different from that in the embodiments and still achieve desirable results. In addition, the processes depicted in the accompanying figures do not necessarily require the particular order shown, or sequential order, to achieve desirable results. Multitasking and parallel processing are also possible or may be advantageous in certain embodiments.
以上仅为本说明书的实施例而已,并不用于限制本说明书。对于本领域技术人员来说,本说明书可以有各种更改和变化。凡在本说明书的精神和原理之内所作的任何修改、等同替换、改进等,均应包含在本说明书的权利要求范围之内。此外,本领域普通技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都应当属于本文件的保护范围。The above are only examples of this specification, and are not intended to limit this specification. For those skilled in the art, various modifications and changes may occur in this description. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of this specification shall be included within the scope of the claims of this specification. In addition, all other embodiments obtained by persons of ordinary skill in the art without creative efforts shall fall within the scope of protection of this document.

Claims (14)

  1. 一种区块链的交易处理方法,包括:A blockchain transaction processing method, comprising:
    区块链的共识节点执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;The consensus node of the blockchain executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
    所述共识节点执行所述第一交易集的交易执行操作;The consensus node executes the transaction execution operation of the first transaction set;
    所述共识节点在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, the consensus node initiates a transaction execution confirmation operation for the first transaction set;
    所述共识节点在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After the consensus node has reached a consensus on all the transaction sets proposed by the N-round consensus and completed the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus.
  2. 如权利要求1所述的方法,The method of claim 1,
    所述共识节点发起对所述第一交易集的交易执行确定操作,包括:The consensus node initiates a determination operation on transactions in the first transaction set, including:
    所述共识节点向区块链的其它共识节点发送所述第一交易集的交易执行确认消息,所述交易执行确认消息携带有所述第一交易集的哈希信息;The consensus node sends a transaction execution confirmation message of the first transaction set to other consensus nodes of the block chain, and the transaction execution confirmation message carries hash information of the first transaction set;
    以及,所述共识节点当接收到2f个其它共识节点发送的携带有相同所述第一交易集的哈希信息的交易执行确认消息后,确认所述第一交易集的交易执行,f为所述区块链设置的拜占庭容错数量。And, the consensus node confirms the transaction execution of the first transaction set after receiving the transaction execution confirmation message carrying the same hash information of the first transaction set sent by 2f other consensus nodes, where f is the The amount of Byzantine fault tolerance set by the above blockchain.
  3. 如权利要求2所述的方法,The method of claim 2,
    所述共识节点在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作,包括:After the consensus node reaches a consensus on all the transaction sets proposed by the N-round consensus and completes the transaction execution confirmation operation, it performs a block writing operation on all the transaction sets proposed by the N-round consensus, including:
    所述共识节点在对所述第N轮共识提议的所有交易集都完成交易执行确认操作后,生成所述第N轮共识提议的临时区块;The consensus node generates a temporary block proposed by the N-round consensus after completing the transaction confirmation operation for all transaction sets proposed by the N-round consensus;
    如果尚未对所述第N轮共识提议的所有交易集都达成共识,则所述共识节点进行等待;If a consensus has not been reached on all transaction sets proposed by the N round of consensus, the consensus node waits;
    如果已经对所述第N轮共识提议的所有交易集都达成共识,则所述共识节点将所述第N轮共识提议的临时区块写入所述区块链中。If a consensus has been reached on all transaction sets proposed by the Nth round of consensus, the consensus node writes the temporary block proposed by the Nth round of consensus into the block chain.
  4. 如权利要求3所述的方法,The method of claim 3,
    在所述共识节点执行所述第一交易集的共识操作时,并行执行所述第一交易集的交易执行操作。When the consensus node executes the consensus operation of the first transaction set, the transaction execution operation of the first transaction set is executed in parallel.
  5. 如权利要求4所述的方法,The method of claim 4,
    所述共识节点基于实用拜占庭容错PBFT协议执行共识操作;The consensus nodes perform consensus operations based on the Practical Byzantine Fault Tolerant PBFT protocol;
    若所述共识节点作为所述区块链的共识主节点,则在对所述第一交易集执行所述PBFT协议的预准备Pre-Prepare阶段的共识操作时,并行执行所述第一交易集的交易执行操作;If the consensus node is used as the consensus master node of the block chain, when the consensus operation of the Pre-Prepare phase of the PBFT protocol is executed on the first transaction set, the first transaction set is executed in parallel transaction execution operations;
    若所述共识节点作为所述区块链的共识备份节点,则在对所述第一交易集执行所述PBFT协议的准备Prepare阶段的共识操作时,并行执行所述第一交易集的交易执行操作。If the consensus node is used as the consensus backup node of the block chain, when the consensus operation of the Prepare phase of the PBFT protocol is executed on the first transaction set, the transaction execution of the first transaction set is executed in parallel operate.
  6. 如权利要求5所述的方法,The method of claim 5,
    所述共识节点在对所述第一交易集执行所述PBFT协议的保证Commit阶段的共识操作前,完成对第一交易集执行的交易执行操作;The consensus node completes the transaction execution operation performed on the first transaction set before performing the consensus operation of the guaranteed Commit phase of the PBFT protocol on the first transaction set;
    所述共识节点在对所述第一交易集执行所述PBFT的Commit阶段的共识操作时,将Commit消息作为所述第一交易集的交易执行确认消息发送至所述区块链的其它共识节点,其中,所述共识节点发送 的Commit消息携带有所述共识节点生成的所述第一交易集的哈希信息。When the consensus node executes the consensus operation of the Commit phase of the PBFT on the first transaction set, the Commit message is sent to other consensus nodes of the block chain as a transaction execution confirmation message of the first transaction set , wherein the Commit message sent by the consensus node carries hash information of the first transaction set generated by the consensus node.
  7. 如权利要求6所述的方法,The method of claim 6,
    所述第N轮共识提议只包括所述第一交易集,所述共识节点在对所述第一交易集执行所述PBFT协议的Commit阶段的共识操作前,生成所述第N轮共识提议的临时区块,其中,所述共识节点发送的Commit消息携带有所述共识节点生成的所述第N轮共识提议的临时区块的哈希信息,所述第N轮共识提议的临时区块的哈希信息作为所述第一交易集的哈希信息。The consensus proposal of the Nth round only includes the first transaction set, and the consensus node generates the consensus proposal of the Nth round before performing the consensus operation of the Commit phase of the PBFT protocol on the first transaction set. Temporary block, wherein, the Commit message sent by the consensus node carries the hash information of the temporary block proposed by the consensus node in the Nth round, and the hash information of the temporary block proposed by the N round consensus The hash information is used as the hash information of the first transaction set.
  8. 如权利要求1所述的方法,The method of claim 1,
    所述第N轮共识提议包括所述第一交易集在内的多个交易集,所述共识节点在对所述第一交易集执行交易执行操作时,如果存在第二交易集,则并行对所述第二交易集执行共识操作,其中,所述第二交易集是所述第N轮共识提议中尚未完成共识的交易集。The N-th round of consensus proposes multiple transaction sets including the first transaction set, and when the consensus node executes a transaction execution operation on the first transaction set, if there is a second transaction set, it will parallelize A consensus operation is performed on the second transaction set, wherein the second transaction set is a transaction set that has not yet completed consensus in the N-th round of consensus proposals.
  9. 如权利要求3所述的方法,还包括:The method of claim 3, further comprising:
    所述共识节点在生成所述第N轮共识提议的临时区块后,若所述第N轮共识提议超时结束,则对所述第N轮共识提议的临时区块进行缓存;以及,After the consensus node generates the temporary block of the consensus proposal of the Nth round, if the consensus proposal of the Nth round ends overtime, the temporary block of the consensus proposal of the Nth round is cached; and,
    所述共识节点在对第N+1轮共识提议的共识操作时,若所述第N+1轮共识提议与所述第N轮共识提议的交易集一致,则跳过对所述第N+1轮共识提议的交易集执行交易执行操作的流程,并将所述第N轮共识提议的临时区块沿用为所述第N+1轮共识提议的临时区块,若所述第N+1轮共识提议与所述第N轮共识提议的交易集不一致,则删除掉缓存的所述第N轮共识提议的临时区块的临时区块。When the consensus node performs the consensus operation on the consensus proposal of the N+1 round, if the consensus proposal of the N+1 round is consistent with the transaction set of the consensus proposal of the N round, skip the transaction set of the N+th round consensus proposal. The transaction set of the 1st round of consensus proposal executes the transaction execution process, and the temporary block proposed by the Nth round of consensus is used as the temporary block of the N+1st round of consensus proposal, if the N+1th round If the round consensus proposal is inconsistent with the transaction set of the Nth round consensus proposal, the cached temporary block of the Nth round consensus proposal is deleted.
  10. 如权利要求1所述的方法,The method of claim 1,
    所述共识节点为所述区块链的共识主节点,在共识节点执行第N轮共识提议中第一交易集的交易执行操作之前,所述方法还包括:The consensus node is the consensus master node of the block chain, and before the consensus node executes the transaction execution operation of the first transaction set in the N round consensus proposal, the method further includes:
    共识节点创建所述第N轮共识提议并发送至所述区块链的共识备份节点。The consensus node creates the consensus proposal for the Nth round and sends it to the consensus backup node of the block chain.
  11. 如权利要求1所述的方法,The method of claim 1,
    所述共识节点为所述区块链的共识备份节点,在共识节点执行第N轮共识提议中第一交易集的交易执行操作之前,所述方法还包括:The consensus node is the consensus backup node of the block chain, and before the consensus node executes the transaction execution operation of the first transaction set in the N round consensus proposal, the method further includes:
    共识节点接收所述区块链的共识主节点发送的所述第N轮共识提议。The consensus node receives the consensus proposal of the Nth round sent by the consensus master node of the block chain.
  12. 一种区块链节点,包括:A blockchain node, comprising:
    交易共识模块,执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;The transaction consensus module executes the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
    交易执行模块,执行所述第一交易集的交易执行操作;The transaction execution module executes the transaction execution operation of the first transaction set;
    交易执行确认模块,在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;The transaction execution confirmation module, after the execution of the transaction execution operation is completed, initiates the transaction execution confirmation operation of the first transaction set;
    写块模块,在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。The block writing module executes a block writing operation on all transaction sets proposed by the N-th round of consensus after reaching a consensus on all transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation.
  13. 一种电子设备包括:存储器、处理器及存储在所述存储器上并可在所述处理器上运行的计算机程序,所述计算机程序被所述处理器执行:An electronic device includes: a memory, a processor, and a computer program stored on the memory and operable on the processor, the computer program being executed by the processor:
    执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
    执行所述第一交易集的交易执行操作;executing a transaction execution operation of the first transaction set;
    在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, initiate the transaction execution determination operation of the first transaction set;
    在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction execution confirmation operation, a block writing operation is performed on all the transaction sets proposed by the N-th round of consensus.
  14. 一种计算机可读存储介质,所述计算机可读存储介质存储一个或多个程序,所述一个或多个程序当被包括多个应用程序的电子设备执行时,使得所述电子设备执行以下操作:A computer-readable storage medium that stores one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform the following operations :
    执行第N轮共识提议中第一交易集的共识操作,其中,N为正整数;Execute the consensus operation of the first transaction set in the Nth round of consensus proposals, where N is a positive integer;
    执行所述第一交易集的交易执行操作;executing a transaction execution operation of the first transaction set;
    在所述交易执行操作执行完毕后,发起对所述第一交易集的交易执行确定操作;After the execution of the transaction execution operation is completed, initiate the transaction execution determination operation of the first transaction set;
    在对所述第N轮共识提议的所有交易集都达成共识且都完成交易执行确认操作后,对所述第N轮共识提议的所有交易集执行写块操作。After reaching a consensus on all the transaction sets proposed by the N-th round of consensus and completing the transaction confirmation operation, perform a block write operation on all the transaction sets proposed by the N-th round of consensus.
PCT/CN2022/135403 2022-02-24 2022-11-30 Transaction processing method of blockchain, blockchain node, and electronic device WO2023160086A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN202210178246.2 2022-02-24
CN202210178246.2A CN114529414A (en) 2022-02-24 2022-02-24 Transaction processing method of block chain, block chain node and electronic equipment

Publications (1)

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

Family

ID=81624487

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2022/135403 WO2023160086A1 (en) 2022-02-24 2022-11-30 Transaction processing method of blockchain, blockchain node, and electronic device

Country Status (2)

Country Link
CN (1) CN114529414A (en)
WO (1) WO2023160086A1 (en)

Families Citing this family (1)

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

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
CN110020859A (en) * 2019-03-28 2019-07-16 杭州秘猿科技有限公司 A kind of block chain common recognition method, apparatus and electronic equipment executed parallel
US20190354518A1 (en) * 2018-05-01 2019-11-21 Michael Zochowski Chain mesh network for decentralized transaction systems
CN112991066A (en) * 2021-04-27 2021-06-18 支付宝(杭州)信息技术有限公司 Consensus method and device in alliance chain and electronic equipment
CN113836232A (en) * 2021-09-24 2021-12-24 支付宝(杭州)信息技术有限公司 Consensus method and system in alliance chain
CN114529414A (en) * 2022-02-24 2022-05-24 蚂蚁区块链科技(上海)有限公司 Transaction processing method of block chain, block chain node and electronic equipment

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20190354518A1 (en) * 2018-05-01 2019-11-21 Michael Zochowski Chain mesh network for decentralized transaction systems
CN108648078A (en) * 2018-05-02 2018-10-12 杭州秘猿科技有限公司 A kind of transaction preprocess method, device and electronic equipment
CN110020859A (en) * 2019-03-28 2019-07-16 杭州秘猿科技有限公司 A kind of block chain common recognition method, apparatus and electronic equipment executed parallel
CN112991066A (en) * 2021-04-27 2021-06-18 支付宝(杭州)信息技术有限公司 Consensus method and device in alliance chain and electronic equipment
CN113836232A (en) * 2021-09-24 2021-12-24 支付宝(杭州)信息技术有限公司 Consensus method and system in alliance chain
CN114529414A (en) * 2022-02-24 2022-05-24 蚂蚁区块链科技(上海)有限公司 Transaction processing method of block chain, block chain node and electronic equipment

Also Published As

Publication number Publication date
CN114529414A (en) 2022-05-24

Similar Documents

Publication Publication Date Title
US11095750B2 (en) Method, apparatus, and electronic device for processing consensus requests in a blockchain consensus network
US11368317B2 (en) Consensus method of consortium blockchain, and consortium blockchain system
EP3934162B1 (en) Blockchain consensus method and device and electronic equipment
CN108648078B (en) Transaction preprocessing method and device and electronic equipment
CN108710638B (en) Distributed concurrency control method and system based on mixed RDMA operation
WO2021109471A1 (en) Method and device for dynamically adding consensus node in blockchain
US20210314179A1 (en) Methods and consensus nodes for block generation
CN105988862A (en) Distributed transaction processing method and device
WO2023160086A1 (en) Transaction processing method of blockchain, blockchain node, and electronic device
CN109002462B (en) Method and system for realizing distributed transaction
EP3557445A1 (en) Transaction processing method and apparatus
US20210165810A1 (en) Transaction processing method, apparatus, and device and computer storage medium
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
WO2022160901A1 (en) Blockchain consensus method, consensus node, and electronic device
US11803447B2 (en) Transaction processing method, apparatus, and electronic device for blockchain
CN115409507A (en) Block processing method, block processing device, computer equipment and storage medium
CN110865874B (en) Transaction commit method and device
CN109542631A (en) A kind of recurrence method, apparatus, server and the storage medium of standby host
CN112445761B (en) File checking method and device and storage medium
CN116860362B (en) Plug-in transaction management method and device applied to flow programming engine
CN113326268A (en) Data writing and reading method and device
CN114357079A (en) Data processing method, node equipment, system and platform based on block chain
CN112667148A (en) Method and system for cluster storage data online migration
CN117520449A (en) Data operation management method, device, equipment and storage medium

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

Country of ref document: EP

Kind code of ref document: A1