CN111447274B - Node selection method and device - Google Patents

Node selection method and device Download PDF

Info

Publication number
CN111447274B
CN111447274B CN202010224718.4A CN202010224718A CN111447274B CN 111447274 B CN111447274 B CN 111447274B CN 202010224718 A CN202010224718 A CN 202010224718A CN 111447274 B CN111447274 B CN 111447274B
Authority
CN
China
Prior art keywords
node
information
nodes
received
preset number
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202010224718.4A
Other languages
Chinese (zh)
Other versions
CN111447274A (en
Inventor
杨文锋
者文明
刘瑞飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Zhenshi Information Technology Co Ltd
Original Assignee
Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Zhenshi Information Technology Co Ltd filed Critical Beijing Jingdong Zhenshi Information Technology Co Ltd
Priority to CN202010224718.4A priority Critical patent/CN111447274B/en
Publication of CN111447274A publication Critical patent/CN111447274A/en
Application granted granted Critical
Publication of CN111447274B publication Critical patent/CN111447274B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1095Replication or mirroring of data, e.g. scheduling or transport for data synchronisation between network nodes
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L67/00Network arrangements or protocols for supporting network services or applications
    • H04L67/01Protocols
    • H04L67/10Protocols in which an application is distributed across nodes in the network
    • H04L67/1097Protocols in which an application is distributed across nodes in the network for distributed storage of data in networks, e.g. transport arrangements for network file system [NFS], storage area networks [SAN] or network attached storage [NAS]
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L9/00Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols
    • H04L9/50Cryptographic mechanisms or cryptographic arrangements for secret or secure communications; Network security protocols using hash chains, e.g. blockchains or hash trees

Landscapes

  • Engineering & Computer Science (AREA)
  • Computer Networks & Wireless Communication (AREA)
  • Signal Processing (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The embodiment of the application provides a node selection method and a node selection device, wherein the method is applied to a block chain system, a first information set corresponding to each node in M nodes is obtained, M first information sets are obtained, node information of a plurality of nodes is included in the first information sets corresponding to each node, and M is an integer larger than 1; and when the number of the node information included in each first information set is greater than or equal to the preset number, determining a consensus node in the blockchain system according to the hash value of the preset number of the node information in each first information set. The scheme of the embodiment of the application does not need to exhaust the node information of each node, and the consumption of computing resources is small.

Description

Node selection method and device
Technical Field
The embodiment of the application relates to the technical field of blockchain, in particular to a node selection method and device.
Background
Blockchains are novel application modes of computer technologies such as distributed data storage, point-to-point transmission, consensus mechanisms, encryption algorithms, and the like. In blockchain technology, common nodes and common nodes are included. In general, the more consensus nodes involved, the lower the efficiency of the consensus, the fewer the consensus nodes, and the higher the efficiency, and in order to ensure the efficiency, the consensus nodes need to be selected from a plurality of nodes.
Currently, the method Of electing consensus nodes is mainly through a Proof Of Work (POW) method. The POW method makes hash values satisfying the conditions by exhausting all random numbers. Although the POW method achieves randomness and fairness of the consensus node, the consumption of computing resources is large.
Disclosure of Invention
The embodiment of the application provides a node selection method and a node selection device, which are used for solving the problem that the consumption of computing resources is large by selecting consensus nodes through a POW method.
In a first aspect, an embodiment of the present application provides a node selection method, applied to a blockchain system, the method including:
acquiring a first information set corresponding to each node in M nodes to obtain M first information sets, wherein the first information set corresponding to each node comprises node information of a plurality of nodes, and M is an integer greater than 1;
and when the number of the node information included in each first information set is greater than or equal to the preset number, determining a consensus node in the blockchain system according to the hash value of the preset number of the node information in each first information set.
In one possible implementation manner, the obtaining the first information set corresponding to each node in the M nodes, to obtain M first information sets, includes:
Acquiring node information of other nodes received by each node in the M nodes;
and obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
In one possible implementation manner, the obtaining, according to the node information of each node and the received node information of other nodes, the first information set corresponding to each node in the M nodes includes:
aiming at any node i in the M nodes, acquiring node information of other nodes received by the node i;
and ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
In one possible implementation, for any node i, the node information of the node i includes address information and random information of the node i.
In a possible implementation manner, the sorting the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i includes:
and ordering the node information of the node i and the node information of other nodes received by the node i according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
In one possible implementation manner, when the number of node information included in each first information set is greater than or equal to a preset number, determining a consensus node in the blockchain system according to a hash value of a previous preset number of node information in each first information set includes:
carrying out hash operation on the first preset number of node information in the first information set corresponding to each node to obtain hash values of the first preset number of node information in the first information set corresponding to each node;
for any node i, acquiring hash values of a preset number of node information in a corresponding first information set broadcast by other nodes received by the node i;
and determining a consensus node in the block chain system according to the hash value of the preset number of node information in the corresponding first information set broadcast by other nodes received by each node.
In one possible implementation manner, the determining, in the blockchain system, a consensus node according to the hash value of the first preset number of node information in the corresponding first information set broadcasted by other nodes received by each node includes:
Determining a plurality of first nodes in the M nodes according to hash values of the preset number of node information in the corresponding first information sets broadcast by other nodes received by each node, wherein the hash values of the preset number of node information in the corresponding first information sets broadcast by the plurality of first nodes are the same;
among the plurality of first nodes, the consensus node is determined.
In one possible implementation, the preset number is 2f+1, where the blockchain system includes N total nodes, f is the number of failed nodes in the N nodes, M < = N.
In one possible implementation, the number of the plurality of first nodes is greater than or equal to f+1, and the number of the consensus nodes is less than f+1.
In a second aspect, an embodiment of the present application provides a node selection apparatus, including:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring first information sets corresponding to each node in M nodes in a blockchain system to obtain M first information sets, the first information sets corresponding to each node comprise node information of a plurality of nodes, and M is an integer larger than 1;
and the processing module is used for determining the consensus node in the blockchain system according to the hash value of the preset number of node information in each first information set when the number of the node information included in each first information set is larger than or equal to the preset number.
In one possible implementation manner, the acquiring module is specifically configured to:
acquiring node information of other nodes received by each node in the M nodes;
and obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
In one possible implementation manner, the acquiring module is specifically configured to:
aiming at any node i in the M nodes, acquiring node information of other nodes received by the node i;
and ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
In one possible implementation, for any node i, the node information of the node i includes address information and random information of the node i.
In one possible implementation manner, the acquiring module is specifically configured to:
and ordering the node information of the node i and the node information of other nodes received by the node i according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
In one possible implementation manner, the processing module is specifically configured to:
carrying out hash operation on the first preset number of node information in the first information set corresponding to each node to obtain hash values of the first preset number of node information in the first information set corresponding to each node;
for any node i, acquiring hash values of a preset number of node information in a corresponding first information set broadcast by other nodes received by the node i;
and determining a consensus node in the block chain system according to the hash value of the preset number of node information in the corresponding first information set broadcast by other nodes received by each node.
In one possible implementation manner, the processing module is specifically configured to:
determining a plurality of first nodes in the M nodes according to hash values of the preset number of node information in the corresponding first information sets broadcast by other nodes received by each node, wherein the hash values of the preset number of node information in the corresponding first information sets broadcast by the plurality of first nodes are the same;
among the plurality of first nodes, the consensus node is determined.
In one possible implementation, the preset number is 2f+1, where the blockchain system includes N total nodes, f is the number of failed nodes in the N nodes, M < = N.
In one possible implementation, the number of the plurality of first nodes is greater than or equal to f+1, and the number of the consensus nodes is less than f+1.
In a third aspect, an embodiment of the present application provides a node selection device, including: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing computer-executable instructions stored in the memory causes the at least one processor to perform the node selection method of any of the first aspects.
In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, where computer-executable instructions are stored, and when executed by a processor, implement a node selection method according to any one of the first aspects.
The node selection method and the device are applied to a block chain system, first, a first information set corresponding to each node in M nodes is obtained, M first information sets are obtained, the first information set corresponding to each node comprises node information of the nodes, and M is an integer larger than 1; then, when the number of node information included in each first information set is greater than or equal to a preset number, a consensus node is determined in the blockchain system according to the hash value of the previous preset number of node information in each first information set. According to the scheme provided by the embodiment of the application, node information broadcast by other nodes is received by each node, then the common node is obtained according to the hash value of the preset number of node information in each first information set, the node information of each node is not required to be exhausted, and the consumption of computing resources is small.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, a brief description will be given below of the drawings that are needed in the embodiments or the prior art descriptions, it being obvious that the drawings in the following description are some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort to a person skilled in the art.
Fig. 1 is a schematic view of an application scenario provided in an embodiment of the present application;
fig. 2 is a flow chart of a node selection method according to an embodiment of the present application;
fig. 3 is a flow chart of a node selection method according to another embodiment of the present disclosure;
fig. 4 is a schematic diagram of node information provided in an embodiment of the present application;
fig. 5 is a schematic diagram of node information broadcast provided in an embodiment of the present application;
fig. 6 is a schematic diagram of node information ordering provided in an embodiment of the present application;
fig. 7 is a schematic diagram of node broadcasting according to an embodiment of the present application;
fig. 8 is a schematic structural diagram of a node selection device according to an embodiment of the present application;
fig. 9 is a schematic hardware structure of a node selection device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more clear, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments. All other embodiments, which can be made by one of ordinary skill in the art without undue burden from the present disclosure, are within the scope of the present disclosure.
Fig. 1 is a schematic view of an application scenario provided in the embodiment of the present application, as shown in fig. 1, where a blockchain system includes a plurality of nodes, and 8 nodes are illustrated in fig. 1. When a consensus node in the blockchain system is selected, the consensus node can be used to achieve consensus for any transaction or decision.
Alternatively, the nodes in the blockchain system may be computers, servers, or the like.
Optionally, other nodes are also included in the blockchain system. Fig. 1 is presented for ease of understanding only and is not intended to limit the number of nodes in a blockchain system.
There are various schemes for selecting the consensus node, such as a POW method, a POS method, a DPOS method, and the like.
The principle of the POW method is that each node in the blockchain system performs a cryptographic challenge, i.e., each node hashes all data in the blockchain system and obtains a hash value that is less than a given target value. Meanwhile, a Nonce value is also included in the blockchain system, and the correct hash value is found by increasing the Nonce value. When the correct hash value is found, the node broadcasts the hash value to the blockchain system and is then verified by other nodes in the network. In the POW method, if one block needs to be modified, the block needs to be reworked and the workload of all blocks after the block is verified, so that the premise of cheating needs to spend a large amount of computing resources. This mechanism means that the most honest chains in a blockchain system tend to be able to guarantee randomness and fairness of the consensus nodes. At the same time, however, the POW method consumes too much computing resources.
In view of the disadvantage that the POW method consumes too much computing resources, POS and DPOS methods have been proposed. Taking POS method as an example, corresponding shares are distributed according to the amount and time of the digital currency held by the nodes, and the nodes with higher shares have higher speaking rights, so that the influence is larger when the consensus voting is carried out. The POS method consumes less computing resources, but is too centralized. For example, a certain node occupies a larger share, becomes a super node, has a larger influence on the consensus result, and if the nodes are controlled, the whole network is controlled, and fairness and randomness are lost.
In order to solve the above problems, the present application provides a node selection method, which ensures fairness and randomness of consensus node selection on the premise of not consuming larger network resources.
Fig. 2 is a flowchart of a node selection method according to an embodiment of the present application, where the method is applied to a blockchain system, as shown in fig. 2, and the method may include:
s21, acquiring first information sets corresponding to each node in M nodes to obtain M first information sets, wherein the first information sets corresponding to each node comprise node information of a plurality of nodes, and M is an integer larger than 1.
The block chain system comprises N nodes, each node has corresponding node information, the node information of each node is related to the node, and the node information of different nodes is different.
After obtaining the corresponding node information according to each node, each node broadcasts the node information of itself to other nodes, and simultaneously, each node also receives the node information broadcast by other nodes. Since there may be a faulty node among the N nodes in the blockchain system, for example, a network fault exists in some nodes, the faulty node cannot broadcast its own node information to other nodes, and cannot receive the node information of other nodes. Thus, M nodes in the embodiments of the present application are a subset of N nodes of the blockchain system, M being less than or equal to N.
And aiming at any node i in the M nodes, obtaining a first information set corresponding to the node i according to the node information broadcast by other nodes received by the node i and the node information of the node i. Since each of the M nodes broadcasts its own node information, each node receives node information broadcast by the other M-1 nodes under ideal conditions. However, due to the influence of various factors, the time of the node information broadcast by other nodes, which may be received by different nodes, may be different, and the number of the node information of other nodes, which may be received by a certain node, may be different within a certain period.
Each node forms a corresponding first information set according to the plurality of node information, and M first information sets can be obtained.
S22, when the number of the node information included in each first information set is greater than or equal to the preset number, determining a consensus node in the blockchain system according to the hash value of the preset number of the node information in each first information set.
After the first information sets corresponding to each node are obtained, because the number of the node information in each first information set is different, when the number of the node information included in each first information set is greater than or equal to the preset number, hash operation can be performed on the preset number of the node information in each first information set, so that hash values of the preset number of the node information in each first information set are obtained. Each node may then broadcast the resulting hash value to other nodes, or may receive the hash value broadcast by other nodes, thereby forming a consensus.
If the hash values broadcast by multiple nodes to other nodes are the same, the same hash value is a random consensus here, and the broadcast of the same hash value can be used as a consensus node. Then, all or part of the nodes in the plurality of nodes broadcasting the same hash value may be selected as the consensus nodes of the blockchain system.
The node selection method provided by the embodiment of the application is applied to a block chain system, first, a first information set corresponding to each node in M nodes is obtained, M first information sets are obtained, the first information set corresponding to each node comprises node information of a plurality of nodes, and M is an integer larger than 1; then, when the number of node information included in each first information set is greater than or equal to a preset number, a consensus node is determined in the blockchain system according to the hash value of the previous preset number of node information in each first information set. According to the scheme provided by the embodiment of the application, node information broadcast by other nodes is received by each node, then the common node is obtained according to the hash value of the preset number of node information in each first information set, the node information of each node is not required to be exhausted, and the consumption of computing resources is small.
The technical scheme shown in the application is described in detail through specific embodiments. It should be noted that the following embodiments may be combined with each other, and for the same or similar matters, the description will not be repeated in different embodiments.
Fig. 3 is a flowchart of a node selection method according to another embodiment of the present application, where the method is applied to a blockchain system, and as shown in fig. 3, the method may include:
s31, acquiring node information of other nodes received by each node in the M nodes.
The block chain system comprises N nodes, N is greater than or equal to M, and M and N are integers greater than 1. Each node has corresponding node information, and the node information of different nodes is different.
Among the N nodes, each node has corresponding node information, and each node broadcasts own node information to other nodes and also receives node information broadcast by other nodes.
Optionally, in this embodiment of the present application, for any node i, the node information of the node i may include address information and random information of the node i, where the address information of the node i may be, for example, a Mac address of the node i, and Mac addresses of different nodes are different. The random information of the nodes i is obtained randomly according to the nodes i, for example, each node i can generate a random number Rand (Ni), and the number and the size of the random number Rand (Ni) are not limited, for example, the random number Rand (Ni) can be a 4-bit number or an 8-bit number, and the like, wherein Ni represents the ith node.
Fig. 4 is a schematic diagram of node information provided in the embodiment of the present application, as shown in fig. 4, including N nodes, where each node i includes a Mac address and an 8-bit 16-ary random number Rand (Ni).
For example, the Mac address of the first node is Mac1, the random number is Rand (N1), the Mac address of the second node is Mac2, the random number is Rand (N2), the Mac address of the i-th node is Maci, the random number is Rand (Ni), and so on.
For each node, the Mac address and random number of the node constitute a key: value pair { node Mac address: rand (Ni) }, e.g., key of the first node: the value pair is { Mac1: rand (N1) }, key of the second node: the value pair is { Mac2: rand (N2) }, key of the i-th node: the value pair is { Maci: rand (Ni) }, and so on. Key for each node: the value pair is node information of the node. In fig. 4, node information of 6 nodes is illustrated, in the set 40, node information of 6 nodes is included, and node information of each node includes address information of the node and random information, where the address information is a Mac address of the node, and the random information is a random number generated according to the node.
After each node i acquires the node information of the node i, the node information of the node i can be broadcast to other nodes, and the node information broadcast to the node i by other nodes can be received. If M is smaller than N, some nodes that cannot broadcast node information and cannot receive the broadcasted node information exist in the N nodes, so communication between the nodes is only performed in the M nodes.
Fig. 5 is a schematic diagram of node information broadcast provided in the embodiment of the present application, as shown in fig. 5, including M nodes, where each node includes node information of its own. Each node will broadcast its own node information to other nodes, while each node will also receive node information broadcast by other nodes. For example, node 1 would broadcast node 1, i.e., { Mac1: rand (N1), and also receives node information 2 broadcast by node 2, node information 3 broadcast by node 3, and node information broadcast by node 4.
S32, obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
Specifically, for any node i in the M nodes, node information of other nodes received by the node i is obtained, and in the embodiment of the present application, other nodes refer to nodes except the node i in the M nodes. And then, ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
Fig. 6 is a schematic node information ordering diagram provided in the embodiment of the present application, as shown in fig. 6, let M equal to 6, where a certain node receives node information of other 5 nodes, and then orders its own node information and received node information of other 5 nodes.
Optionally, for any node i, the node information of the node i and the node information of other nodes received by the node i may be ordered according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
As shown in fig. 6, node information sent by other nodes received by the node i in the set 61 and node information of the node i itself, wherein random information of each node is illustrated in the set 61, and the random information of each node is an 8-bit 16-ary number. The random information of node 1 is 0x00002438, the random information of node 2 is 0x00300741, the random information of node 3 is 0x00B81C32, the random information of node 4 is 0x0A0B3266, the random information of node 5 is 0x00012512, and the random information of node 6 is 0x0040F5C2.
Then, a first information set corresponding to the node i can be obtained according to the random information ordering of the 6 nodes in an ascending order and a descending order. For example, in fig. 6, the first information set 62 is obtained in an order of random information from small to large, node information of 6 nodes is included in the first information set 62, and node information of 6 nodes is ordered.
Optionally, M is less than or equal to N and greater than or equal to 2f+1 among the N nodes of the blockchain system, where f is the number of failed nodes in the blockchain system and N is greater than or equal to 3f+1.M, N and f are integers.
S33, carrying out hash operation on the preset number of node information in the first information set corresponding to each node to obtain hash values of the preset number of node information in the first information set corresponding to each node.
In executing the solution of the present application, optionally, a timer may be set. After obtaining node information of each node, namely key: after the value pair, the timer starts counting down. For example, setting the preset network delay to be 5s, after the timer starts counting down, when the number of node information in the first information set exceeds the preset number, or after the timer counts down until the network delay becomes 0, performing hash operation on the previous preset number of node information in the first information set corresponding to each node according to the obtained M first information sets, so as to obtain hash values of the previous preset number of node information in the first information set corresponding to each node.
And setting the number of node information included in the first information set as count, and performing hash operation on the first 2f+1 node information in the first information set A corresponding to each node when the count is greater than or equal to the preset number 2f+1. When the node information received by each node and the node information of the node are ordered, the first 2f+1 node information in the first information set corresponding to each node obtained should be the same, so that the hash value obtained after the hash operation is performed on the first 2f+1 node information in the first information set a should also be the same.
S34, for any node i, acquiring hash values of the preset number of node information in the corresponding first information set broadcast by other nodes received by the node i.
Fig. 7 is a schematic diagram of node broadcasting provided in the embodiment of the present application, as shown in fig. 7, including 5 nodes, which are respectively node 71, node 72, node 73, node 74 and node 75. Each node broadcasts itself obtained (a, hash (a)) to other nodes after obtaining Hash values of the first 2f+1 node information in the first information set a of itself, wherein a represents the first information set, and Hash (a) represents Hash values of the first 2f+1 node information in the first information set a.
S35, determining a consensus node in the block chain system according to the hash value of the preset number of node information in the corresponding first information set broadcast by other nodes received by each node.
Specifically, according to hash values of the first preset number of node information in the corresponding first information set broadcast by other nodes received by each node, determining a plurality of first nodes in M nodes, wherein the hash values of the first preset number of node information in the corresponding first information set broadcast by the plurality of first nodes are the same; then, among the plurality of first nodes, a consensus node is determined.
Each node may broadcast the hash value of the first 2f+1 node information in the first information set a to other nodes, and each node may also receive the hash value of the first 2f+1 node information in the first information set a sent by other nodes, and check whether there is a possibility that the same node sends out different random numbers, and if so, discard the node, which cannot become a consensus node. If not less than f+1 Hash values Hash (a) are the same among the 2f+1 returned results, then the random consensus here is Hash (a). At this time, the Hash values of the first 2f+1 pieces of node information in the first information set a broadcast to other nodes are all nodes of random consensus Hash (a), and the node is regarded as the first node.
After a plurality of first nodes are determined in the M nodes, selecting M nodes from the plurality of first nodes as consensus nodes, wherein M is a positive integer less than f+1.
Alternatively, m nodes can be intercepted from the set a as elected nodes by truncating the function short (Hash (a), a, m), and a set B of m elements is returned.
Short (Hash (a), a, M): the truncated function is to select m elements from a as consensus nodes through random consensus Hash (a). The expression of the truncated function may be given according to actual needs, and the specific expression of the truncated function in the embodiment of the present application is not particularly limited. For example, one possible implementation is as follows:
The Hash (A) takes the last 8 digits to obtain C,
Offset=C mod M,
the selected node is A [ Offset ], A [ offset+1], A [ offset+i ] … A [ offset+M-1].
When f fault nodes exist, consistent consensus can be met according to the Bayesian fault-tolerant consensus algorithm principle; when an attack node sends different random numbers to other nodes, the receiving node can receive the (A, hash (A)) sent by other nodes, and if the same node sends different random numbers to different nodes, the attack node can detect the different random numbers and reject the different random numbers; when an attack node wants to construct a number, a random consensus HASH (A) is formed, and an attacker can only use the random number of the exhaustive algorithm because of the unidirectionality of the HASH algorithm; in addition, in the consensus, only 2f+1 inner seeds are required to be consistent with f+1, so that the consensus can be achieved, and because the number of network nodes is larger than 3f+1, only when the previous 2f+1 elements are consistent, the (2f+1, N) nodes with slow network calculation are invalid by utilizing the previous random numbers.
The node selection method provided by the embodiment of the application is applied to a block chain system, first, a first information set corresponding to each node in M nodes is obtained, M first information sets are obtained, the first information set corresponding to each node comprises node information of a plurality of nodes, and M is an integer larger than 1; then, when the number of node information included in each first information set is greater than or equal to a preset number, a consensus node is determined in the blockchain system according to the hash value of the previous preset number of node information in each first information set. According to the scheme provided by the embodiment of the application, node information broadcast by other nodes is received by each node, then the common node is obtained according to the hash value of the preset number of node information in each first information set, the node information of each node is not required to be exhausted, and the consumption of computing resources is small.
Fig. 8 is a schematic structural diagram of a node selection device provided in an embodiment of the present application, as shown in fig. 8, including an obtaining module 81 and a processing module 82, where:
the system comprises an acquisition module, a storage module and a storage module, wherein the acquisition module is used for acquiring a first information set corresponding to each node in M nodes to obtain M first information sets, the first information set corresponding to each node comprises node information of a plurality of nodes, and M is an integer greater than 1;
and the processing module is used for determining the consensus node in the blockchain system according to the hash value of the preset number of node information in each first information set when the number of the node information included in each first information set is larger than or equal to the preset number.
In one possible implementation manner, the obtaining module 81 is specifically configured to:
acquiring node information of other nodes received by each node in the M nodes;
and obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
In one possible implementation manner, the obtaining module 81 is specifically configured to:
aiming at any node i in the M nodes, acquiring node information of other nodes received by the node i;
And ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
In one possible implementation, for any node i, the node information of the node i includes address information and random information of the node i.
In one possible implementation manner, the obtaining module 81 is specifically configured to:
and ordering the node information of the node i and the node information of other nodes received by the node i according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
In one possible implementation, the processing module 82 is specifically configured to:
carrying out hash operation on the first preset number of node information in the first information set corresponding to each node to obtain hash values of the first preset number of node information in the first information set corresponding to each node;
for any node i, acquiring hash values of a preset number of node information in a corresponding first information set broadcast by other nodes received by the node i;
And determining a consensus node in the block chain system according to the hash value of the preset number of node information in the corresponding first information set broadcast by other nodes received by each node.
In one possible implementation, the processing module 82 is specifically configured to:
determining a plurality of first nodes in the M nodes according to hash values of the preset number of node information in the corresponding first information sets broadcast by other nodes received by each node, wherein the hash values of the preset number of node information in the corresponding first information sets broadcast by the plurality of first nodes are the same;
among the plurality of first nodes, the consensus node is determined.
In one possible implementation, the preset number is 2f+1, where the blockchain system includes N total nodes, f is the number of failed nodes in the N nodes, M < = N.
In one possible implementation, the number of the plurality of first nodes is greater than or equal to f+1, and the number of the consensus nodes is less than f+1.
The node selection device provided in the embodiment of the present application may execute the technical solution shown in the foregoing method embodiment, and its implementation principle and beneficial effects are similar, and will not be described herein again.
Fig. 9 is a schematic hardware structure of a node selection device provided in an embodiment of the present application, where, as shown in fig. 9, the node selection device includes: at least one processor 91 and a memory 92. The processor 91 and the memory 92 are connected by a bus 93.
In a specific implementation, the at least one processor 91 executes computer-executable instructions stored in the memory 92, so that the at least one processor 91 performs the node selection method as described above.
The specific implementation process of the processor 91 may refer to the above-mentioned method embodiment, and its implementation principle and technical effects are similar, and this embodiment will not be described herein again.
In the embodiment shown in fig. 9, it should be understood that the processor may be a central processing unit (english: central Processing Unit, abbreviated as CPU), or may be other general purpose processors, digital signal processors (english: digital Signal Processor, abbreviated as DSP), application specific integrated circuits (english: application Specific Integrated Circuit, abbreviated as ASIC), or the like. 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 present invention may be embodied directly in a hardware processor for execution, or in a combination of hardware and software modules in a processor for execution.
The memory may comprise high speed RAM memory or may further comprise non-volatile storage NVM, such as at least one disk memory.
The bus may be an industry standard architecture (Industry Standard Architecture, ISA) bus, an external device interconnect (Peripheral Component, PCI) bus, or an extended industry standard architecture (Extended Industry Standard Architecture, EISA) bus, among others. The buses may be divided into address buses, data buses, control buses, etc. For ease of illustration, the buses in the drawings of the present application are not limited to only one bus or one type of bus.
The present application also provides a computer-readable storage medium having stored therein computer-executable instructions that, when executed by a processor, implement a node selection method as described above.
The computer readable storage medium described above may be implemented by any type of volatile or non-volatile memory device or combination thereof, such as Static Random Access Memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk, or optical disk. A readable storage medium can be any available medium that can be accessed by a general purpose or special purpose computer.
An exemplary readable storage medium is coupled to the processor such the processor can read information from, and write information to, the readable storage medium. In the alternative, the readable storage medium may be integral to the processor. The processor and the readable storage medium may reside in an application specific integrated circuit (Application Specific Integrated Circuits, ASIC for short). The processor and the readable storage medium may reside as discrete components in a device.
The division of the units is merely a logic function division, and there may be another division manner when actually implemented, for example, a plurality of units or components may be combined or may be integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed with each other may be an indirect coupling or communication connection via some interfaces, devices or units, which may be in electrical, mechanical or other form.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of blockchain units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in each embodiment of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit.
The functions, if implemented in the form of software functional units and sold or used as a stand-alone product, may be stored in a computer-readable storage medium. Based on such understanding, the technical solution of the present application may be embodied essentially or in a part contributing to the prior art or in a part of the technical solution, in the form of a software product stored in a storage medium, including several instructions for causing a computer device (which may be a personal computer, a server, or a blockchain device, etc.) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
Those of ordinary skill in the art will appreciate that: all or part of the steps for implementing the method embodiments described above may be performed by hardware associated with program instructions. The foregoing program may be stored in a computer readable storage medium. The program, when executed, performs steps including the method embodiments described above; and the aforementioned storage medium includes: various media that can store program code, such as ROM, RAM, magnetic or optical disks.
Finally, it should be noted that: the above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some or all of the technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit of the corresponding technical solutions from the scope of the technical solutions of the embodiments of the present application.

Claims (18)

1. A node selection method, applied to a blockchain system, the method comprising:
acquiring a first information set corresponding to each node in M nodes to obtain M first information sets, wherein the first information set corresponding to each node comprises node information of a plurality of nodes, and M is an integer greater than 1;
when the number of the node information included in each first information set is greater than or equal to a preset number, determining a plurality of first nodes according to hash values of a preset number of node information in corresponding first information sets broadcast by other nodes received by each node, wherein the hash values of the preset number of node information in the corresponding first information sets broadcast by the plurality of first nodes are the same;
Among the plurality of first nodes, a consensus node is determined.
2. The method of claim 1, wherein the obtaining the first information set corresponding to each of the M nodes, to obtain the M first information sets, includes:
acquiring node information of other nodes received by each node in the M nodes;
and obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
3. The method according to claim 2, wherein the obtaining the first information set corresponding to each of the M nodes according to the node information of each node and the received node information of the other nodes includes:
aiming at any node i in the M nodes, acquiring node information of other nodes received by the node i;
and ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
4. A method according to claim 3, characterized in that for any node i, the node information of said node i comprises address information and random information of said node i.
5. The method of claim 4, wherein the sorting the node information of the node i and the node information of the other nodes received by the node i to obtain the first information set corresponding to the node i includes:
and ordering the node information of the node i and the node information of other nodes received by the node i according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
6. The method according to any one of claims 1-5, wherein the determining, according to the hash value of the first preset number of node information in the corresponding first information set broadcasted by the other node received by each node, before determining a plurality of first nodes in the M nodes, further comprises:
carrying out hash operation on the first preset number of node information in the first information set corresponding to each node to obtain hash values of the first preset number of node information in the first information set corresponding to each node;
and aiming at any node i, acquiring hash values of the preset number of node information in the corresponding first information set broadcast by other nodes received by the node i.
7. The method of claim 1, wherein the predetermined number is 2f+1, wherein the blockchain system includes a total of N nodes, f being a number of failed nodes of the N nodes, M < = N.
8. The method of claim 7, wherein the number of the plurality of first nodes is greater than or equal to f+1 and the number of the consensus nodes is less than f+1.
9. A node selection apparatus, comprising:
the system comprises an acquisition module, a processing module and a processing module, wherein the acquisition module is used for acquiring first information sets corresponding to each node in M nodes in a blockchain system to obtain M first information sets, the first information sets corresponding to each node comprise node information of a plurality of nodes, and M is an integer larger than 1;
a processing module, configured to, when the number of node information included in each first information set is greater than or equal to a preset number,
determining a plurality of first nodes in the M nodes according to hash values of the preset number of node information in the corresponding first information sets broadcast by other nodes received by each node, wherein the hash values of the preset number of node information in the corresponding first information sets broadcast by the plurality of first nodes are the same;
Among the plurality of first nodes, a consensus node is determined.
10. The apparatus of claim 9, wherein the obtaining module is specifically configured to:
acquiring node information of other nodes received by each node in the M nodes;
and obtaining a first information set corresponding to each node in the M nodes according to the node information of each node and the received node information of other nodes.
11. The apparatus of claim 10, wherein the obtaining module is specifically configured to:
aiming at any node i in the M nodes, acquiring node information of other nodes received by the node i;
and ordering the node information of the node i and the node information of other nodes received by the node i to obtain a first information set corresponding to the node i.
12. The apparatus of claim 11, wherein for any node i, the node information for the node i comprises address information and random information for the node i.
13. The apparatus of claim 12, wherein the obtaining module is specifically configured to:
and ordering the node information of the node i and the node information of other nodes received by the node i according to the random information of the node i and the random information of other nodes received by the node i, so as to obtain a first information set corresponding to the node i.
14. The apparatus of any one of claims 9-13, wherein the processing module is further configured to:
carrying out hash operation on the first preset number of node information in the first information set corresponding to each node to obtain hash values of the first preset number of node information in the first information set corresponding to each node;
and aiming at any node i, acquiring hash values of the preset number of node information in the corresponding first information set broadcast by other nodes received by the node i.
15. The apparatus of claim 9, wherein the predetermined number is 2f+1, wherein the blockchain system includes a total of N nodes, f being a number of failed nodes of the N nodes, M < = N.
16. The apparatus of claim 15, wherein the number of the plurality of first nodes is greater than or equal to f+1 and the number of common nodes is less than f+1.
17. A node selection apparatus, comprising: at least one processor and memory;
the memory stores computer-executable instructions;
the at least one processor executing computer-executable instructions stored in the memory causes the at least one processor to perform the node selection method of any one of claims 1 to 8.
18. A computer readable storage medium having stored therein computer executable instructions which when executed by a processor implement the node selection method of any of claims 1 to 8.
CN202010224718.4A 2020-03-26 2020-03-26 Node selection method and device Active CN111447274B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010224718.4A CN111447274B (en) 2020-03-26 2020-03-26 Node selection method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010224718.4A CN111447274B (en) 2020-03-26 2020-03-26 Node selection method and device

Publications (2)

Publication Number Publication Date
CN111447274A CN111447274A (en) 2020-07-24
CN111447274B true CN111447274B (en) 2023-06-02

Family

ID=71652485

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010224718.4A Active CN111447274B (en) 2020-03-26 2020-03-26 Node selection method and device

Country Status (1)

Country Link
CN (1) CN111447274B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114650289B (en) * 2020-12-02 2023-04-14 王志诚 Method and device for block chain consensus
CN112688996A (en) * 2020-12-16 2021-04-20 宁波云麟信息科技有限公司 Electronic certificate storage data storage method based on block chain and electronic equipment

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107481145A (en) * 2017-08-30 2017-12-15 北京知金链网络技术有限公司 Block chain multidimensional random number common recognition election method
CN110011974A (en) * 2019-03-07 2019-07-12 深圳市融汇通金科技有限公司 Bookkeeping methods, device, terminal and the computer readable storage medium of block chain
CN110599173A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Block chain consensus node determination method, device, equipment and storage medium
CN110909083A (en) * 2019-12-03 2020-03-24 北京艾摩瑞策科技有限公司 Consensus method and system for verifiable random function on block chain

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US11646879B2 (en) * 2018-06-12 2023-05-09 Electronics And Telecommunications Research Institute Method and apparatus for selecting distributed consensus node based on proof of nonce

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107481145A (en) * 2017-08-30 2017-12-15 北京知金链网络技术有限公司 Block chain multidimensional random number common recognition election method
CN110011974A (en) * 2019-03-07 2019-07-12 深圳市融汇通金科技有限公司 Bookkeeping methods, device, terminal and the computer readable storage medium of block chain
CN110599173A (en) * 2019-09-20 2019-12-20 腾讯科技(深圳)有限公司 Block chain consensus node determination method, device, equipment and storage medium
CN110909083A (en) * 2019-12-03 2020-03-24 北京艾摩瑞策科技有限公司 Consensus method and system for verifiable random function on block chain

Also Published As

Publication number Publication date
CN111447274A (en) 2020-07-24

Similar Documents

Publication Publication Date Title
US11095451B2 (en) Optimal data storage configuration in a blockchain
EP3493084B1 (en) Method for processing data in bloom filter and bloom filter
CN110599160B (en) Method and apparatus for selecting distributed consensus nodes based on random number attestation
CN108512650B (en) Block chain-oriented dynamic hash calculation method, device, node and storage medium
US9917689B2 (en) Generating multiple secure hashes from a single data buffer
CN111447274B (en) Node selection method and device
US20190182029A1 (en) Method of generating block chain and apparatus and method for generating blocks
US11362832B2 (en) Distributed proof-of-work for sharded or parallel blockchains
US7269614B2 (en) Secure hardware random number generator
US9396119B2 (en) Device for controlling the access to a cache structure
CN111698094B (en) Common identification method based on block chain system and block chain system
US10491377B2 (en) Hashing using data parallel instructions
US9063807B2 (en) Method and structure for provably fair random number generator
US20080263117A1 (en) Initial seed management for pseudorandom number generator
US20240163121A1 (en) Blockchain consensus method, apparatus, and device, and storage medium
Kara et al. Fast and robust hashing for database operators
US20220358119A1 (en) Blockchain consensus method, apparatus and device
US8214902B2 (en) Determination by circuitry of presence of authorized and/or malicious data
EP3642707A1 (en) A method for generating operating entropy
CN110515591B (en) Random number generation method and device based on block chain
US20220292203A1 (en) Technologies for device attestation
CN111866156B (en) Fusing processing method and device
CN112636907A (en) Key management method, key using method, device and equipment
Bastos et al. Measuring randomness in IoT products
Fukač et al. Increasing memory efficiency of hash-based pattern matching for high-speed networks

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant