The present application is based on, and claims priority from, Korean Patent Application Number 10-2023-0176839, filed Dec. 7, 2023, the disclosure of which is incorporated by reference herein in its entirety.
The present disclosure relates to a method and apparatus for generating a consensus for enduring a node failure, and more particularly, to a method and apparatus for generating a consensus, capable of proceeding with an agreement even if a node failure occurs during an agreement in a blockchain network.
The content described below simply provides background information related to the present embodiment and does not constitute prior art.
Blockchain is a data distribution processing technology that distributes and stores data regarding transaction details that may be generated by all users participating in a network. Transaction details generated by users over a certain period of time are confirmed through the agreement of more than half of the users. Confirmed transaction details are bundled into one block and stored in the blockchain. In order to change the transaction details stored in the blockchain, the agreement of more than half of the users should be obtained for the corresponding block and all blocks connected after the corresponding block, so it is impossible to practically forge or modify the data stored in the blockchain.
In the blockchain network, an agreement is performed using a consensus generated using nodes. While performing the agreement, a failure may occur in a specific node among the nodes used to generate the consensus. In this case, if a new consensus is generated by replacing the specific node in which a failure occurs and the agreement proceeds again, the agreement may not be interrupted. Here, if the specific node in which the failure occurs is a chair node, there is a problem in that the agreement is interrupted because the chair node cannot be replaced. Therefore, it is necessary to ensure that the agreement is not interrupted even if a failure occurs in the chair node while an agreement is performed.
In view of the above, the present disclosure is to generate a consensus using nodes having the number of a voting right equal to or less than a predetermined number.
In addition, according to an embodiment, the present disclosure is to delete information on nodes in which a failure occurs in a candidate consensus, update the candidate consensus, and generate a final consensus using the updated candidate consensus.
The problems to be solved by the present disclosure are not limited to the problems mentioned above, and other problems not mentioned may be clearly understood by those skilled in the art from the description below.
According to the present disclosure, a method for generating a consensus includes calculating hash values using a header value of a block and a node list. The method also includes generating a candidate consensus by comparing the hash values with a threshold value. The method also includes generating a sorted candidate consensus by sorting node information in the candidate consensus. The method also includes generating a final consensus by selecting node information in the sorted candidate consensus as many as a consensus quorum based on a number of voting rights of each node. The node information is information on a node ID and a hash value pair.
According to the present disclosure, a method for generating a consensus includes calculating hash values using a header value of a block and a node list. The method also includes generating a candidate consensus by comparing the hash values with a threshold value. The method also includes generating a sorted candidate consensus by sorting node information in the candidate consensus. The method also includes generating a first final consensus by selecting node information in the sorted candidate consensus as many as a consensus quorum and performing an agreement. The method also includes generating a first candidate consensus by deleting node information on a chair node from among the node information in the sorted candidate consensus when a failure occurs in the chair node during the agreement. The method also includes generating a second final consensus using node information in the first candidate consensus. The node information is information on a node ID and a hash value pair.
According to the present disclosure, an apparatus for generating a consensus includes a memory and a plurality of processors. At least one of the plurality of processors is configured to calculate hash values using a header value of a block and a node list. The at least one of the plurality of processors is also configured to generate a candidate consensus by comparing the hash values with a threshold value. The at least one of the plurality of processors is also configured to generate a sorted candidate consensus by sorting node information in the candidate consensus. The at least one of the plurality of processors is also configured to generate a final consensus by selecting node information in the sorted candidate consensus as many as a consensus quorum based on a number of voting rights of each node. The node information is information on a node ID and a hash value pair.
According to the present disclosure, there is an effect of generating a consensus using nodes having the number of a voting right equal to or less than a predetermined number, so that consensus may proceed even if a node failure occurs during an agreement.
In addition, according to an embodiment, information on nodes in which a failure occurs in a candidate consensus, the candidate consensus is updated, and a final consensus is generated using the updated candidate consensus, so that consensus may proceed even if a node failure occurs in a chair node during an agreement.
The effects that may be obtained from the present disclosure are not limited to the effects mentioned above, and other effects not mentioned may be clearly understood by those skilled in the art from the description below.
Hereinafter, some exemplary embodiments of the present disclosure will be described in detail with reference to the accompanying drawings. In the following description, like reference numerals preferably designate like elements, although the elements are shown in different drawings. Further, in the following description of some embodiments, a detailed description of known functions and configurations incorporated therein will be omitted for the purpose of clarity and for brevity.
Additionally, various terms such as first, second, A, B, (a), (b), etc., are used solely to differentiate one component from the other but not to imply or suggest the substances, order, or sequence of the components. Throughout this specification, when a part ‘includes’ or ‘comprises’ a component, the part is meant to further include other components, not to exclude thereof unless specifically stated to the contrary. The terms such as ‘unit’, ‘module’, and the like refer to one or more units for processing at least one function or operation, which may be implemented by hardware, software, or a combination thereof.
The following detailed description, together with the accompanying drawings, is intended to describe exemplary embodiments of the present disclosure, and is not intended to represent the only embodiments in which the present disclosure may be practiced.
Referring to
The hash value calculating unit 110 calculates hash values using a header value of an agreed upon block and ID values of nodes. Hash values are calculated using a hash function and a hash operation. For example, the hash function may be secure hash algorithm 256 (sha256). The hash value may consist of only some of output bits of the hash function. For example, the hash value may consist of only 32 bits, which are some of the output bits of sha256 of the hash function. The hash value calculating unit 110 calculates hash values based on the number of voting rights of the nodes. For example, if a node has three voting rights, the hash value calculating unit 110 may calculate three hash values, while increasing an ID value.
The candidate consensus generating unit 120 compares the calculated hash values with a threshold value to generate a candidate consensus. The threshold value may be any value. The threshold value may be a predefined value. The candidate consensus generating unit 120 adds node information including only hash values less than or equal to the threshold value to the candidate consensus. Here, the node information may be information on a [node ID, hash value] pair. The candidate consensus generating unit 120 sorts the node information in the candidate consensus in descending order of hash value.
The final consensus generating unit 130 generates a final consensus using the candidate consensus and node information as many as (3f+1), which is a consensus quorum. For example, when the consensus quorum is 7, the final consensus generating unit 130 may generate the final consensus by selecting the first node information to seventh node information from the candidate consensus sorted in descending hash value order. Here, f may be any predefined positive integer.
Referring to
The candidate consensus generating unit 120 generates a candidate consensus 240 by comparing each calculated hash value Hi with a threshold value T. The candidate consensus generating unit 120 generates the candidate consensus 240 using node information including hash values that are less than or equal to the threshold value T. The candidate consensus generating unit 120 may generate the candidate consensus 240 by using [ID0, H0], [ID0, H0+1], [ID0, H0+2], [ID1, H1], [ID2, H2], and [ID3, H3]. The candidate consensus generating unit 120 sorts the node information in the candidate consensus 240 in descending order of hash values. The candidate consensus generating unit 120 may sort the node information in the candidate consensus 240 in order of [ID0, H0], [ID1, H1], [ID0, H0+1], [ID0, H0+2], [ID3, H3], and [ID2, H2] which is descending order of hash values.
The final consensus generating unit 130 generates the final consensus 250 using the candidate consensus 240 and the consensus quorum (3f+1). Here, f may be any positive integer. f may be a predefined value. When f is 1, the final consensus generating unit 130 may generate the final consensus 250 using four node information. The final consensus generating unit 130 generates the final consensus 250 so that the number of voting rights of each node included in the final consensus 250 does not exceed f. The node included in the final consensus 250 is a node having the ID of the node information included in the final consensus 250. If f is 1, the number of voting rights of each node included in the final consensus 250 should not exceed 1. If f is 1, the final consensus generating unit 130 may generate the final consensus 250 using [ID0, H0], [ID1, H1], [ID3, H3], and [ID2, H2] among the node information in the candidate consensus 240. [ID0, H0+1] and [ID0, H0+2] may not be used to generate the final consensus 250 because the voting right of node 0 included in the final consensus 250 should not exceed 1.
Referring to
The candidate consensus generating unit 120 generates a candidate consensus 340 by comparing each calculated hash value Hi with a threshold value T. The candidate consensus generating unit 120 generates the candidate consensus 340 using node information including hash values that are less than or equal to the threshold value T. The candidate consensus generating unit 120 may generate the candidate consensus 340 by using [ID0, H0], [ID0, H0+1], [ID1, H1], [ID2, H2], [ID3, H3], and [ID4, H4]. The candidate consensus generating unit 120 sorts the node information in the candidate consensus 340 in descending order of hash values. The candidate consensus generating unit 120 may sort the node information in the candidate consensus 340 in order of [ID0, H0], [ID1, H1], [ID0, H0+1], [ID3, H3], [ID2, H2], and [ID4, H4] which is descending order of hash values.
The final consensus generating unit 130 generates the final consensus 350 using the candidate consensus 340 and the consensus quorum (3f+1). When f is 1, the final consensus generating unit 130 may generate the final consensus 350 using four pieces of node information. The final consensus generating unit 130 generates the final consensus 350 without limitation on the number of voting rights of each node included in the final consensus 350. If f is 1, the final consensus generating unit 130 may generate the final consensus 350 using [ID0, H0], [ID1, H1], [ID0, H0+1], and [ID3, H3] among the node information in the candidate consensus 340.
If f is 1 and the hash value H0 has the smallest hash value among the hash values in the final consensus 350, node 0 included in the final consensus 350 may be a chair node because it has the smallest hash value H0. The node included in the final consensus 350 is a node having the ID of the node information included in the final consensus 350. Node 0 may be a chair node because it has the smallest hash value. If a failure occurs in the chair node, the candidate consensus generating unit 120 deletes the node information on the chair node in the candidate consensus 340. If a failure occurs in node 0, which is the chair node, the candidate consensus generating unit 120 may delete [ID0, H0] and [ID0, H0+1], which are node information for node 0, in the candidate consensus 340. The final consensus generating unit 130 generates a new final consensus 360 using the candidate consensus 340 from which the node information on the chair node has been deleted. The final consensus generating unit 130 generates a new final consensus 360 using the candidate consensus 340 from which the node information on node 0 has been deleted. The final consensus generating unit 130 may generate the new final consensus 360 using [ID1, H1], [ID3, H3], [ID2, H2], and [ID4, H4] among the node information in the candidate consensus 340 from which the node information for node 0 has been deleted.
Referring to
When the failure of node 0 is confirmed, the candidate consensus generating unit 120 deletes the node information on node 0 in the candidate consensus. The final consensus generating unit 130 may generate a new final consensus using a candidate consensus from which the node information on node 0 has been deleted. The final consensus generating unit 130 may generate the new final consensus using nodes that may replace the number of voting rights of node 0. The final consensus generating unit 130 may generate the new final consensus using node 2 and node 4 to replace node 0. Accordingly, the new final consensus may include node 1, node 2, node 3, and node 4. Thereafter, node 1, node 2, node 3, and node 4 may perform a new consensus.
Referring to
The final consensus generating unit 130 determines whether the number of voting rights of a specific node included in the final consensus is less than f (S560). Here, the specific node is a node having the node ID of the node information obtained in S550. If it is determined that the number of voting rights of the specific node included in the final consensus is equal to or exceeds f (S560-NO), the final consensus generating unit 130 obtains node information from the candidate consensus in descending order of hash values (S550). If it is determined that the number of voting rights of the specific node included in the final consensus is less than f (S560-YES), the final consensus generating unit 130 determines whether the sum of voting rights of nodes included in the final consensus is less than (3f+1), which is the consensus quorum (S570). If it is determined that the sum of voting rights of the nodes included in the final consensus is not less than (3f+1) (S570-NO), the final consensus generating unit 130 determines a chair node among the nodes included in the final consensus (S580). The final consensus generating unit 130 determines a node having the smallest hash value as a chair node. If it is determined that the sum of voting rights of the nodes included in the final consensus is less than (3f+1) (S570-YES), the final consensus generating unit 130 adds the obtained node information to the final consensus (S590). the final consensus generating unit 130 obtains node information from the candidate consensus in descending order of hash values (S550).
Referring to
If it is determined that the conditions for replacing the chair node are not met (S630-NO), the nodes included in the existing final consensus perform an agreement by exchanging agreement messages (S610). If it is determined that the conditions for replacing the chair node are met (S630-YES), all nodes connected to the blockchain network excluding the chair node verify the failure of the chair node (S640). If the failure of the chair node is not verified (S640-NO), the nodes included in the existing final consensus perform an agreement by exchanging consensus messages (S610). If the failure of the chair node is verified (S640-YES), the occurrence of a failure of the chair node is confirmed, and the candidate consensus generating unit 120 deletes the node information on the chair node in the candidate consensus (S650).
The final consensus generating unit 130 obtains node information in descending order of hash values from candidate consensus from which the node information on the chair node has been deleted (S660). The final consensus generating unit 130 determines whether the sum of voting rights of nodes included in the new final consensus is less than (3f+1), which is the consensus quorum (S670). If it is determined that the sum of voting rights of the nodes included in the new final consensus is not less than (3f+1) (S670-NO), the final consensus generating unit 130 determines a chair node among the nodes included in the final consensus (S680). The final consensus generating unit 130 may determine a node having the smallest hash value within the final consensus as a chair node. If it is determined that the sum of voting rights of the nodes included in the new final consensus is less than (3f+1) (S670-YES), the final consensus generating unit 130 adds the obtained node information to the final consensus (S690). The final consensus generating unit 130 obtains node information in descending order of hash values from candidate consensus from which the node information on the chair node has been deleted (S660).
Referring to
The candidate consensus generating unit 120 sorts the node information in the candidate consensus to generate a sorted candidate consensus (S730). The process of generating the sorted candidate consensus may include sorting node information in the candidate consensus in descending order of hash values to generate a sorted candidate consensus.
The final consensus generating unit 130 generates a final consensus by selecting the node information in the candidate consensus sorted based on the number of voting rights of each node as many as the consensus quorum (S740). The consensus generating apparatus 10 determines a node having the smallest hash value among the nodes included in the final consensus as a chair node. The process of generating the final consensus may include a process of generating the final consensus using the node information in the candidate consensus sorted so that the number of voting rights of the nodes included in the final consensus does not exceed a first value. The node information may be information on a node ID and a hash value pair. The first value may be any positive integer value. The first value may be a predefined value. The consensus quorum may be a value obtained by multiplying the first value by 3 and adding 1 to the value.
Referring to
The candidate consensus generating unit 120 sorts the node information in the candidate consensus to generate a sorted candidate consensus (S830). The process of generating a sorted candidate consensus may include a process of sorting node information in the candidate consensus in descending order of hash values to generate a sorted candidate consensus.
The final consensus generating unit 130 selects the node information in the sorted candidate consensus as many as the consensus quorum to generate a first final consensus (S840). If a failure occurs in the chair node during an agreement, the candidate consensus generating unit 120 deletes the node information on the chair node from the node information in the sorted candidate consensus to generate a first candidate consensus (S850). The final consensus generating unit 130 generates a second final consensus using the node information in the first candidate consensus (S860). The consensus generating apparatus 10 may determine a node having the smallest hash value among the nodes included in the second final consensus as a new chair node. The process of generating the second final consensus may include a process of generating the second final consensus using the node information in the first candidate consensus based on the number of pieces of node information on the deleted chair node.
Each element of the apparatus or method in accordance with the present invention may be implemented in hardware or software, or a combination of hardware and software. The functions of the respective elements may be implemented in software, and a microprocessor may be implemented to execute the software functions corresponding to the respective elements.
Various embodiments of systems and techniques described herein can be realized with digital electronic circuits, integrated circuits, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), computer hardware, firmware, software, and/or combinations thereof. The various embodiments can include implementation with one or more computer programs that are executable on a programmable system. The programmable system includes at least one programmable processor, which may be a special purpose processor or a general purpose processor, coupled to receive and transmit data and instructions from and to a storage system, at least one input device, and at least one output device. Computer programs (also known as programs, software, software applications, or code) include instructions for a programmable processor and are stored in a “computer-readable recording medium.”
The computer-readable recording medium may include all types of storage devices on which computer-readable data can be stored. The computer-readable recording medium may be a non-volatile or non-transitory medium such as a read-only memory (ROM), a random access memory (RAM), a compact disc ROM (CD-ROM), magnetic tape, a floppy disk, or an optical data storage device. In addition, the computer-readable recording medium may further include a transitory medium such as a data transmission medium. Furthermore, the computer-readable recording medium may be distributed over computer systems connected through a network, and computer-readable program code can be stored and executed in a distributive manner.
Although operations are illustrated in the flowcharts/timing charts in this specification as being sequentially performed, this is merely an exemplary description of the technical idea of one embodiment of the present disclosure. In other words, those skilled in the art to which one embodiment of the present disclosure belongs may appreciate that various modifications and changes can be made without departing from essential features of an embodiment of the present disclosure, that is, the sequence illustrated in the flowcharts/timing charts can be changed and one or more operations of the operations can be performed in parallel. Thus, flowcharts/timing charts are not limited to the temporal order.
Although exemplary embodiments of the present disclosure have been described for illustrative purposes, those skilled in the art will appreciate that various modifications, additions, and substitutions are possible, without departing from the idea and scope of the claimed invention. Therefore, exemplary embodiments of the present disclosure have been described for the sake of brevity and clarity. The scope of the technical idea of the present embodiments is not limited by the illustrations. Accordingly, one of ordinary skill would understand that the scope of the claimed invention is not to be limited by the above explicitly described embodiments but by the claims and equivalents thereof.
| Number | Date | Country | Kind |
|---|---|---|---|
| 10-2023-0176839 | Dec 2023 | KR | national |