Method and apparatus for determining consensus nodes, and storage medium

By obtaining multiple rounds of election information from the consensus node contract center, and electing and updating consensus nodes, the problem of existing consensus algorithms relying on blockchain tokens is solved, and consensus node determination without relying on blockchain tokens is achieved, thus improving the flexibility and scalability of the consensus algorithm.

CN115883573BActive Publication Date: 2025-12-16JINGDONG TECH HLDG CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202110924446.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-08-12
Publication Date
2025-12-16
Estimated Expiration
2041-08-12

AI Technical Summary

Technical Problem

Existing consensus algorithms rely on blockchain tokens to determine consensus nodes, resulting in excessive dependence.

Method used

By obtaining multiple rounds of election information from the consensus node contract center, consensus nodes for the current and next election rounds are elected based on the multiple rounds of election information, and when the number of consensus nodes elected in all election rounds is equal to the number of consensus nodes to be elected, it is determined as the final consensus node.

Benefits of technology

This paper presents a method for determining consensus nodes without relying on blockchain tokens, which addresses the shortcomings of existing technologies that depend on blockchain tokens and improves the flexibility and scalability of consensus algorithms.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115883573B_ABST
    Figure CN115883573B_ABST
Patent Text Reader

Abstract

The present disclosure relates to a method and device for determining consensus nodes and a storage medium. The method comprises: obtaining multi-round election information from a consensus node contract center, wherein the multi-round election information comprises a number of consensus nodes to be elected; electing consensus nodes for a current election round according to the multi-round election information, and updating the multi-round election information according to the consensus nodes elected for the current election round; electing consensus nodes for a next election round of the current election round according to the multi-round election information updated in the current election round; and determining all the consensus nodes elected in all the election rounds as final consensus nodes if the number of all the consensus nodes elected in all the election rounds is equal to the number of consensus nodes to be elected. The above technical means solves the problem that the existing consensus algorithm needs to rely on regional chain tokens to determine consensus nodes in the prior art.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of Internet, and particularly relates to a consensus node determination method and device and storage medium. BACKGROUND

[0002] Because of the characteristics of decentralization, non-tamperability, full traceability, traceability, collective maintenance, openness and transparency, the characteristics ensure the "honesty" and "transparency" of the blockchain, lay the foundation for the creation of trust in the blockchain, at the same time, the blockchain can solve the problem of information asymmetry, realize the collaborative trust and consistent action among multiple subjects, so the blockchain is widely used in various fields. The consensus algorithm is the most core part of the blockchain project, as long as there is distribution, consensus needs to be reached, that is, a consensus algorithm is needed. It can be seen that the consensus algorithm is very important in the blockchain, and the existing consensus algorithms all have their own shortcomings, such as: POS consensus mechanism and DPOS consensus mechanism, the cumulative rights are obtained by multiplying the number of blockchain tokens by the time of holding the blockchain tokens, and the POS consensus mechanism and the DPOS consensus mechanism excessively rely on the blockchain tokens.

[0003] In the process of implementing the present disclosure, the inventors have found that the related art at least has the following technical problems: the existing consensus algorithm needs to rely on the blockchain token to determine the consensus node. SUMMARY

[0004] In order to solve the above technical problems or at least partially solve the above technical problems, the embodiments of the present disclosure provide a consensus node determination method, device and storage medium to at least solve the problem that the existing consensus algorithm needs to rely on the blockchain token to determine the consensus node in the prior art.

[0005] The purpose of the present disclosure is achieved by the following technical solutions:

[0006] In a first aspect, the embodiments of the present disclosure provide a consensus node determination method, comprising: obtaining multi-round election information from a consensus node contract center, wherein the multi-round election information comprises a number of to-be-elected consensus nodes; electing consensus nodes of a current election round according to the multi-round election information, and updating the multi-round election information according to the consensus nodes elected in the current election round; electing consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round; and determining all the consensus nodes elected in all the election rounds as final consensus nodes in a case that the number of all the consensus nodes elected in all the election rounds is equal to the number of to-be-elected consensus nodes.

[0007] In an example embodiment, the electing the consensus nodes of the current election round according to the multi-round election information comprises: obtaining a consensus node blacklist and / or a consensus node whitelist from the consensus node contract center; performing a screening operation on a candidate consensus node list according to the consensus node blacklist and / or the consensus node whitelist, wherein the multi-round election information comprises the candidate consensus node list; and electing the consensus nodes of the current election round according to the candidate consensus node list after the screening operation.

[0008] In an example embodiment, before the electing the consensus nodes of the current election round according to the candidate consensus node list after the screening operation, the method further comprises: querying a node state of a candidate consensus node in the candidate consensus node list; and deleting a withdrawn candidate consensus node from the candidate consensus node list in a case where the node state indicates that the candidate consensus node withdraws.

[0009] In an example embodiment, before the performing the screening operation on the candidate consensus node list according to the consensus node blacklist and / or the consensus node whitelist, the method further comprises: in a case where the candidate consensus node list is an empty list, updating the candidate consensus node list according to a candidate consensus node in the multi-round election information; and calculating the number of consensus nodes to be elected according to the updated candidate consensus node list.

[0010] In an example embodiment, the electing the consensus nodes of the current election round according to the candidate consensus node list after the screening operation comprises: in a case where the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of consensus nodes to be elected, electing all candidate consensus nodes in the candidate consensus node list as the consensus nodes of the current election round; and in a case where the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, randomly electing candidate consensus nodes in the candidate consensus node list according to an election period, and determining the randomly elected candidate consensus nodes as the consensus nodes of the current election round, wherein the multi-round election information comprises the election period.

[0011] In an example embodiment, in the case that the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, the candidate consensus nodes in the candidate consensus node list are randomly elected according to an election period, and the candidate consensus nodes randomly elected are determined as the consensus nodes of the current election round, and then the method further comprises: removing the candidate consensus nodes that have been randomly elected from the candidate consensus node list to obtain a first candidate consensus node list; calculating the number of consensus nodes to be elected according to the first candidate consensus node list; randomly electing the candidate consensus nodes in the first candidate consensus node list according to the election period, wherein the number of elected candidate consensus nodes is equal to the number of consensus nodes to be elected after being calculated and updated; and updating the consensus nodes of the current election round according to the candidate consensus nodes randomly elected.

[0012] In an example embodiment, in the case that the number of all the consensus nodes elected in all the election rounds is equal to the number of consensus nodes to be elected, after all the consensus nodes elected in all the election rounds are determined as final consensus nodes, the method further comprises: sending block information to other nodes in a full-network broadcast manner by the final consensus nodes; receiving feedback information of the other nodes on the block information by the consensus node contract center, and updating a consensus node blacklist and / or a consensus node whitelist according to the feedback information.

[0013] In an example embodiment, the method comprises: in the case that the number of final consensus nodes is less than a preset number, performing a dynamic expansion operation: performing a block information verification operation on a first number of nodes with the highest priority in a consensus node whitelist; and according to the result information of the block information verification operation, determining a second number of nodes elected from the first number of nodes as the final consensus nodes, wherein the first number is greater than the second number.

[0014] In a second aspect, embodiments of the present disclosure provide a consensus node determination apparatus, comprising: an acquisition module configured to acquire multi-round election information from a consensus node contract center, wherein the multi-round election information comprises a number of consensus nodes to be elected; a first election module configured to elect consensus nodes of a current election round according to the multi-round election information, and update the multi-round election information according to the consensus nodes elected in the current election round; a second election module configured to elect the consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round; and a determination module configured to determine all the consensus nodes elected in all the election rounds as final consensus nodes in the case that the number of all the consensus nodes elected in all the election rounds is equal to the number of consensus nodes to be elected.

[0015] In a third aspect, embodiments of the present disclosure provide an electronic device. The electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory complete communication with each other through the communication bus; the memory is configured to store a computer program; and the processor is configured to execute the program stored in the memory to implement the method for determining a consensus node or the method for image processing.

[0016] In a fourth aspect, embodiments of the present disclosure provide a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the method for determining a consensus node or the method for image processing.

[0017] The above technical solution provided by the embodiments of the present disclosure has at least some or all of the following advantages compared with the prior art: the multi-round election information is obtained from the consensus node contract center, wherein the multi-round election information includes the number of consensus nodes to be elected; the consensus nodes of the current election round are elected according to the multi-round election information, and the multi-round election information is updated according to the consensus nodes elected in the current election round; the consensus nodes of the next election round of the current election round are elected according to the multi-round election information updated in the current election round; and in the case that the number of all the consensus nodes elected in all the election rounds is equal to the number of consensus nodes to be elected, all the consensus nodes elected in all the election rounds are determined as final consensus nodes. By using the above technical means, the problem that the existing consensus algorithm needs to rely on regional chain tokens to determine consensus nodes in the prior art is solved, thereby providing a method for determining consensus nodes without relying on regional chain tokens. BRIEF DESCRIPTION OF DRAWINGS

[0018] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, further serve to explain the principles of the present disclosure.

[0019] In order to more clearly illustrate the technical solutions of the embodiments of the present disclosure or the prior art, the accompanying drawings needed to be used in the embodiments or related description will be briefly introduced. Obviously, for those skilled in the art, other drawings can also be obtained without creative labor based on these drawings.

[0020] Figure 1 The hardware structure block diagram of the computer terminal of the consensus node determination method according to an embodiment of the present disclosure is schematically shown;

[0021] Figure 2 The flowchart of the consensus node determination method according to an embodiment of the present disclosure is schematically shown;

[0022] Figure 3 The flowchart illustrates a method for determining consensus nodes in the current election round according to an embodiment of the present disclosure.

[0023] Figure 4 This schematically illustrates a flowchart of a method for determining the consensus node of the current election round through random election, according to an embodiment of the present disclosure.

[0024] Figure 5 The diagram schematically illustrates a structural block diagram of a consensus node determination device according to an embodiment of the present disclosure;

[0025] Figure 6 The schematic diagram illustrates a structural block diagram of an electronic device provided in an embodiment of the present disclosure. Detailed Implementation

[0026] The present disclosure will be described in detail below with reference to the accompanying drawings and embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of the present disclosure can be combined with each other.

[0027] It should be noted that the terms "first," "second," etc., in the specification, claims, and drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence.

[0028] The methods and embodiments provided in this disclosure can be executed on a computer terminal or similar computing device. Taking running on a computer terminal as an example, Figure 1 The diagram schematically illustrates a hardware structure block diagram of a computer terminal for a consensus node determination method according to an embodiment of this disclosure. Figure 1 As shown, a computer terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 (which may include, but is not limited to, a microprocessor unit (MPU) or a programmable logic device (PLD)) and a memory 104 for storing data are also included. Optionally, the computer terminal may further include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the computer terminal described above. For example, the computer terminal may also include components that are more complex than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 Equivalent functions or ratios shown Figure 1 The functions shown have more different configurations.

[0029] The memory 104 can be used to store computer programs, for example, software programs of application software and modules, such as a computer program corresponding to the method for determining a consensus node in the embodiments of the present disclosure. The processor 102 can execute various functional applications and data processing, that is, implement the above method, by running the computer program stored in the memory 104. The memory 104 can include a high-speed random access memory, and can also include a non-volatile memory, such as one or more magnetic storage devices, flash memories, or other non-volatile solid-state memories. In some examples, the memory 104 can further include a memory remotely arranged with respect to the processor 102, and the remote memory can be connected to the computer terminal through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0030] The transmission device 106 is used to receive or send data via a network. The specific examples of the above network can include a wireless network provided by a communication provider of the computer terminal. In one example, the transmission device 106 includes a network adapter (NIC), which can be connected to other network devices through a base station so as to communicate with the Internet. In one example, the transmission device 106 can be a radio frequency (RF) module, which is used to communicate with the Internet in a wireless manner.

[0031] In the embodiments of the present disclosure, a method for determining a consensus node is provided, Figure 2 A flowchart of the method for determining a consensus node in the embodiments of the present disclosure is schematically shown, as shown in Figure 2 The flowchart includes the following steps:

[0032] In step S202, multi-round election information is obtained from a consensus node contract center, wherein the multi-round election information includes a number of consensus nodes to be elected.

[0033] In step S204, consensus nodes of a current election round are elected according to the multi-round election information, and the multi-round election information is updated according to the consensus nodes elected in the current election round.

[0034] In step S206, the consensus nodes of a next election round of the current election round are elected according to the multi-round election information updated in the current election round.

[0035] In step S208, in a case where the number of all the consensus nodes elected in all the election rounds is equal to the number of the consensus nodes to be elected, all the consensus nodes elected in all the election rounds are determined as final consensus nodes.

[0036] It should be noted that all election rounds are the current election round and the election round before the current election round. If the number of all the consensus nodes elected in all the election rounds is equal to the number of the to-be-elected consensus nodes after the consensus nodes are elected in the current election round, all the consensus nodes elected in all the election rounds are determined as the final consensus nodes. If the number of all the consensus nodes elected in all the election rounds is not equal to the number of the to-be-elected consensus nodes, the consensus nodes of the next election round of the current election round are elected according to the multi-round election information updated in the current election round.

[0037] According to the present disclosure, the multi-round election information is obtained from the consensus node contract center, wherein the multi-round election information includes the number of to-be-elected consensus nodes; the consensus nodes of the current election round are elected according to the multi-round election information, and the multi-round election information is updated according to the consensus nodes elected in the current election round; the consensus nodes of the next election round of the current election round are elected according to the multi-round election information updated in the current election round; and in the case that the number of all the consensus nodes elected in all the election rounds is equal to the number of the to-be-elected consensus nodes, all the consensus nodes elected in all the election rounds are determined as the final consensus nodes. By using the above technical means, the problem that the existing consensus algorithm needs to rely on regional chain tokens to determine consensus nodes in the prior art is solved, thereby providing a method for determining consensus nodes without relying on regional chain tokens.

[0038] The regional chain token in the background art refers to a block chain native regional chain token or an embedded regional chain token. The native regional chain token refers to a bookkeeping unit attached to a block chain system and generated and used in the system.

[0039] Figure 3 A flowchart of a method for determining consensus nodes of a current election round according to an embodiment of the present disclosure is schematically shown as follows, Figure 3 The flowchart includes the following steps:

[0040] Step S302, obtaining a consensus node blacklist and / or a consensus node whitelist from the consensus node contract center;

[0041] Step S304, performing a screening operation on a candidate consensus node list according to the consensus node blacklist and / or the consensus node whitelist, wherein the multi-round election information includes the candidate consensus node list;

[0042] Step S306, electing the consensus nodes of the current election round according to the candidate consensus node list after the screening operation.

[0043] The consensus node contract center is added in the embodiment of the disclosure, which saves multi-round election information updated in each election round, and records credit conditions of each node through a consensus node blacklist and / or a consensus node whitelist. If a node sends error information for multiple times, other nodes receiving the error information will feed back information indicating that they receive error information from the target node to the consensus node contract center. The consensus node contract center will analyze the feedback information of other nodes to obtain the credit condition of the target node, and decide whether to put the target node into the consensus node blacklist or the consensus node whitelist according to the credit condition.

[0044] Before the consensus nodes of the current election round are elected according to the candidate consensus node list after the screening operation, the method further includes: querying node states of candidate consensus nodes in the candidate consensus node list; and deleting a candidate consensus node that exits from the candidate consensus node list in a case where the node state indicates that the candidate consensus node exits.

[0045] If a candidate consensus node exits, the candidate consensus node that exits needs to be deleted from the candidate consensus node list. Optionally, if a node that has been determined as a consensus node exits, the consensus node that exits is deleted, wherein the deletion is successful only by the consent of other nodes on the network.

[0046] Optionally, if there is a candidate consensus node that newly participates in an election round, the candidate consensus node that newly participates does not participate in the election process of the current election round, and participates in the election of the next election round after the election of the current election round ends.

[0047] Before the candidate consensus node list is screened according to the consensus node blacklist and / or the consensus node whitelist, the method further includes: in a case where the candidate consensus node list is an empty list, updating the candidate consensus node list according to candidate consensus nodes in the multi-round election information; and calculating the number of consensus nodes to be elected according to the updated candidate consensus node list.

[0048] If the candidate consensus node list is an empty list, it indicates that the last election round may end abnormally, and the empty list cannot be normally used. The candidate consensus node list is updated according to candidate consensus nodes in the multi-round election information, and the updating process can be understood as an initialization operation on the candidate consensus node list. If the candidate consensus node list is incorrect, the number of consensus nodes to be elected may also be incorrect, and the number of consensus nodes to be elected needs to be calculated according to the updated candidate consensus node list. The method for calculating the number of consensus nodes to be elected is consistent with a consensus node algorithm in the prior art.

[0049] In step S204, the consensus nodes of the current election round are elected according to the candidate consensus node list after the screening operation, including: in the case that the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of consensus nodes to be elected, all candidate consensus nodes in the candidate consensus node list are elected as the consensus nodes of the current election round; in the case that the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, the candidate consensus nodes in the candidate consensus node list are randomly elected according to an election period, and the randomly elected candidate consensus nodes are determined as the consensus nodes of the current election round, wherein the multi-round election information includes the election period.

[0050] In the case that the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of consensus nodes to be elected, all candidate consensus nodes in the candidate consensus node list are elected as the consensus nodes of the current election round; in the case that the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, the candidate consensus nodes in the candidate consensus node list are randomly elected according to an election period, and the randomly elected candidate consensus nodes are determined as the consensus nodes of the current election round. Wherein, the election is performed every n blocks (election period), the number of consensus nodes elected each time is denoted as N, N >= 3f + 1, f is the number of faulty nodes, and f is a natural number.

[0051] Figure 4 A flowchart of a method for determining the consensus nodes of the current election round by random election according to an embodiment of the present disclosure is schematically shown in FIG. 4, which includes the following steps: Figure 4 As shown in FIG. 4, the flowchart includes the following steps:

[0052] In step S402, the candidate consensus nodes that have been randomly elected are removed from the candidate consensus node list to obtain a first candidate consensus node list;

[0053] In step S404, the number of consensus nodes to be elected is updated according to the first candidate consensus node list;

[0054] In step S406, the candidate consensus nodes in the first candidate consensus node list are randomly elected according to the election period, wherein the number of elected candidate consensus nodes is equal to the number of consensus nodes to be elected after the update;

[0055] In step S408, the consensus nodes of the current election round are updated according to the randomly elected candidate consensus nodes.

[0056] It should be noted that in the embodiment, the updated to-be-elected consensus node quantity can be the original to-be-elected consensus node quantity minus the candidate consensus nodes randomly elected. Updating the consensus nodes of the current election round according to the candidate consensus nodes randomly elected can be understood as combining the consensus nodes obtained by two times of random election together to obtain the consensus nodes of the current election round.

[0057] In the last election period of the current election round, if the number of to-be-elected consensus nodes is less than the number of consensus nodes to be elected each time in the current round, all nodes are compulsorily elected; and the election of the next round is started. The number of consensus nodes at the junction is calculated according to the number of consensus nodes elected in the last round, so as to avoid the following situation: for example, 64 consensus nodes need to be elected in the n th round, and 32 consensus nodes need to be elected in the n+1 th round. In the last election period of the n th round, the remaining nodes are 63. If the election is performed according to the 32 consensus nodes of the n+1 th round, the n th round cannot be completed.

[0058] In step S208, in a case where the number of all the consensus nodes elected in all the election rounds is equal to the to-be-elected consensus node quantity, after all the consensus nodes elected in all the election rounds are determined as final consensus nodes, the method further includes: sending, by the final consensus nodes, block information to other nodes in a full-network broadcast manner; receiving, by the consensus node contract center, feedback information of the other nodes on the block information, and updating a consensus node blacklist and / or a consensus node whitelist according to the feedback information.

[0059] The embodiments of the present disclosure can also solve the problem of poor scalability of existing consensus algorithms. In the embodiments of the present disclosure, after being determined as final consensus nodes, the determined final consensus nodes can be subjected to a block information verification operation, and finally the consensus node contract center aggregates result information (that is, the feedback information) of the block information verification operation, updates a consensus node blacklist and / or a consensus node whitelist according to the result information, and performs a dynamic expansion operation on the final consensus nodes according to the updated consensus node blacklist and / or consensus node whitelist.

[0060] Optionally, the feedback information sent by the other nodes is received by the consensus node contract center, and the feedback information includes information that the final consensus nodes do not generate blocks or generate few blocks within a preset time period and fed back to the consensus nodes.

[0061] It should be noted that the consensus node blacklist and / or the consensus node whitelist can also be updated according to the information that the final consensus nodes do not generate blocks or generate few blocks.

[0062] In an optional embodiment, when the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: a first number of nodes with the highest priority in the consensus node whitelist are subjected to block information verification operation; and a second number of nodes are elected from the first number of nodes as the final consensus nodes according to the result information of the block information verification operation, wherein the first number is greater than the second number.

[0063] The block information verification operation comprises: sending the block information by the target node to other nodes in a full-network broadcast manner; receiving, by the consensus node contract center, result information of the block information from the other nodes, and updating the consensus node blacklist and / or the consensus node whitelist according to the result information. The nodes with poor credit in the result information are prohibited from participating in the election of the consensus nodes, and the priority of the nodes with good credit in the result information is increased in the election of the consensus nodes.

[0064] Optionally, the consensus node whitelist in the embodiment of the present disclosure is different from the traditional whitelist, and the consensus node whitelist can record the priority of different network nodes and / or the weight value of different network nodes.

[0065] Optionally, when the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: a second number of the final consensus nodes are elected from the consensus node whitelist according to the priority of the plurality of network nodes.

[0066] Optionally, when the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: the weight value is subjected to normalization operation, and a second number of the final consensus nodes are elected from the consensus node whitelist according to the weight value after the normalization operation.

[0067] From the above description of the embodiments, those skilled in the art can clearly understand that the method according to the above embodiments can be realized by means of software and a general hardware platform as required, and of course, can also be realized by hardware, but in many cases, the former is a better embodiment. Based on such understanding, the technical solutions of the present disclosure can be embodied in the form of a software product, which is stored in a storage medium (such as a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk), and includes a plurality of instructions for causing a terminal device (which can be a mobile phone, a computer, a server, or a network device) to execute the methods of the various embodiments of the present disclosure.

[0068] A consensus node determination apparatus is also provided in the embodiment, which is used to implement the above-mentioned embodiments and preferred embodiments, and details are not repeated. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, implementation of hardware, or a combination of software and hardware, is also possible and contemplated.

[0069] Figure 5 A structural block diagram of a consensus node determination apparatus of an optional embodiment of the disclosure is schematically shown, as shown in Figure 5 The apparatus includes:

[0070] The acquisition module 502 is configured to acquire multi-round election information from a consensus node contract center, wherein the multi-round election information includes a number of consensus nodes to be elected.

[0071] The first election module 504 is configured to elect consensus nodes of a current election round according to the multi-round election information, and update the multi-round election information according to the consensus nodes elected in the current election round.

[0072] The second election module 506 is configured to elect consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round.

[0073] The determination module 508 is configured to determine all the consensus nodes elected in all the election rounds as final consensus nodes in a case where a number of all the consensus nodes elected in all the election rounds is equal to the number of consensus nodes to be elected.

[0074] It should be noted that all the election rounds are the current election round and the election rounds before the current election round. If the number of all the consensus nodes is equal to the number of consensus nodes to be elected in the current election round and the election rounds before the current election round after the consensus nodes are elected in the current election round, all the consensus nodes elected in all the election rounds are determined as final consensus nodes. If the number is not equal to the number of consensus nodes to be elected, the consensus nodes of the next election round of the current election round are elected according to the multi-round election information updated in the current election round.

[0075] According to the disclosure, multi-round election information is obtained from a consensus node contract center, the multi-round election information including a number of consensus nodes to be elected; a consensus node of a current election round is elected according to the multi-round election information, and the multi-round election information is updated according to the consensus node elected in the current election round; the consensus node of a next election round of the current election round is elected according to the multi-round election information updated in the current election round; and in a case where a number of all the consensus nodes elected in all the election rounds is equal to the number of the consensus nodes to be elected, all the consensus nodes elected in all the election rounds are determined as final consensus nodes. By using the above technical means, the problem that the existing consensus algorithm needs to rely on regional chain tokens to determine consensus nodes in the prior art is solved, thereby providing a method for determining consensus nodes without relying on regional chain tokens.

[0076] The regional chain token in the background art refers to a block chain native regional chain token or an embedded regional chain token. The native regional chain token refers to a bookkeeping unit attached to a block chain system and generated and used in the system.

[0077] Optionally, the first election module 504 is further configured to obtain a consensus node blacklist and / or a consensus node whitelist from the consensus node contract center; perform a screening operation on a candidate consensus node list according to the consensus node blacklist and / or the consensus node whitelist, wherein the multi-round election information includes the candidate consensus node list; and elect the consensus node of the current election round according to the candidate consensus node list after the screening operation.

[0078] The consensus node contract center of the embodiments of the disclosure stores the multi-round election information updated in each election round, and records the credit status of each node through the consensus node blacklist and / or the consensus node whitelist. If a node sends error information multiple times, other nodes receiving the error information will feed back information indicating that they receive the information of the target node to the consensus node contract center. The consensus node contract center will analyze the feedback information of other nodes to obtain the credit status of the target node, and decide whether to put the target node into the consensus node blacklist or the consensus node whitelist according to the credit status.

[0079] Optionally, the first election module 504 is further configured to query a node state of a candidate consensus node in the candidate consensus node list; and delete the candidate consensus node that exits from the candidate consensus node list in a case where the node state indicates that the candidate consensus node exits.

[0080] If a candidate consensus node exits, the exited candidate consensus node needs to be deleted from the candidate consensus node list. Optionally, if a node that has been determined as a consensus node exits, the exited consensus node is deleted, wherein the deletion is successful only with the consent of other nodes on the network.

[0081] Optionally, if a new candidate consensus node participates in an election round, the new candidate consensus node does not participate in the election process of the election round; after the election round ends, the new candidate consensus node participates in the election of the next election round.

[0082] Optionally, the first election module 504 is further configured to update the candidate consensus node list according to candidate consensus nodes in the multi-round election information when the candidate consensus node list is an empty list; and calculate the number of consensus nodes to be elected according to the updated candidate consensus node list.

[0083] If the candidate consensus node list is an empty list, it indicates that the last election round may not have ended normally, and the empty list cannot be used normally. The candidate consensus node list is updated according to candidate consensus nodes in the multi-round election information. This update process can be understood as an initialization operation on the candidate consensus node list. If the candidate consensus node list is incorrect, the number of consensus nodes to be elected may also be incorrect. The number of consensus nodes to be elected is calculated according to the updated candidate consensus node list. The method of calculating the number of consensus nodes to be elected is consistent with the consensus node algorithm in the prior art.

[0084] Optionally, the first election module 504 is further configured to elect all candidate consensus nodes in the candidate consensus node list as the consensus nodes of the current election round when the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of consensus nodes to be elected; and randomly elect candidate consensus nodes in the candidate consensus node list according to an election period when the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, and determine the randomly elected candidate consensus nodes as the consensus nodes of the current election round, wherein the multi-round election information includes the election period.

[0085] If the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of consensus nodes to be elected, all candidate consensus nodes in the candidate consensus node list are elected as the consensus nodes of the current election round; if the number of candidate consensus nodes in the candidate consensus node list is greater than the number of consensus nodes to be elected, the candidate consensus nodes in the candidate consensus node list are randomly elected according to an election period, and the randomly elected candidate consensus nodes are determined as the consensus nodes of the current election round. Wherein, the election is performed every n blocks (election period), the number of consensus nodes elected each time is denoted as N, N >= 3f + 1, f is the number of faulty nodes, and f is a natural number.

[0086] Optionally, the first election module 504 is further configured to remove the candidate consensus nodes that have been randomly elected from the candidate consensus node list to obtain a first candidate consensus node list; update the number of consensus nodes to be elected according to the first candidate consensus node list; randomly elect the candidate consensus nodes in the first candidate consensus node list according to the election period, wherein the number of elected candidate consensus nodes is equal to the number of consensus nodes to be elected after the update; and update the consensus nodes of the current election round according to the randomly elected candidate consensus nodes.

[0087] It should be noted that in this embodiment, the number of consensus nodes to be elected after the update can be the number of consensus nodes to be elected originally minus the candidate consensus nodes that have been randomly elected. Updating the consensus nodes of the current election round according to the randomly elected candidate consensus nodes can be understood as combining the consensus nodes obtained by two times of random election together to obtain the consensus nodes of the current election round.

[0088] In the last election period of the current election round, if the number of consensus nodes to be elected is less than the number of consensus nodes elected each time in the current round, all nodes are elected; and the election of the next round is started. The number of consensus nodes at the junction is calculated according to the number of consensus nodes elected in the last round, so as to avoid the following situation: for example, 64 consensus nodes need to be elected in the nth round, and 32 consensus nodes need to be elected in the (n+1)th round, in the last election period of the nth round, the remaining nodes are 63, if the election is performed according to the 32 consensus nodes of the (n+1)th round, the nth round cannot be completed.

[0089] Optionally, the determination module 508 is further configured to send block information to other nodes in a full-network broadcast manner through the final consensus node; receive feedback information of the other nodes on the block information through the consensus node contract center, and update a consensus node blacklist and / or a consensus node whitelist according to the feedback information.

[0090] The embodiments of the present disclosure can also solve the problem of poor scalability of existing consensus algorithms. In the embodiments of the present disclosure, after being determined as the final consensus nodes, the determined final consensus nodes can be subjected to block information verification operations, and finally the results information (that is, the feedback information) of the block information verification operations is aggregated by the consensus node contract center, the consensus node blacklist and / or the consensus node whitelist are updated according to the results information, and the dynamic expansion operation is performed on the final consensus nodes according to the updated consensus node blacklist and / or the consensus node whitelist.

[0091] Optionally, the feedback information sent by the other nodes is received by the consensus node contract center, wherein the feedback information includes information that the final consensus nodes fed back by the other nodes do not produce blocks or produce few blocks within a preset time period.

[0092] It should be noted that the consensus node blacklist and / or the consensus node whitelist can also be updated according to the information that the final consensus nodes do not produce blocks or produce few blocks.

[0093] Optionally, the determination module 508 is further configured to, in a case where the number of the final consensus nodes is less than a preset number, perform a dynamic expansion operation: performing block information verification operations on a first number of nodes with the highest priority in the consensus node whitelist; and determining a second number of nodes elected from the first number of nodes as the final consensus nodes according to results information of the block information verification operations, wherein the first number is greater than the second number.

[0094] The block information verification operation includes: sending the block information to other nodes in a full-network broadcast manner by a target node; receiving, by the consensus node contract center, results information of the block information from the other nodes, and updating the consensus node blacklist and / or the consensus node whitelist according to the results information. The nodes with poor credit in the results information in the consensus node blacklist are prohibited from participating in the election of the consensus nodes, and the priority of the nodes with good credit in the results information in the consensus node whitelist is increased in the election of the consensus nodes.

[0095] Optionally, the consensus node whitelist in the embodiments of the present disclosure is different from the traditional whitelist, and the consensus node whitelist can record the priority of different network nodes and / or the weight value of different network nodes.

[0096] Optionally, in a case where the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: a second number of the final consensus nodes are elected from the consensus node whitelist according to the priority of a plurality of network nodes.

[0097] Optionally, in a case where the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: the weight values are normalized, and a second number of the final consensus nodes are elected from the consensus node whitelist according to the weight values after the normalization operation.

[0098] It should be noted that the above various modules can be implemented by software or hardware, and for the latter, the following implementation manners can be used, but are not limited thereto: the above modules are located in the same processor; or the above various modules are located in different processors in any combination.

[0099] Embodiments of the present disclosure provide an electronic device.

[0100] Figure 6 An example of a structural block diagram of an electronic device provided by embodiments of the present disclosure is shown.

[0101] Referring to Figure 6 The electronic device 600 provided by the embodiments of the present disclosure includes a processor 601, a communication interface 602, a memory 603 and a communication bus 604, wherein the processor 601, the communication interface 602 and the memory 603 complete mutual communication through the communication bus 604; the memory 603 is used to store a computer program; the processor 601 is used to execute the program stored on the memory to implement the steps in any of the above method embodiments.

[0102] Optionally, the electronic device can further include a transmission device and an input / output device, wherein the input / output device is connected to the processor.

[0103] Optionally, in the present embodiment, the processor can be configured to execute the following steps through the computer program:

[0104] S1, obtaining multi-round election information from a consensus node contract center, wherein the multi-round election information includes a number of consensus nodes to be elected;

[0105] S2, electing consensus nodes of a current election round according to the multi-round election information, and updating the multi-round election information according to the consensus nodes elected in the current election round;

[0106] S3, electing consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round;

[0107] S4, in a case where the number of all the consensus nodes elected in all the election rounds is equal to the number of the consensus nodes to be elected, determining all the consensus nodes elected in all the election rounds as final consensus nodes.

[0108] The embodiments of the present disclosure further provide a computer readable storage medium. The computer readable storage medium stores a computer program, and the computer program is executed by a processor to implement the steps in any of the method embodiments.

[0109] Optionally, in the embodiment, the storage medium can be configured to store a computer program for executing the following steps:

[0110] S1, obtaining multi-round election information from a consensus node contract center, wherein the multi-round election information comprises a number of to-be-elected consensus nodes;

[0111] S2, electing consensus nodes in a current election round according to the multi-round election information, and updating the multi-round election information according to the consensus nodes elected in the current election round;

[0112] S3, electing consensus nodes in a next election round of the current election round according to the multi-round election information updated in the current election round;

[0113] S4, in a case where a number of all the consensus nodes elected in all the election rounds is equal to the number of to-be-elected consensus nodes, determining all the consensus nodes elected in all the election rounds as final consensus nodes.

[0114] The computer readable storage medium can be included in the device / apparatus described in the above embodiments; or can exist separately without being assembled into the device / apparatus. The computer readable storage medium carries one or more programs, and when the one or more programs are executed, the method according to the embodiments of the present disclosure is implemented.

[0115] According to the embodiments of the present disclosure, the computer readable storage medium can be a non-volatile computer readable storage medium, which can include but is not limited to: a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any appropriate combination thereof. In the present disclosure, the computer readable storage medium can be any tangible medium that contains or stores a program, which can be used by or in connection with an instruction execution system, apparatus or device.

[0116] Optionally, specific examples in the embodiments can refer to the examples described in the above embodiments and optional implementation manners, and the embodiments will not be described here again.

[0117] It is apparent that those skilled in the art should understand that the modules or steps of the present disclosure described above can be realized by general computing devices, which can be centralized on a single computing device or distributed on a network composed of multiple computing devices, and optionally, they can be realized by program codes executable by computing devices, so that they can be stored in storage devices and executed by computing devices, and in some cases, the steps shown or described can be executed in different order, or they can be respectively manufactured into individual integrated circuit modules, or multiple modules or steps among them can be manufactured into a single integrated circuit module. Thus, the present disclosure is not limited to any particular combination of hardware and software.

[0118] The preferred embodiments of the present disclosure are described above, but the present disclosure is not limited to the above. Those skilled in the art can make various modifications and changes to the present disclosure. Any modification, equivalent replacement, improvement, etc. within the principles of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A method for determining consensus nodes, characterized in that, The method comprises the following steps: obtaining multi-round election information from a consensus node contract center, wherein the multi-round election information comprises a number of consensus nodes to be elected; electing consensus nodes of a current election round according to the multi-round election information, and updating the multi-round election information according to the consensus nodes elected in the current election round; electing consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round; in a case where the number of all the consensus nodes elected in all the election rounds is equal to the number of the consensus nodes to be elected, determining all the consensus nodes elected in all the election rounds as final consensus nodes; in a case where the number of the final consensus nodes is less than a preset number, performing a dynamic expansion operation: performing block information verification operation on a first number of nodes with the highest priority in a consensus node whitelist; and according to result information of the block information verification operation, electing a second number of nodes from the first number of nodes to determine the second number of nodes as the final consensus nodes, wherein the first number is greater than the second number; the block information verification operation comprises: sending block information to other nodes in a full-network broadcast manner by a target node; receiving, by the consensus node contract center, result information of the other nodes on the block information, updating a consensus node blacklist and / or a consensus node whitelist according to the result information, and prohibiting the nodes with poor credit in the consensus node blacklist from participating in the election of the consensus nodes, and increasing the priority of the nodes with good credit in the consensus node whitelist in the election of the consensus nodes.

2. The method of claim 1, wherein, The method further comprises the following steps before the election of the consensus nodes of the current election round according to the candidate consensus node list after the screening operation: querying a node state of a candidate consensus node in the candidate consensus node list; in a case where the node state indicates that the candidate consensus node exits, deleting the exited candidate consensus node from the candidate consensus node list. The method further comprises the following steps before the screening operation of the candidate consensus node list according to the consensus node blacklist and / or the consensus node whitelist:

3. The method of claim 2, wherein, in a case where the candidate consensus node list is an empty list, updating the candidate consensus node list according to candidate consensus nodes in the multi-round election information; calculating the number of the consensus nodes to be elected according to the updated candidate consensus node list. The election of the consensus nodes of the current election round according to the candidate consensus node list after the screening operation comprises the following steps:

4. The method of claim 2, wherein, ​ ​ ​ 5. The method of claim 2, wherein, ​ In a case where the number of candidate consensus nodes in the candidate consensus node list is not greater than the number of to-be-elected consensus nodes, all candidate consensus nodes in the candidate consensus node list are elected as the consensus nodes of the current election round; In a case where the number of candidate consensus nodes in the candidate consensus node list is greater than the number of to-be-elected consensus nodes, the candidate consensus nodes in the candidate consensus node list are randomly elected according to an election cycle, and the randomly elected candidate consensus nodes are determined as the consensus nodes of the current election round, wherein the multi-round election information includes the election cycle.

6. The method of claim 5, wherein, After the candidate consensus nodes in the candidate consensus node list are randomly elected according to the election cycle in a case where the number of candidate consensus nodes in the candidate consensus node list is greater than the number of to-be-elected consensus nodes, and the randomly elected candidate consensus nodes are determined as the consensus nodes of the current election round, the method further includes: removing the randomly elected candidate consensus nodes from the candidate consensus node list to obtain a first candidate consensus node list; updating the number of to-be-elected consensus nodes according to the first candidate consensus node list; randomly electing the candidate consensus nodes in the first candidate consensus node list according to the election cycle, wherein the number of elected candidate consensus nodes is equal to the number of to-be-elected consensus nodes after the update; updating the consensus nodes of the current election round according to the randomly elected candidate consensus nodes.

7. The method of claim 1, wherein, After all the consensus nodes elected in all the election rounds are determined as final consensus nodes in a case where the number of all the consensus nodes elected in all the election rounds is equal to the number of to-be-elected consensus nodes, the method further includes: sending block information to other nodes in a full-network broadcast manner by the final consensus nodes; receiving feedback information of the block information from the other nodes by the consensus node contract center, and updating a consensus node blacklist and / or a consensus node whitelist according to the feedback information.

8. A consensus node determination device, characterized in that, comprise: an acquisition module, configured to acquire multi-round election information from a consensus node contract center, wherein the multi-round election information includes a number of to-be-elected consensus nodes; a first election module, configured to elect consensus nodes of a current election round according to the multi-round election information, and update the multi-round election information according to the consensus nodes elected in the current election round; a second election module, configured to elect the consensus nodes of a next election round of the current election round according to the multi-round election information updated in the current election round; a determination module, configured to determine all the consensus nodes elected in all the election rounds as final consensus nodes in a case where the number of all the consensus nodes elected in all the election rounds is equal to the number of to-be-elected consensus nodes; In a case where the number of the final consensus nodes is less than a preset number, a dynamic expansion operation is performed: performing block information verification operation on a first number of nodes with the highest priority in the consensus node whitelist; and determining a second number of nodes elected from the first number of nodes as the final consensus nodes according to result information of the block information verification operation, wherein the first number is greater than the second number; The block information verification operation comprises: sending the block information to other nodes in a full-network broadcast manner by a target node; receiving, by the consensus node contract center, result information of the other nodes on the block information, updating a consensus node blacklist and / or a consensus node whitelist according to the result information, prohibiting the nodes with poor credit in the result information in the consensus node blacklist from participating in the election of the consensus nodes, and increasing the priority of the nodes with good credit in the result information in the consensus node whitelist in the election of the consensus nodes.

9. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the method in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Federation chain consensus method and computer storage medium

    CN109660545A

  • Consensus method and system for block chain and Internet of Things fusion scene

    CN112163856A