Disclosure of Invention
In order to overcome the above technical problems or at least partially solve the above technical problems, the following technical solutions are proposed:
in a first aspect, an embodiment of the present application provides a parallel blockchain consensus method, including the following steps:
when a round of consensus begins, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a verification request to a verification module while broadcasting the pre-voting result to other consensus nodes;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcast to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
and each consensus node obtains a consensus result of the consensus node according to the received pre-submission result.
Preferably, the pre-vote results include two types: empty block and legal;
when the consensus node does not receive the proposal or receives an illegal proposal within a preset time, the result of the pre-voting is an empty block; when the consensus node receives a legal offer within a preset time, the result of the pre-voting is legal;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result, and the method specifically comprises the following steps:
and counting the number of the received pre-voting results by each consensus node according to the type, wherein the type of which the number reaches the preset proportion of the total number of the consensus nodes is the pre-submission result of the consensus node.
Preferably, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result, and the method specifically includes:
each consensus node carries out quantity statistics on the types of the received pre-submission results, and when the quantity of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; and when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails.
Preferably, the preset proportion of the total number of the common nodes is two thirds.
Preferably, when the consensus result of the proposer in the consensus nodes is successful, the proposer sends the proposal block to an execution module to obtain an execution result; and entering the next round of consensus when the consensus result of the proposer in the consensus nodes is that the consensus fails.
Preferably, the execution result will follow a new round of proposal and consensus along with the proposed block at a fixed delay height.
In a second aspect, an embodiment of the present invention further provides a parallel blockchain consensus system, including a checking module and a consensus module including a plurality of consensus nodes,
when a round of consensus begins, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a verification request to a verification module while broadcasting the pre-voting result to other consensus nodes;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcast to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
and each consensus node obtains a consensus result of the consensus node according to the received pre-submission result.
Preferably, the pre-vote results include two types: empty block and legal;
when the consensus node does not receive the proposal or receives an illegal proposal within a preset time, the result of the pre-voting is an empty block; when the consensus node receives a legal offer within a preset time, the result of the pre-voting is legal;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result, and the method specifically comprises the following steps:
and counting the number of the received pre-voting results by each consensus node according to the type, wherein the type of which the number reaches the preset proportion of the total number of the consensus nodes is the pre-submission result of the consensus node.
Preferably, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result, and the method specifically includes:
each consensus node carries out quantity statistics on the types of the received pre-submission results, and when the quantity of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; and when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails.
Preferably, the preset proportion of the total number of the common nodes is two thirds.
Preferably, the method further comprises an execution module, when the consensus result of the proposer in the consensus node is successful, the proposer sends the proposal block to the execution module to obtain an execution result; and entering the next round of consensus when the consensus result of the proposer in the consensus nodes is that the consensus fails.
Preferably, the system further comprises a packaging transaction module, and the packaging transaction module packages the execution result along with the proposal block on the fixed delay height to carry out a new round of proposal and consensus.
In a third aspect, an electronic device is further provided, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, where the computer program is executed by the processor to perform the parallel block chain consensus method described above.
In a fourth aspect, a computer-readable storage medium is further provided, in which a computer program is stored, and when the computer program is executed by a processor, the parallel blockchain consensus method is implemented.
The invention has the following beneficial effects:
1. the verification process of the verification module is executed in parallel with the process of sending and receiving the pre-votes by the consensus node, so that the transaction processing capacity is improved;
2. and sending the block to an execution module for execution in a consensus submission stage, and carrying out a new round of proposal and consensus on the consensus of the execution result along with the recommendation block at the fixed delay height, so that the execution efficiency of the system is improved.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are some, not all, embodiments of the present invention. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1, a first embodiment of the present invention discloses a parallel blockchain consensus method, including the following steps:
s101, when a round of consensus starts, the proposer in the consensus nodes is determined, and the proposer broadcasts the proposal block to other consensus nodes.
Specifically, each consensus node determines whether the consensus node is a proposer or not through a deterministic algorithm. With this arrangement, the consensus node can uniquely identify a proposer. In one embodiment, the proposed block may comprise a plurality of proposed blocks for a transaction.
S102, after each consensus node conducts pre-voting on the received proposed block, each consensus node sends a check request to the check module while broadcasting the pre-voting result to other consensus nodes.
In a specific application example, the pre-voting has three cases: the proposed consensus node is not received within a certain time, and the result of pre-voting is as follows: empty blocks; the pre-vote result of the consensus node receiving the illegal proposal is as follows: empty blocks; the pre-vote result of the consensus node receiving the legal proposal is as follows: and (4) legality. When the consensus node does not receive the proposal within the preset time or the proposal is illegal, the result of pre-voting is an empty block; and when the consensus node receives a legal offer within the preset time, the result of the pre-voting is legal.
And S103, each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result.
Specific application examples include: and counting the number of the received pre-voting results by each consensus node according to the type, wherein the type of which the number reaches the preset proportion of the total number of the consensus nodes is the pre-submission result of the consensus node.
S104, each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcasted to other consensus nodes; and if the check fails, sending the pre-submission result of the empty block to other common identification nodes.
According to the foregoing technical solution, the empty block pre-commit result has two sources: firstly, the consensus node obtains a pre-submission result of the empty block, and the verification is successful; and the common node obtains a legal pre-submission result but fails to check.
And S105, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result.
In a specific application example, each consensus node performs quantity statistics on the types of the received pre-submission results, and if the quantity of the pre-submission results of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; and when the number of the empty block type pre-submission results reaches the preset proportion of the total number of the consensus nodes, the consensus fails. Typically, the predetermined ratio of the total number of the common nodes is two thirds. Namely, if more than two thirds of the consensus nodes submit legal pre-submission, the consensus is successful; and if more than two thirds of the consensus nodes submit empty blocks, the consensus fails. Those skilled in the art can understand that the preset proportion of the total number of the consensus nodes can be set according to actual requirements.
The parallel block chain consensus method implemented above is one of Byzantine fault-tolerant algorithms, a plurality of nodes participate in consensus of the current height at each height, and the consensus nodes achieve final consensus through at least one round of consensus under the condition that the total number of the consensus nodes is up to the honesty of the nodes in the preset proportion. According to the parallel block chain consensus method implemented in the steps, the node sends the check request to the check module while casting the legal pre-vote, so that the transaction processing capacity is improved.
Referring to fig. 2, a parallel blockchain consensus method according to a second embodiment of the present invention is shown, including the following steps:
s101, when a round of consensus starts, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
s102, after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a check request to a check module while broadcasting the pre-voting result to other consensus nodes;
s103, each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
s104, each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcasted to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
s105, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result;
s106, each consensus node counts the number of the types of the received pre-submission results, and if the number of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; and when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails.
Typically, the predetermined ratio of the total number of the common nodes is two thirds. Namely, if more than two thirds of the consensus nodes submit legal pre-submission, the consensus is successful; and if more than two thirds of the consensus nodes submit empty blocks, the consensus fails.
Referring to fig. 3, a parallel blockchain consensus method according to a third embodiment of the present invention is shown, including the following steps:
s101, when a round of consensus starts, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
s102, after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a check request to a check module while broadcasting the pre-voting result to other consensus nodes;
and S103, each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result.
S104, each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcasted to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
s105, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result;
s106, each consensus node counts the number of the types of the received pre-submission results, and if the number of the legal types reaches a preset proportion of the total number of the consensus nodes, the consensus is successful; when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails;
s107, when the consensus result of the proposer in the consensus nodes is successful, the proposer sends the proposal block to an execution module to obtain an execution result; when the consensus result of the proposer in the consensus nodes is that the consensus fails, the next round of consensus is entered.
Referring to fig. 4, a parallel blockchain consensus method according to a fourth embodiment of the present invention is shown, including the following steps:
s101, when a round of consensus starts, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
s102, after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a check request to a check module while broadcasting the pre-voting result to other consensus nodes;
s103, each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
s104, each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcasted to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
s105, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result;
s106, each consensus node counts the number of the types of the received pre-submission results, and if the number of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails;
s107, when the consensus result of the proposer in the consensus nodes is successful, the proposer sends the proposal block to an execution module to obtain an execution result; when the consensus result of the proposer in the consensus nodes is that the consensus fails, the next round of consensus is entered.
The execution result will be a new round of proposition and consensus along with the proposed block at the fixed delay height S108.
In the specific application example, the fixed delay height is the next or two next trades.
According to the parallel block chain consensus method provided by the embodiment of the invention, on the basis that the check request is sent to the check module while the node throws out the pre-vote, the block is sent to the execution module for execution in the consensus submitting stage, and the consensus of the execution result is carried out along with the proposal of the next block, so that the transaction processing capacity is improved, and the execution efficiency of the system is also improved.
The electronic device of the embodiment of the present invention is described in detail below with reference to fig. 5. On a hardware level, the electronic device includes a processor, and optionally an internal bus, a network interface, and a memory. The Memory may include a Memory, such as a Random-Access Memory (RAM), and may further include a Non-Volatile Memory (NVM), such as at least one disk Memory. Of course, the electronic device may also include hardware required for other services.
The processor, the network interface, and the memory may be interconnected by an internal bus, which may be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, an Extended ISA (EISA) bus, or the like. Wherein the bus can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one double-headed arrow is shown in FIG. 5, but this does not represent only one bus or one type of bus.
The memory for storing the program, in particular, the program may include program code including computer operating instructions, the memory may include memory and non-volatile storage, and provide instructions and data to the processor.
The processor reads the corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form the content recommendation device on a logic level. And the processor is used for executing the program stored in the memory and is specifically used for executing the method operation executed when the server is taken as an execution main body.
The parallel blockchain consensus method according to the embodiments of the present invention shown in fig. 1 to fig. 4 can be applied to or implemented by a processor. The processor may be an integrated circuit chip having signal processing capabilities. In implementation, the steps of the above method may be performed by integrated logic circuits of hardware in a processor or instructions in the form of software. The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc., and may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other Programmable logic device, a discrete Gate or transistor logic device, or a discrete hardware component. The various methods, steps and logic blocks disclosed in embodiments of the present invention may be implemented or performed. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like. The steps of the method disclosed in connection with the embodiments of the present invention may be directly implemented by a hardware decoding processor, or implemented by a combination of hardware and software modules in a decoder. The software module may be located in ram, flash memory, rom, prom, or eprom, registers, etc. storage media as is well known in the art. The storage medium is located in a memory, and a processor reads information in the memory and completes the steps of the method in combination with hardware of the processor.
Of course, the electronic device in the embodiment of the present specification does not exclude other implementations, such as a logic device or a combination of software and hardware, besides a software implementation, that is, the execution subject of the following processing flow is not limited to each logic unit, and may be hardware or a logic device.
Embodiments of the present invention also provide a computer-readable storage medium storing one or more programs that, when executed by an electronic device including a plurality of application programs, cause the electronic device to perform operations comprising:
when a round of consensus begins, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
after each consensus node carries out pre-voting on the received proposed block, each consensus node sends a verification request to a verification module while broadcasting the pre-voting result to other consensus nodes;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcast to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
and each consensus node obtains a consensus result of the consensus node according to the received pre-submission result.
The computer-readable storage medium may be a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk.
Referring to fig. 6, a schematic structural diagram of a parallel blockchain consensus device 10 according to an embodiment of the present invention is shown, the device mainly includes a check module 101 and a consensus module 102 including a plurality of consensus nodes,
when a round of consensus begins, determining a proposer in the consensus nodes, and broadcasting the proposal block to other consensus nodes by the proposer;
after each consensus node (shown as consensus node 1, consensus node 2 to consensus node N) pre-votes for the received proposed block, each consensus node sends a check request to the check module while broadcasting the pre-voted result to other consensus nodes;
each consensus node obtains a pre-submission result of the consensus node according to the received pre-vote result;
each consensus node receives the verification result sent by the verification module, and if the verification is successful, the pre-submission result is broadcast to other consensus nodes; if the check fails, sending a pre-submission result of the empty block to other common identification nodes;
and each consensus node obtains a consensus result of the consensus node according to the received pre-submission result.
Through the parallel block chain consensus device implemented above, by using one of the Byzantine fault-tolerant algorithms, at each height, a plurality of nodes participate in consensus at the current height, and under the condition that the total number of the consensus nodes reaches the honesty of the nodes in a preset proportion, the consensus nodes reach final consensus through at least one round of consensus. The parallel block chain consensus device implemented in the steps sends the check request to the check module while the node throws out the legal pre-vote, so that the transaction processing capacity is improved.
Further, each consensus node obtains a consensus result of the consensus node according to the received pre-submission result, and the method specifically includes: each consensus node carries out quantity statistics on the types of the received pre-submission results, and when the quantity of the legal types reaches the preset proportion of the total number of the consensus nodes, the consensus is successful; and when the number of the null block types reaches the preset proportion of the total number of the consensus nodes, the consensus fails.
In a specific application example, the preset proportion of the total number of the consensus nodes can be set to be two thirds. Of course, in other application examples, the required preset proportion of the total number of the consensus nodes can be set
Further, the parallel blockchain consensus device of the embodiment of the present invention further includes an execution module, where when the consensus result of the proposer in the consensus node is successful, the proposer sends the proposed block to the execution module to obtain an execution result; and entering the next round of consensus when the consensus result of the proposer in the consensus nodes is that the consensus fails.
Further, the parallel blockchain consensus device of the embodiment of the present invention further includes a packaging transaction module, where the packaging transaction module packages the execution result with the proposed blockchain at the fixed delay height, and performs a new round of proposal and consensus.
The parallel block chain consensus device provided by the embodiment of the invention sends the blocks to the execution module for execution in the consensus submitting stage on the basis of sending the check request to the check module while the node throws the pre-vote, and performs consensus on the execution result along with the proposal of the next block, thereby improving the transaction processing capacity and the system execution efficiency.
The systems, devices, modules or units illustrated in the above embodiments may be implemented by a computer chip or an entity, or by a product with certain functions. One typical implementation device is a computer. In particular, the computer may be, for example, a personal computer, a laptop computer, a cellular telephone, a camera phone, a smartphone, a personal digital assistant, a media player, a navigation device, an email device, a game console, a tablet computer, a wearable device, or a combination of any of these devices.
Computer-readable media, which include both non-transitory and non-transitory, removable and non-removable media, may implement the information storage by any method or technology. The information may be computer readable instructions, data structures, modules of a program, or other data. Computer storage media includes, but is not limited to, Phase Change Memory (PCM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash Memory or other Memory technology, compact disc read only Memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic cassettes, magnetic tape disk storage or other magnetic storage devices, or any other non-transmission medium which can be used to store information that can be accessed by a computer device. As defined in this specification, a computer readable medium does not include a transitory readable medium such as a modulated data signal and a carrier wave.
It should also be noted that the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, or apparatus. The use of the phrase "including a" does not exclude the presence of other, identical elements in the process, method, article, or apparatus that comprises the same element, whether or not the same element is present in all of the same element.
In short, the above description is only a preferred embodiment of the present disclosure, and is not intended to limit the scope of the embodiments of the present disclosure. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the embodiments of the present invention shall be included in the protection scope of the embodiments of the present specification.
It is to be understood that the exemplary embodiments described herein are illustrative and not restrictive. Although one or more embodiments of the present invention have been described with reference to the accompanying drawings, it will be understood by those of ordinary skill in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present invention as defined by the following claims.