Disclosure of Invention
Embodiments of the present disclosure provide a block chain consensus method, system, node, and electronic device, which can reduce overhead of network bandwidth and storage space in a endrmintbft protocol consensus process.
In order to achieve the above object, the embodiments of the present specification are implemented as follows:
in a first aspect, a method for identifying a blockchain is provided, including:
when the consensus main node of the block chain initiates the consensus, splitting the proposed data of the consensus into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
the consensus master node sends the data blocks obtained by splitting the proposed data to the corresponding consensus backup nodes in the block chain through a prompt message at the prompt stage of the TerdermintBFT protocol;
the consensus backup node which receives the data blocks carries out erasure code verification on the data blocks provided by the consensus master node, so that the data blocks which are successfully subjected to erasure code verification are broadcast to other consensus backup nodes through Pre-byte information at the Pre-byte stage of the TerdermintBFT protocol;
and the consensus backup node restores the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, so as to execute consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol and complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
In a second aspect, there is provided a blockchain system, comprising: the consensus main node and the consensus backup node; wherein:
when the consensus main node initiates the consensus of the current round, the proposed data of the consensus of the current round is split into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
the consensus master node sends the data blocks obtained by splitting the proposed data to the corresponding consensus backup nodes in the block chain through a prompt message at the prompt stage of the TerdermintBFT protocol;
the consensus backup node which receives the data blocks carries out erasure code verification on the data blocks provided by the consensus master node, so that the data blocks which are successfully subjected to erasure code verification are broadcast to other consensus backup nodes through Pre-byte information at the Pre-byte stage of the TerdermintBFT protocol;
and the consensus backup node restores the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, so as to execute consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol and complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
In a third aspect, there is provided a block link point comprising:
the erasure code module splits proposed data of the consensus of the current round into data blocks corresponding to consensus backup nodes of the block chains based on an erasure code algorithm when the consensus of the current round is initiated and if the corresponding block chain node is a consensus main node, wherein the block chains adopt a TerdermintBFT (bidirectional Forwarding transfer) protocol for consensus;
a sending module, configured to send, at a prompt stage of the endrmintbft protocol, a data block into which the proposed data is split to a corresponding consensus backup node in the block chain through a prompt message if the block chain node to which the proposed data belongs is the consensus master node;
the checking module is used for checking erasure codes of the data blocks provided by the consensus master node if the block chain node is a consensus backup node, so that the data blocks successfully checked by the erasure codes are broadcast to other consensus backup nodes through a Pre-vote message at the Pre-vote stage of the TerdermintBFT protocol;
and the restoring module restores the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm if the block chain node to which the block chain belongs is a consensus backup node, so that the consensus logic of the TerdermintBFT protocol is executed on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of the consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
In a fourth aspect, an electronic device is provided comprising: a memory, a processor, and a computer program stored on the memory and executable on the processor, the computer program being executed by the processor to:
when the consensus of the current round is initiated, if the consensus is taken as a main consensus node, splitting the proposed data of the consensus of the current round into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
if the node is used as a consensus backup node, in a prompt stage of the TerdermintBFT protocol, sending the data blocks obtained by splitting the proposed data to the corresponding consensus backup node in the block chain through a prompt message;
if the node is used as a consensus backup node, performing erasure code check on the data blocks provided by the consensus master node, so that the data blocks successfully subjected to erasure code check are broadcast to other consensus backup nodes through a Pre-byte message in a Pre-byte stage of the TerdermintBFT protocol;
if the candidate block is used as a consensus backup node, restoring the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, and executing consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
In a fifth aspect, a computer-readable storage medium is provided, having stored thereon a computer program which, when executed by a processor, performs the steps of:
when the consensus of the current round is initiated, if the consensus is taken as a main consensus node, splitting the proposed data of the consensus of the current round into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
if the node is used as a consensus backup node, in a prompt stage of the TerdermintBFT protocol, sending the data blocks obtained by splitting the proposed data to the corresponding consensus backup node in the block chain through a prompt message;
if the node is used as a consensus backup node, performing erasure code check on the data blocks provided by the consensus master node, so that the data blocks successfully subjected to erasure code check are broadcast to other consensus backup nodes through a Pre-byte message in a Pre-byte stage of the TerdermintBFT protocol;
if the candidate block is used as a consensus backup node, restoring the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, and executing consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
Based on the scheme of the embodiment of the description, when the consensus master node of the block chain executes the consensus of the TerdermintBFT, the erasure code algorithm is used for splitting the proposed data into data blocks corresponding to the consensus backup nodes, and the split data blocks are sent to the corresponding consensus backup nodes. And then, the consensus backup node performs erasure code verification on the data blocks provided by the consensus main node based on an erasure code technology, and forwards the data blocks to other consensus backup nodes after the verification is successful, so that after each consensus backup node of the block chain obtains a certain number of data blocks, the obtained data blocks can be restored back to the proposed data through an erasure code algorithm, and consensus logic is performed on the proposed data. In the whole scheme, the consensus master node only needs to send the corresponding data blocks to the consensus backup nodes, and the consensus backup nodes mutually forward the respective data blocks, so that the transmission of the proposed data is shared, and the fault tolerance of the transmission of the proposed data is realized with smaller network bandwidth and storage space overhead.
Detailed Description
In order to make those skilled in the art better understand the technical solutions in the present specification, the technical solutions in the embodiments of the present specification will be clearly and completely described below with reference to the drawings in the embodiments of the present specification, and it is obvious that the described embodiments are only a part of the embodiments of the present specification, and not all of the embodiments. All other embodiments obtained by a person skilled in the art based on the embodiments in the present specification without any inventive step should fall within the scope of protection of the present specification.
As described above, under the consensus mechanism of the present endrmintbft protocol, the consensus master node needs to send redundant proposed data to each consensus backup node, so that the consensus backup node performs consensus logic on the proposed data. Redundant offer data can take up excessive network bandwidth and storage space on the consensus master node. Therefore, the document aims to provide an optimization scheme of the TerdermintBFT protocol, which can effectively reduce network bandwidth and storage space occupied by the consensus main node for transmitting proposed data in the consensus process.
Fig. 1 is a flowchart illustrating a block chain consensus method according to an embodiment of the present disclosure. The method shown in fig. 1 may be performed by a corresponding apparatus below, comprising the steps of:
s102, when the consensus main node of the block chain initiates the consensus, the proposed data of the consensus is split into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus.
Erasure Coding (EC) is a method of data fault-tolerant protection that segments data into segments, expands, encodes, and stores redundant data blocks in different locations, such as disks, storage nodes, or other geographic locations. From a data function perspective, the protection provided by erasure codes can be given by the following formula: n is represented by k + m. The variable "k" represents the value of the original data or symbol. The variable "m" represents the value of an extra or redundant symbol added after a failure to provide protection. The variable "n" represents the total value of the symbols created after the erasure coding process. For example, in one EC 10/16 configuration, there would be 6 additional symbols (variable m) added to the 10 original symbols (variable k). These 16 data segments (variable n) may be spread over 16 drives, nodes or geographical locations, while the original file may be reconstructed from 10 verification segments. That is, the original file can be restored even if 6 drives, nodes, or geographic locations are lost or unavailable. It can be seen that the erasure code only needs redundancy with a small amount of data to achieve restoration of data.
In the embodiment of the present specification, an erasure code technology is used to split proposed data to be identified into data blocks corresponding to identified backup nodes, and the identified backup nodes subsequently store the data blocks.
And S104, the consensus master node sends the data blocks obtained by splitting the proposed data to the corresponding consensus backup nodes in the block chain through a prompt message at the prompt stage of the TerdermintBFT protocol.
In the process phase of the traditional TerdermintBFT protocol, the consensus master node sends the full amount of proposal data with redundancy to each consensus backup node through a process message. In the step, the erasure code algorithm is used for only sending the corresponding data block to the consensus backup node, so that the transmission overhead of the consensus main node can be effectively reduced.
It should be noted here that the multiple data blocks into which the proposed data is split may correspond to the common backup nodes of the blockchain one to one; or the number of the plurality of data blocks into which the data is proposed to be split is smaller than the number of the consensus backup nodes of the block chain, and one consensus backup node corresponds to one data block at most. Thus, in this step, the consensus primary node may, but need not, send data blocks to each consensus backup node of the block chain, depending on the algorithmic setting of the erasure code.
S106, the consensus backup node receiving the data blocks carries out erasure code check on the data blocks provided by the consensus master node, so that the data blocks successfully checked by the erasure code are broadcast to other consensus backup nodes through a Pre-byte message in the Pre-byte stage of the TerdermintBFT protocol.
Specifically, the data blocks into which the proposed data are split correspond to the mercker tree path information obtained based on an erasure code algorithm. And the consensus master node also sends the path information of the Mercker trees matched with the data blocks obtained by splitting the proposed data into data blocks to corresponding consensus backup nodes in the block chain through the prompt message. In this step, the consensus backup node that receives the data block reconstructs the tacher tree of the data block provided by the consensus master node based on the erasure code algorithm, if the tacher tree path information provided by the consensus node is matched with the reconstructed tacher tree, the erasure code verification is successful, otherwise, the erasure code verification fails.
In addition, as a preferable scheme, if the proposal data of the current round of consensus is initiated in the previous round of consensus, the proposal data is cached when the consensus backup node performs the previous round of consensus, and then the step can directly perform matching check with higher speed on the basis of the data block provided by the cached proposal data consensus main node to replace erasure code check. And if the proposal data of the current round of consensus does not originate from the previous round of consensus, the consensus backup node receiving the data block performs erasure code check on the data block provided by the consensus main node.
And S108, the consensus backup node point restores the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on an erasure code algorithm, so that consensus logic of the TerdermintBFT protocol is executed on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
Where N-2f reverts back to the minimum number of data blocks required for the proposed data.
Specifically, in this step, if the consensus backup node restores the extracted data based on the erasure code algorithm, the Pre-commit message is broadcast to other consensus nodes of the block chain at the Pre-vote stage; wherein, when the current round of consensus generates N-f Pre-commit messages, the proposed data achieves a passing consensus.
Based on the consensus method shown in fig. 1, it can be known that: in the solution of the embodiment of the present specification, when performing the consensus of endrmintbft, the consensus master node of the block chain splits proposed data into data blocks corresponding to the consensus backup node using an erasure code algorithm, and sends the split data blocks to the corresponding consensus backup node. And then, the consensus backup node performs erasure code verification on the data blocks provided by the consensus main node based on an erasure code technology, and forwards the data blocks to other consensus backup nodes after the verification is successful, so that after each consensus backup node of the block chain obtains a certain number of data blocks, the obtained data blocks can be restored back to the proposed data through an erasure code algorithm, and consensus logic is performed on the proposed data. In the whole scheme, the consensus master node only needs to send the corresponding data blocks to the consensus backup nodes, and the consensus backup nodes mutually forward the respective data blocks, so that the transmission of the proposed data is shared, and the fault tolerance of the transmission of the proposed data is realized with smaller network bandwidth and storage space overhead.
The following describes in detail the consensus method of the examples of the present specification.
In the methods of embodiments of the present specification, the chain of blocks performs consensus based on the TerdermintBFT protocol. The number of the common identification nodes of the block chain is set to be N, the fault-tolerant number of the common identification nodes of the Byzantine is set to be f, and N > is 3f + 1. The corresponding consensus process is as follows:
the proposed node in the blockchain initializes the height to be agreed, hp, and other parameters based on the current consensus blockheight. And initiating the current consensus height. The consensus comprises the following stages:
a Propose stage:
and each consensus node judges whether to be a consensus main node of the current consensus according to the information consensus height hp and the consensus round roundp initiated by the current consensus.
If the node is used as the consensus master node, acquiring proposed data (firstly checking whether the previous round has cache data or not, if so, using the cache data, otherwise, acquiring new proposed data), and then performing (N-2f, N) erasure code on the proposed data to obtain a data block corresponding to the consensus backup node and the Mercker tree path information of the data block (namely, a root hash value obtained by the erasure code calculation); and then in a process stage, sending the data blocks into which the proposed data are split by a process message < process, hp, roundp, r, bi, si, -1> to the corresponding consensus backup nodes in the block chain. Wherein i represents the ith consensus backup node, si is a data block corresponding to the ith consensus backup node, and bi is the merckel tree merkle path information for the ith consensus backup node.
If the node is used as the consensus backup node, waiting for collecting the data of the Propose message, and checking the information in the Propose message when receiving the message < Propose, hp, roundp, r, bi, si, -1> sent by the consensus master node. It should be understood that checking the information in the dispose message includes: and carrying out erasure code verification based on the si and the bi.
Pre-vote phase:
if the Propos message passes the check, broadcasting a Pre-vote message < Pre-vote, hp, roundp, r, bi, si > to other common identification backup nodes, and if the Propos message does not pass the check, broadcasting a Pre-vote nil message < Pre-vote, hp, roundp, nil, nil > message to other common identification backup nodes, wherein the Pre-vote nil message is used for voting a null block.
When any consensus backup node receives N-F effective Pre-votes: at least si in each of the N-2f Pre-votes is used for erasure code calculation to recover the proposal data.
Pre-commit stage:
if any consensus node obtains effective proposal data, broadcasting a Pre-commit message < Precommit, hp, roundp, r > to other consensus nodes; otherwise, a Pre-commit nil message is broadcast. The reason why the consensus backup node broadcasts the Pre-commit nil message may be that the consensus backup node does not collect the information reaching the N-F Pre-votes, or that the consensus backup node collects the information reaching the N-F Pre-votes but does not restore the information to obtain valid proposed data through erasure code calculation.
Wherein, when the current round of consensus generates N-f Pre-commit messages, the proposed data achieves a passing consensus. When the current round of consensus generates f Pre-commit nil messages, the proposal data directly determines that a failed consensus is achieved.
To sum up, the method in the embodiment of the present specification integrates data fault-tolerant transmission based on erasure codes into the endrmintbft protocol, and compared with the conventional endrmintbft protocol, does not increase additional signaling overhead, but significantly improves the transmission efficiency of proposed data, and improves the consensus efficiency for the endrmintbft protocol consensus.
The above is a description of the method of the embodiments of the present specification. It will be appreciated that appropriate modifications may be made without departing from the principles outlined herein, and such modifications are intended to be included within the scope of the embodiments herein.
In correspondence with the consensus method shown in fig. 1, an embodiment of the present disclosure further provides a blockchain system. Fig. 2 is a block diagram of a blockchain system 200 according to an embodiment of the present disclosure, which includes: consensus master node 210 and a plurality of consensus backup nodes 220. Wherein:
when the consensus master node 210 initiates the consensus of the current round, the proposed data of the consensus of the current round is split into data blocks corresponding to the consensus backup nodes 220 of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
the consensus master node 210 sends the data blocks obtained by splitting the proposed data to the corresponding consensus backup node 220 in the block chain through a prompt message at the prompt stage of the endrmintbft protocol;
the consensus backup node 220 receiving the data block performs erasure code check on the data block provided by the consensus master node 210, so that the data block successfully subjected to erasure code check is broadcast to other consensus backup nodes 220 through a Pre-vote message in the Pre-vote stage of the terdermintbft protocol;
the consensus backup node 220 restores the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, so as to execute the consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol, and complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is greater than or equal to 3f + 1.
In the blockchain system of the embodiment, when performing the consensus of endrmintbft, the consensus master node 210 splits the proposed data into data blocks corresponding to the consensus backup node 220 using an erasure coding algorithm, and sends the split data blocks to the corresponding consensus backup node 220. Then, the consensus backup node 220 performs erasure code verification on the data blocks provided by the consensus master node 210 based on an erasure code technology, and forwards the data blocks to other consensus backup nodes 220 after the verification is successful, so that after each consensus backup node 220 of the block chain obtains a certain number of data blocks, the obtained data blocks can be restored to the proposed data through an erasure code algorithm, so as to execute consensus logic on the proposed data. In the whole scheme, the consensus master node 210 only needs to send the corresponding data blocks to the consensus backup nodes 220, and the consensus backup nodes 220 forward the respective data blocks mutually, so that the transmission of the proposed data is shared, and the fault tolerance of the transmission of the proposed data is realized with lower network bandwidth and storage space overhead.
Optionally, if the erasure code check fails, the consensus backup node 220 that receives the data block broadcasts a Pre-volume nil message to other consensus nodes in the Pre-volume stage of the terdermintbft protocol, where the Pre-volume nil message is used to vote for a null block.
Optionally, the consensus backup node 220 restores the data blocks in the obtained Pre-vote message back to the data extraction data based on the erasure coding algorithm in the Pre-vote stage of the terdermintbft protocol, including: after the consensus backup node 220 obtains at least N-f previous messages including the previous message provided by the consensus backup node itself, the obtained data in the previous message is quickly restored to the proposed data based on the erasure code algorithm.
Optionally, the consensus backup node 220 executes consensus logic of the terdermintbft protocol on the proposed data restored in the Pre-vote phase of the terdermintbft protocol, including: if the consensus backup node 220 restores the extracted data based on the erasure code algorithm, broadcasting a Pre-commit message to other consensus nodes of the block chain at the Pre-vote stage of the TerdermintBFT protocol; wherein, when the current round of consensus generates N-f Pre-commit messages, the proposed data achieves a passing consensus.
Optionally, if the consensus backup node 220 fails to recover the extracted data, broadcasting a Pre-commit nil message to other consensus nodes of the block chain at the Pre-vote stage of the terdermintbft protocol; wherein, when the current round of consensus generates f Pre-commit nil messages, the proposal data directly determines that an unsuccessful consensus is achieved.
Optionally, the data blocks into which the proposed data is split correspond to merkel tree path information obtained based on the erasure code algorithm, and the consensus master node 210 further sends the merkel tree path information matched with the data blocks into which the proposed data is split to the corresponding consensus backup node 220 in the block chain through a prompt message; the consensus backup node 220 that receives the data block performs erasure code checking on the data block provided by the consensus primary node 210, including: the consensus backup node 220 that receives the data block reconstructs the tacher tree of the data block provided by the consensus master node 210 based on the erasure code algorithm, if the tacher tree path information provided by the consensus node is matched with the reconstructed tacher tree, the erasure code verification is successful, otherwise the erasure code verification fails.
Optionally, the erasure code checking, performed by the consensus backup node 220 that receives the data block, on the data block provided by the consensus primary node 210 includes: if the proposed data is not initiated by the consensus of the previous round, the consensus backup node 220 that receives the data block performs erasure code check on the data block provided by the consensus master node 210, otherwise, the proposed data that directly passes through the consensus cache of the previous round performs matching check on the data block provided by the consensus master node 210 to replace the erasure code check.
Obviously, the blockchain system of the embodiment of the present specification can be used as the execution subject of the consensus method shown in fig. 1, and thus can implement the function of the consensus method implemented in fig. 1. Since the principle is the same, the detailed description is omitted here.
Corresponding to the consensus method shown in fig. 1, an embodiment of the present specification further provides a blockchain node. Fig. 3 is a block diagram of a block link point 300 according to an embodiment of the present disclosure, including:
the erasure code module 310, when the local round of consensus is initiated, if the node of the block chain to which the node belongs is the consensus master node, splits the proposed data of the local round of consensus into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a terminermintbft byzantine protocol for consensus;
a sending module 320, configured to send, in a prompt stage of the endrmintbft protocol, a data block obtained by splitting the proposed data by a prompt message to a corresponding consensus backup node in the block chain if the block chain node to which the proposed data belongs is the consensus master node;
the checking module 330, if the block chain node to which the block chain node belongs is a consensus backup node, performs erasure code checking on the data block provided by the consensus master node, so that the data block successfully checked by the erasure code is broadcast to other consensus backup nodes through a Pre-vote message at the Pre-vote stage of the terdermintbft protocol;
if the block chain node to which the block chain node belongs is a consensus backup node, the recovery module 340 recovers the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, so as to execute the consensus logic of the TerdermintBFT protocol on the recovered proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of the consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is greater than or equal to 3f + 1.
Obviously, the block link node of the embodiment of the present disclosure may be a consensus primary node or a consensus backup node in the consensus method shown in fig. 1, and thus can implement the function of the consensus method implemented in fig. 1. Since the principle is the same, the detailed description is omitted here.
Fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present disclosure. Referring to fig. 4, at a hardware level, the electronic device includes a processor, and optionally further includes 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, such as at least 1 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 connected to each other via an internal bus, which may be an ISA (Industry Standard Architecture) bus, a PCI (Peripheral Component Interconnect) bus, an EISA (Extended Industry Standard Architecture) bus, or the like. The bus may 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. 4, but that does not indicate only one bus or one type of bus.
And the memory is used for storing programs. In particular, the program may include program code comprising computer operating instructions. The memory may include both memory and non-volatile storage and provides instructions and data to the processor.
The processor reads a corresponding computer program from the nonvolatile memory into the memory and then runs the computer program to form a consensus device on a logic level, wherein the consensus device can be a consensus main node or a consensus backup node of the blockchain system, or a component of the consensus main node or the consensus backup node of the blockchain system. The processor is used for executing the program stored in the memory and is specifically used for executing the following operations:
when the consensus of the current round is initiated, if the consensus is taken as a main consensus node, splitting the proposed data of the consensus of the current round into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
if the node is used as a consensus backup node, in a prompt stage of the TerdermintBFT protocol, sending the data blocks obtained by splitting the proposed data to the corresponding consensus backup node in the block chain through a prompt message;
if the node is used as a consensus backup node, performing erasure code check on the data blocks provided by the consensus master node, so that the data blocks successfully subjected to erasure code check are broadcast to other consensus backup nodes through a Pre-byte message in a Pre-byte stage of the TerdermintBFT protocol;
if the candidate block is used as a consensus backup node, restoring the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, and executing consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
The consensus method as disclosed above in the embodiment of fig. 1 of the present specification may 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), and the like; but also Digital Signal Processors (DSPs), Application Specific Integrated Circuits (ASICs), Field Programmable Gate Arrays (FPGAs) or other Programmable logic devices, discrete Gate or transistor logic devices, discrete hardware components. The various methods, steps and logic blocks disclosed in the embodiments of the present specification 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 a method disclosed in connection with the embodiments of the present specification may be embodied directly in a hardware decoding processor, or in a combination of hardware and software modules in the decoding processor. 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.
It should be understood that the electronic device of the embodiment of the present specification can implement the functions of the embodiment of the above-mentioned consensus method shown in fig. 1. Since the principle is the same, the detailed description is omitted here.
Of course, besides the software implementation, the electronic device in this specification does not exclude other implementations, such as logic devices or a combination of software and hardware, and the like, that is, the execution subject of the following processing flow is not limited to each logic unit, and may also be hardware or logic devices.
Furthermore, the present specification embodiments also propose a computer-readable storage medium storing one or more programs, the one or more programs comprising instructions, which when executed by a portable electronic device comprising a plurality of application programs, are capable of causing the portable electronic device to perform the method of the embodiment shown in fig. 1, and in particular to perform the following method:
when the consensus of the current round is initiated, if the consensus is taken as a main consensus node, splitting the proposed data of the consensus of the current round into data blocks corresponding to the consensus backup nodes of the block chain based on an erasure code algorithm, wherein the block chain adopts a TerdermintBFT Byzantine protocol for consensus;
if the node is used as a consensus backup node, in a prompt stage of the TerdermintBFT protocol, sending the data blocks obtained by splitting the proposed data to the corresponding consensus backup node in the block chain through a prompt message;
if the node is used as a consensus backup node, performing erasure code check on the data blocks provided by the consensus master node, so that the data blocks successfully subjected to erasure code check are broadcast to other consensus backup nodes through a Pre-byte message in a Pre-byte stage of the TerdermintBFT protocol;
if the candidate block is used as a consensus backup node, restoring the data blocks in the obtained at least N-2f Pre-votes to the proposed data based on the erasure code algorithm, and executing consensus logic of the TerdermintBFT protocol on the restored proposed data at the Pre-commit stage of the TerdermintBFT protocol to complete the cycle of consensus, wherein N is the number of consensus nodes of the block chain, f is the fault-tolerant number of the consensus nodes set by the TerdermintBFT protocol, and N is more than or equal to 3f + 1.
As will be appreciated by one skilled in the art, embodiments of the present description may be provided as a method, system, or computer program product. Accordingly, the description may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the 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, and the like) having computer-usable program code embodied therein.
The foregoing description has been directed to specific embodiments of this disclosure. Other embodiments are within the scope of the following claims. In some cases, the actions or steps recited in the claims may be performed in a different order than 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. In some embodiments, multitasking and parallel processing may also be possible or may be advantageous.
The above description is only an example of the present specification, and is not intended to limit the present specification. Various modifications and alterations to this description will become apparent to those skilled in the art. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present specification should be included in the scope of the claims of the present specification. Moreover, all other embodiments obtained by a person skilled in the art without making any inventive step shall fall within the scope of protection of this document.