CN110427763B - Consensus method of distributed system based on predefined execution codes - Google Patents

Consensus method of distributed system based on predefined execution codes Download PDF

Info

Publication number
CN110427763B
CN110427763B CN201910672698.4A CN201910672698A CN110427763B CN 110427763 B CN110427763 B CN 110427763B CN 201910672698 A CN201910672698 A CN 201910672698A CN 110427763 B CN110427763 B CN 110427763B
Authority
CN
China
Prior art keywords
task
initial
random number
node list
current
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
CN201910672698.4A
Other languages
Chinese (zh)
Other versions
CN110427763A (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.)
Shanghai Zhaoxi Network Technology Co ltd
Original Assignee
Shanghai Zhaoxi Network 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 Shanghai Zhaoxi Network Technology Co ltd filed Critical Shanghai Zhaoxi Network Technology Co ltd
Priority to CN201910672698.4A priority Critical patent/CN110427763B/en
Publication of CN110427763A publication Critical patent/CN110427763A/en
Application granted granted Critical
Publication of CN110427763B publication Critical patent/CN110427763B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/602Providing cryptographic facilities or services
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F21/00Security arrangements for protecting computers, components thereof, programs or data against unauthorised activity
    • G06F21/60Protecting data
    • G06F21/62Protecting access to data via a platform, e.g. using keys or access control rules
    • G06F21/6218Protecting access to data via a platform, e.g. using keys or access control rules to a system of files or objects, e.g. local or distributed file system or database
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F7/00Methods or arrangements for processing data by operating upon the order or content of the data handled
    • G06F7/58Random or pseudo-random number generators
    • G06F7/582Pseudo-random number generators

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Health & Medical Sciences (AREA)
  • Computer Security & Cryptography (AREA)
  • Software Systems (AREA)
  • Computer Hardware Design (AREA)
  • Bioethics (AREA)
  • Health & Medical Sciences (AREA)
  • Databases & Information Systems (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Computer And Data Communications (AREA)
  • Multi Processors (AREA)

Abstract

The invention discloses a distributed system consensus method based on predefined execution codes, which comprises the steps of initializing a distributed system, and determining the update rules of a task period, an initial participating node list L and a candidate participating node list PL of the distributed system; the initial participating node executes and completes an initial predefined task, judges whether the current moment is a periodic moment, if so, updates the candidate participating node list PL according to the updating rule, otherwise, acquires the candidate participating node list PL updated at the previous periodic moment; and determining the current task, selecting an execution node of the current task from the candidate participation node list PL according to the random number of the current task, and achieving consensus. Aiming at the condition that a data processing mechanism is incompatible with the calculation scale and the safety in the prior art, the technical scheme of the invention improves the consensus algorithm on the basis of the consensus algorithm heavily dependent on the calculation power, so that the efficiency and the safety of a transaction processing mechanism can be improved while the consensus algorithm is suitable for large-scale network calculation.

Description

Consensus method of distributed system based on predefined execution codes
Technical Field
The invention belongs to the field of distributed systems, and particularly relates to a distributed system consensus method based on predefined execution codes.
Background
Distributed systems (distributed systems) are software systems built on top of a network. The distributed system has a high degree of cohesion and transparency. In a distributed system, a set of independent computers appear to the user as a unified whole. I.e. from a service point of view, the user perceives an independent system. The system has various general physical and logical resources, can dynamically allocate tasks, and realizes information exchange by the dispersed physical and logical resources through a computer network. On this basis, the distributed system is a distributed database which stores data in each node according to time sequence. The distributed database has the characteristics of centralization, high availability, sharing, data consistency and the like.
In order to ensure efficient operation and safety of the distributed system, researchers at home and abroad propose various consensus algorithms, such as PBFT, Paxos and the like. By "consensus", it is meant that each individual database node guarantees the consistency and integrity of the respective data within a certain time unit. Consensus algorithms are generally classified into two categories according to the frequency of communication and the consumption of computing power: a consensus algorithm of heavily dependent communication and a consensus algorithm of heavily dependent computing power. In a traditional consensus algorithm relying on communication, taking a byzantine algorithm as an example, multiple interactions and negotiations are needed among different nodes, and the final data consensus can be finally determined by multiple confirmations among multiple nodes. Due to the limitation of the network data diffusion speed, the efficiency of the mechanism is very low, and the consensus of heavily relying on communication is that a plurality of times of communication needs to consume a large amount of resources, for example, the network communication amount increases exponentially along with the increase of the number of nodes, so that the algorithm is only suitable for a small-scale network structure, and the consensus of the mode is poor in safety, wherein the nodes are considered to be credible or authorized.
The emerging algorithm of recognization of dependence on computational power represented by bitcoin mining needs to consume a large amount of computational power. The principle is that a plurality of nodes with strong calculation power acquire the execution right of the current round through competition for a certain difficult problem (namely the current round is based on the data of the node). The algorithm with heavy dependence can be suitable for large-scale networks and is relatively safe. But a great deal of computing power is consumed, and most of the computing power is not effectively utilized, so that a great deal of resources are wasted.
Disclosure of Invention
In view of the above-identified deficiencies in the art or needs in the art, the present invention provides a distributed system consensus method based on predefined execution code that at least partially solves the above problems. Aiming at the condition that a data processing mechanism is incompatible with the calculation scale and the safety in the prior art, the technical scheme of the invention improves the consensus algorithm on the basis of the consensus algorithm heavily dependent on the calculation power, so that the efficiency and the safety of a transaction processing mechanism can be improved while the consensus algorithm is suitable for large-scale network calculation.
To achieve the above object, according to one aspect of the present invention, there is provided a distributed system consensus method based on predefined execution codes, comprising
S1 initializes the distributed system, determines its task cycle, initial participating node list L, and determines the update rule (e.g. predefined execution code in the embodiment) of the candidate participating node list PL for each task cycle;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task, selecting at least one participating node from the candidate participating node list PL according to the random number of the current task, and taking the node as the executing node of the current task to reach consensus.
As a preferable aspect of the present invention, step S1 includes,
s11 determining an initial participating node list L and/or a task period;
s12, determining the updating rule of the candidate participation node list PL of each task period in the distributed system;
s13 utilizes the distributed system to store the initial participating node list L, the tasks of the initial task period, and/or the update rules in the initialization module.
As a preferable aspect of the present invention, step S2 includes,
s21, each participating node polls and executes the task completing the initial task period;
s22, detecting whether the current time is the period time of the distributed system, if yes, updating the participating node list according to the updating rule, otherwise, reading the participating node list at the previous period time;
s23 reads the task list of the current task cycle.
As a preferable aspect of the present invention, step S3 includes,
s31, according to the current task, the candidate participation node list PL of the current task period and the random number of the previous task;
s32, generating the random number of the current task according to the random number of the previous task;
s33 determines the executing node of the current task in the candidate participating node list PL of the current task period using the random number of the current task and agrees.
As a preferable aspect of the present invention, step S32 includes,
s321, acquiring an initial key and a random number of an initial task, and distributing the initial key and the random number to participating nodes of a distributed system;
s322, inputting a random number of an initial task and carrying out hash operation to obtain a hash value;
s323, encrypting the hash value by using the initial key;
s324 obtains a new random number according to the returned encrypted hash value, which is the random number of the next task.
According to one aspect of the invention, a distributed system consensus system based on predefined execution codes is provided, which is characterized by comprising
The system comprises an initial module, a task period determination module and an initial participation node list L, wherein the initial module is used for initializing the distributed system, determining a task period and the initial participation node list L of the distributed system, and determining an update rule of a candidate participation node list PL of each task period;
the period module is used for the initial participating node to execute and complete the initial predefined task, judging whether the current time is the period time, if so, updating the candidate participating node list PL according to the updating rule, and otherwise, acquiring the candidate participating node list PL updated at the previous period time;
and the consensus module is used for determining the current task, selecting at least one participating node from the candidate participating node list PL according to the random number of the current task, taking the selected participating node as an execution node of the current task, and achieving consensus.
As a preferred embodiment of the present invention, the initial module comprises,
the system comprises an initial list module, a task period module and a task processing module, wherein the initial list module is used for determining an initial participating node list L and/or a task period;
the updating rule module is used for determining the updating rule of the candidate participation node list PL of each task period in the distributed system;
and the storage module is used for storing the initial participating node list, the initial predefined task and/or the updating rule in the initialization module.
As a preferred embodiment of the present invention, the period module includes,
the task cycle module is used for polling and executing the task completing the initial task cycle by each participating node;
the time detection module is used for detecting whether the current time is the periodic time of the distributed system, if so, updating the participating node list according to the updating rule, and otherwise, reading the participating node list at the previous periodic time;
and the task module is used for reading the task list of the current task period.
As a preferred embodiment of the present invention, the consensus module comprises,
the initial random number module is used for selecting a candidate participation node list PL according to a current task, a current task period and a random number of a previous task;
the current random number module is used for generating the random number of the current task according to the random number of the previous task;
and the consensus executing module is used for determining the executing node of the current task in the candidate participating node list PL in the current task period by using the random number of the current task and achieving consensus.
As a preferred embodiment of the present invention, the current random number module includes,
the initial key module is used for acquiring an initial key and a random number of an initial task and distributing the initial key and the random number to participating nodes of a distributed system;
the hash operation module is used for inputting the random number of the initial task and carrying out hash operation to obtain a hash value;
the encryption module is used for encrypting the hash value by using the initial key;
and the returning module is used for acquiring a new random number according to the returned encrypted hash value, namely the random number of the next task.
According to one aspect of the invention, there is provided a memory device having stored therein a plurality of instructions adapted to be loaded and executed by a processor:
s1, initializing the distributed system, determining the task period and the initial participating node list L, and determining the updating rule of the candidate participating node list PL of each task period;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task, selecting at least one participating node from the candidate participating node list PL according to the random number of the current task, and taking the node as the executing node of the current task to reach consensus.
According to an aspect of the present invention, there is provided a terminal comprising a processor adapted to implement instructions; and a storage device adapted to store a plurality of instructions, the instructions adapted to be loaded and executed by the processor to:
s1, initializing the distributed system, determining the task period and the initial participating node list L, and determining the updating rule of the candidate participating node list PL of each task period;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task, selecting at least one participating node from the candidate participating node list PL according to the random number of the current task, and taking the node as the executing node of the current task to reach consensus.
Generally, compared with the prior art, the above technical solution conceived by the present invention has the following beneficial effects:
1) according to the technical scheme, through two rounds of screening, the candidate participants in a task period are determined, and then the execution nodes of a specific task are selected from the candidate participants, so that the efficiency of consensus exchange is effectively improved, and the resource consumption in the consensus process is reduced.
2) According to the technical scheme, the candidate participants of the latter task period are updated based on the last task period, so that the continuity of the whole distributed system in the execution process of the predefined task is ensured, and the whole system can be continuously operated according to the preset rule.
3) According to the technical scheme, the execution sequence of the current task period is determined by the pseudo-random number of the hardware, the hardware is randomly composed of the encrypted HASH, and due to the limitation of the key and the calling frequency, the future HASH cannot be predicted, so that the task execution node of the next round cannot be predicted, and the safety of the consensus process is ensured.
Drawings
Fig. 1 is a flowchart of electing a task execution node according to an embodiment of the present invention;
fig. 2 is a flowchart of election for selecting a task execution node in a task execution stage according to an embodiment of the present invention;
fig. 3 is a data flow diagram of a consensus method based on predefined execution codes according to an embodiment of the present invention.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention. In addition, the technical features involved in the embodiments of the present invention described below may be combined with each other as long as they do not conflict with each other. The present invention will be described in further detail with reference to specific embodiments.
In a distributed system, because of the decentralized nature of the individual nodes, this means that communication between each of the participating nodes is completely free. In this case, when agreement is required between not less than two nodes, information needs to be exchanged between any two nodes. How to make a plurality of nodes agree on a specific matter is a problem to be solved by the present invention, and in this embodiment, it is preferably done by predefined execution codes.
Specifically, in the consensus method of this embodiment, in any task turn, as long as the tasks participating in the turn form a code contract between the participating nodes, all nodes under the code contract are constrained by the predefined execution code corresponding to the code contract. The participants of a specific predefined execution code in a specific task turn are fully aware of the participating nodes and participating content of the task turn. Thus, for any turn constrained by the predefined execution code, the participating nodes of the current turn are aware of the participants and predefined execution code content of the current turn at the beginning of the current turn, further correspondingly, the results of which are also predictable for the current turn of participation.
On this basis, the present embodiment further describes the consensus method of the present application. The consensus method of the embodiment is designed based on a data structure and a random mathematical idea, and specifically includes at least the following three stages: an initialization phase, a node selection phase and a task execution phase. The details thereof will be described below by specific steps.
The first stage is as follows: and (5) an initialization phase.
First, in this embodiment, the initialization module is preferably provided with a hardware random number unit for generating a random number in an initialization stage, and in any determined task round, the initial random numbers are preferably kept consistent for different nodes to identify. Further, in this embodiment, the random number generated by the hardware random number unit is preferably encrypted and stored in the initialization module. The reason for this is that, since the random number is determined to be generated and shared to all participating nodes in the initialization process, the nodes perform synchronous initialization by the uniform random number. The encryption is to further improve the security of the random number, increase the difficulty of cracking, and reduce the risk of task failure caused by the random number being broken.
And determining an initial participating node of the initial task wheel, acquiring a participating node list L of the initial task wheel, and writing the participating node list L into the initialization module. In the initial task wheel, each node is in an initialized state, and there is no factor for distinguishing between any two nodes, so in the initial task wheel of this embodiment, each participating node executes a task in a polling manner. Namely, each node in the list L executes the task of the current round according to the initial predefined execution code, and each node finishes the execution of the same task in sequence.
Second, the predefined execution code for the selection of the participating nodes of the current round is validated and stored in the distributed system for review. At this time, the task of the initial task wheel is completely executed, and the system is initialized only when the system starts to operate. At this time, a candidate node selection rule (predefined execution code) corresponding to the initial task round is also determined, and according to the rule, the next stage can be entered to select the candidate participating node list PL of the round, and then the next round of tasks can be entered.
Thirdly, determining a task period of the distributed system, and updating the candidate participation node list PL at the periodic moment. For example, when voting is adopted as the candidate node selection rule, the number of votes is subjected to ranking statistics at the arrival of each period, and then the candidate participating node list PL is updated. Preferably, except for the initial task period (the initial task period only has the participating node list L, and there is no candidate participating node list PL), in this embodiment, the candidate participating node list PL of each task period is selected according to the candidate node selection rule in the last task period.
In the process of selecting a node according to the voting result, a node with the highest or lowest vote number may be selected, a node with a certain rank may also be selected, or a node closest to the average vote number may be selected. For the convenience of understanding, in this embodiment, it is preferable to use a time after the initialization phase is completed (at this time, the initial participating node completes the initial task in a polling manner, and determines the list update rule) as a first period time, that is, a period from this time. At this time, the nodes in the participating node list L have already completed initialization, and the candidate participating node list PL may be selected from the participating node list L according to a preset rule.
And a second stage: and a node selection phase. I.e. the latest candidate participating node list PL is chosen from the participating node lists L of the current round in order to select the executing node of the specific task in the PL.
In an initialization phase, the tasks of the initial task period have been completed, and the candidate nodes determining the initial task period select predefined execution code. In the node selection phase, the node selection is further completed based on the result of the initialization phase. In the initialization process, the participating nodes poll the task executing the initial task period, and then the candidate node selection rule selects the candidate participating node list PL, that is, the initial candidate participating node list PL is selected from all the initial participating node lists L by using a predefined execution code. It is noted that in this embodiment, the updating of the list of participating nodes PL is preferably done by means of predefined execution code.
Specifically, the node selection of the present application includes the following steps:
the first step is as follows: in the initial state, preferably in an external calling manner, the system node is triggered to execute an initial predefined execution code, and a selection process is executed to select the participating node list L, so as to obtain an initial candidate participating node list PL. For example, when the node is selected by voting, the participating nodes participating in the current round are voted, and then the node is selected according to the voting result. In the voting process, all the participating nodes can invite the external node to vote for itself, which is not limited to the participating nodes in the current round.
The second step is that: and updating the participating node list of the next round of tasks. According to a specific rule, it can be set that the participants of any task wheel are fixed, that is, all the participating nodes are fixed from the initial task wheel until the execution of all task wheels is completed, and likewise, they can be dynamically changed. In a preferred embodiment, the participants of each task cycle are variable (i.e. the list of participating nodes L, the list of candidate participating nodes PL are variable) over a plurality of task cycles. In a specific implementation, a node that did not participate in the process may request participation, and a node that did participate in the process may request exit.
In this embodiment, it is preferable that the candidate participating nodes (nodes constituting the PL of the next cycle) selected in the task cycle are determined to be added into the next task cycle, and then the participating nodes of the next task cycle may be updated. It should be noted that, in the participating node list L and the candidate participating node list PL, the number of nodes thereof has no upper limit requirement, but must not be less than the lower limit threshold. The lower threshold is preferably not less than 2, depending on the characteristics of the distributed system.
As shown in fig. 1 and fig. 2, the above process may be summarized that after the original participating node list L completes the initialized task, a new round of candidate participating node list PL is generated to enter a next task period, then for each task of the next task period, a current task executing node is selected from the candidate participating node list PL, and the winning node is used as a task executing node to execute the current task.
And a third stage: and a task execution phase. Determining the current task, and selecting an execution node (who executes) of the current task from the candidate participating node list PL of the task period (which may also be referred to as a Leader of the current task in the task period), where the selected task execution node unifies execution behaviors (how to execute) of other participating nodes to lead participants of the current task to execute the current task. Preferably, in this embodiment, the unified execution behavior of the Leader is also verified, and the verification can be executed by a verification passing party.
As shown in fig. 3, this stage is an arbitrary task cycle other than the initial task cycle, and is characterized in that the node executing this task cycle is preferably selected from the candidate participating node list PL selected at the end of the last task cycle by a random number. According to the first and second phases, the distributed system has completed the initialization and has determined that, starting from the first task cycle after the initialization, the executing node of the current task is selected in the list PL of participating nodes. The process comprises two consensus, wherein the first is that a task execution node selected from a candidate participated node list PL acquires all node consensus, all nodes approve the node as a Leader of a current task and lead other participated nodes to execute the current task, namely, the current task is determined to be executed by the Leader in a leading way, the second is that the task content executed by the task execution node is acquired and the other participated nodes are approved for execution behaviors uniformly determined by the task execution node, namely, the other participated nodes approve a uniform execution mode of the Leader.
In one task period, a plurality of specific tasks may be included, and the distributed system of this embodiment preferably selects a corresponding task execution node for each specific task in the current round in the candidate participating nodes of the task period. That is, in this embodiment, the candidate participating node list is updated for each task cycle, that is, the PL is updated once at the beginning of a task cycle, and then, in a specific task in a task cycle, a task executing node is selected from the candidate participating nodes of the PL to execute the task.
Therefore, in the embodiment, the processing of the participating nodes includes two links, one is to update the candidate participating node list PL at the beginning of the task cycle; and the other is to select a specific execution node from the candidate participation nodes PL of the current round to execute the current task aiming at the specific task in a task period.
Specifically, this stage of the present embodiment includes the following steps:
the first step is as follows: firstly, judging whether the current moment is a task period moment, if so, updating a candidate participation node list PL, then starting to execute the task of the period, otherwise, acquiring a candidate participation node list of the previous task period moment as the candidate task execution node list PL of the task period.
The second step is that: after determining the candidate task execution node list PL of the task period, preferably, the random number R of the current task is generated according to the random number of the previous task, and then the random number R of the task in the current round is stored in the system module of the current task period. That is to say, in this embodiment, each task in each task period corresponds to a random number, that is, the generation of the random number is only related to the task sequence of the current task in the whole distributed system. A random number is present in each task, which is only used to decide which candidate participating node of the current task cycle will execute the task when it arrives. That is, when the next task arrives, the random number of the next task is generated according to the random number of the previous task, and then the execution node of the predefined task is selected from the candidate participating nodes of the current task period according to the random number.
The third step: and determining the task execution node of the current round according to the random number. In order to further improve the safety of the method and improve the unpredictability of the method, it is preferable in this embodiment to determine the performers (performance nodes) of the tasks in the current round according to the random number R. Because R has randomness, the outside is difficult to predict the actual executives of the task in the round. In a preferred embodiment, R is used to perform a remainder operation on the length of the current candidate participant node list PL, and the performer (performance node) of the current task round is determined based on the remainder. The randomness and unpredictability of the above process may be further improved in case the list of candidate participating nodes PL is variable.
In a specific embodiment, the random number is generated by a hardware random number generator, which generally comprises the steps of:
1. initializing the key and initial state R corresponding to the current hardware random number generation module0And the key is compared with the initial state R0To all participating hardware modules;
2. acquiring a random number (preferably an encrypted random number) of the previous task round, then performing hash operation on the random number, performing key encryption on the hash operation result again, and returning to obtain the latest key random number;
Ri+1=ENCkey(HASH(Ri))
3. and updating all nodes by using the key random number in a certain fixed task period.
4. In this embodiment, it is preferable to limit the frequency of invoking the random number, for example, in each task period, each random number is only allowed to be invoked N times, where N may represent the number of tasks in the current period or a certain threshold number.
Based on the above process, in a task sequence including a plurality of tasks, the task sequence is divided into a plurality of task periods according to a certain rule, except for the initial task period, starting from the second task period, each task period is based on the execution result of the previous task period to execute the task of the next task period until the tasks in the whole task sequence are all completed.
As can be seen from the above input process of the random number, in any task period, the random numbers received by the participating nodes are consistent to ensure that all the node acquisition information is consistent, and preferably, the encrypted random number is pre-embedded in the hardware module. Due to the consistency of the initial state and the consistency of the algorithm, the consistency of the results obtained in the hardware random number of each node in the current round is ensured, namely the selected execution nodes are consistent. Meanwhile, in order to further improve the privacy of the node information, the random number in the embodiment is preferably encrypted and then sent, so that the security of the random number is improved, and the stability of a distributed system is guaranteed.
Further, in the present embodiment, the participating nodes in both lists L and PL are verifiable, the verifier can perform identity verification on the participating nodes in a variety of ways, and the verifier is not limited to the participating nodes in lists L and PL. For a specific node, when the verification result of a certain number or proportion of nodes is true, that is, the identity of the node is true and credible, otherwise, the identity of the node is not true and credible, and the node needs to be removed from the participating node list.
To sum up, in this embodiment, the participating nodes are processed twice, the first time is at the cycle time of each task cycle, the cycle time is a division point of two cycles, at this time, the candidate participating node list PL is updated according to the voting condition, the candidate participating node of this task cycle is obtained, and the task execution node in this task cycle is selected from the candidate participating node list PL of this task cycle. On the basis, when a specific task in the task period is executed, one node is selected from the candidate participated node list PL of the current task period to execute the task, and when a next task is met, the process is repeated until the next period is met. As shown in table 1, is a specific introduction to the above process.
Node list L PL0 PL1
Node member 1,2,3…N 1,3,5,7,9 2,4,6,8,10
Corresponding task A,B C,D,E,F,G,H,I G,K,L,M,N,O,P,Q
TABLE 1 node List and its corresponding node members and tasks
In table 1, in the initial task period, there is no candidate participating node list PL, and only the participating node list L, at this moment, the corresponding member nodes in the list are all participating nodes 1,2,3 … N, and the tasks that need to be polled are a and B. Then, a first candidate participating node list PL0 is selected from the participating node list L according to a predefined code, where PL0 is a candidate participating node list of a next task cycle of the initial task cycle, where the member nodes include 1,3,5,7,9, and the corresponding tasks to be completed are C, D, E, F, G, H, I, and at this time, for each task to be completed in the task cycle, an executing node is selected from the node members of the corresponding candidate participating node list PL0 to execute the task, that is, each task in C, D, E, F, G, H, I needs to be executed by selecting a node from 1,3,5,7,9, respectively, and this process is implemented by a random number in this embodiment. When the task period is finished, updating the PL according to the updating rule to obtain a candidate participated node list PL1 of the next task period, and the like.
In table 1, except that a and B in the initial task period are executed in a polling manner, tasks in other task periods are executed by selecting an executing node from the candidate participating node list PL in the current task period by using a random number. Meanwhile, the generation (or updating) of the candidate participating node list PL is preferably implemented by means of an update rule.
In this way, it can be ensured that for any task, only one determined task execution node is responsible for executing the task, and the rest of the nodes are compliant with the node. For a simple example, assuming that the current task is mountain climbing, 100 nodes (participating node list L) are provided in the entire distributed system, 10 candidate participating nodes (candidate participating node list PL) are provided in a task period of the task, and the 5 th node is selected from the 10 candidate participating nodes as an executing node (Leader) of the predefined task, the Leader can uniformly determine the line, time, and specifically which mountain (executing mode) to climb the mountain and publish to other participating nodes, and the other participating nodes can verify the executing mode and the executing content, and after the verification is passed, the other participating nodes complete the task of mountain climbing according to the executing mode uniformly determined by the Leader under the lead of the Leader.
In addition, in this embodiment, it is preferable that, in units of one task cycle, information of the predefined tasks in one task cycle, the candidate participating nodes corresponding to the predefined tasks, the actual execution nodes of each predefined task, and the like is written into one storage module and stored as a task execution record of one task cycle.
It will be understood by those skilled in the art that the foregoing is only a preferred embodiment of the present invention, and is not intended to limit the invention, and that any modification, equivalent replacement, or improvement made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (11)

1. A distributed system consensus method based on predefined execution codes is characterized by comprising
S1, initializing all participating nodes in the distributed system by adopting uniform random numbers, determining the task period and the initial participating node list L, and determining the updating rule of the candidate participating node list PL of each task period;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task in the current task period, and generating the random number of the current task according to the random number of the previous task; according to the random number of the current task, selecting a participating node from the candidate participating node list PL of the current task period as an executing node of the current task and achieving consensus;
the execution node determines the execution mode and the execution content of the current task, and other participating nodes in the candidate participating node list PL verify the execution mode and the execution content of the current task issued by the execution node and execute the current task after the verification is passed.
2. The distributed system consensus method based on predefined execution codes, according to claim 1, wherein step S1 comprises,
s11 determining an initial participating node list L and/or a task period;
s12, determining the updating rule of the candidate participation node list PL of each task period in the distributed system;
s13 utilizes the distributed system to store the initial participating node list L, the tasks of the initial task period, and/or the update rules in the initialization module.
3. The distributed system consensus method based on predefined execution codes of claim 1 or 2, wherein step S2 comprises,
s21, each participating node polls and executes the task completing the initial task period;
s22, detecting whether the current time is the period time of the distributed system, if yes, updating the participating node list according to the updating rule, otherwise, reading the participating node list at the previous period time;
s23 reads the task list of the current task cycle.
4. The distributed system consensus method based on predefined execution codes as claimed in claim 1, wherein said generating the random number of the current task according to the random number of the previous task comprises,
s321, acquiring an initial key and a random number of an initial task, and distributing the initial key and the random number to participating nodes of a distributed system;
s322, inputting a random number of an initial task and carrying out hash operation to obtain a hash value;
s323, encrypting the hash value by using the initial key;
s324 obtains a new random number according to the returned encrypted hash value, which is the random number of the next task.
5. A distributed system consensus system based on predefined execution codes is characterized by comprising
The system comprises an initial module, a task period updating module and a candidate participating node list PL updating module, wherein the initial module is used for initializing all participating nodes in the distributed system by adopting uniform random numbers, determining a task period and an initial participating node list L of the nodes and determining an updating rule of the candidate participating node list PL of each task period;
the period module is used for the initial participating node to execute and complete the initial predefined task, judging whether the current time is the period time, if so, updating the candidate participating node list PL according to the updating rule, and otherwise, acquiring the candidate participating node list PL updated at the previous period time;
the consensus module is used for determining the current task in the current task period and generating the random number of the current task according to the random number of the previous task; according to the random number of the current task, selecting a participating node from the candidate participating node list PL of the current task period as an executing node of the current task and achieving consensus;
the execution node determines the execution mode and the execution content of the current task, and other participating nodes in the candidate participating node list PL verify the execution mode and the execution content of the current task issued by the execution node and execute the current task after the verification is passed.
6. The distributed system consensus system based on predefined execution codes of claim 5, wherein said initial module comprises,
the system comprises an initial list module, a task period module and a task processing module, wherein the initial list module is used for determining an initial participating node list L and/or a task period;
the updating rule module is used for determining the updating rule of the candidate participation node list PL of each task period in the distributed system;
and the storage module is used for storing the initial participating node list, the initial predefined task and/or the updating rule in the initialization module.
7. The distributed system consensus system based on predefined execution codes of claim 5 or 6, wherein said period module comprises,
the task cycle module is used for polling and executing the task completing the initial task cycle by each participating node;
the time detection module is used for detecting whether the current time is the periodic time of the distributed system, if so, updating the participating node list according to the updating rule, and otherwise, reading the participating node list at the previous periodic time;
and the task module is used for reading the task list of the current task period.
8. The distributed system consensus system based on predefined execution codes of claim 5, wherein said consensus module comprises,
the initial random number module is used for selecting a candidate participation node list PL according to a current task, a current task period and a random number of a previous task;
the current random number module is used for generating the random number of the current task according to the random number of the previous task;
and the consensus executing module is used for determining the executing node of the current task in the candidate participating node list PL in the current task period by using the random number of the current task and achieving consensus.
9. The distributed system consensus system based on predefined execution codes of claim 8, wherein said current random number module comprises,
the initial key module is used for acquiring an initial key and a random number of an initial task and distributing the initial key and the random number to participating nodes of a distributed system;
the hash operation module is used for inputting the random number of the initial task and carrying out hash operation to obtain a hash value;
the encryption module is used for encrypting the hash value by using the initial key;
and the returning module is used for acquiring a new random number according to the returned encrypted hash value, namely the random number of the next task.
10. A memory device having stored therein a plurality of instructions adapted to be loaded and executed by a processor:
s1, initializing all participating nodes in the distributed system by adopting uniform random numbers, determining the task period and the initial participating node list L, and determining the updating rule of the candidate participating node list PL of each task period;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task in the current task period, and generating the random number of the current task according to the random number of the previous task; according to the random number of the current task, selecting a participating node from the candidate participating node list PL of the current task period as an executing node of the current task and achieving consensus;
the execution node determines the execution mode and the execution content of the current task, and other participating nodes in the candidate participating node list PL verify the execution mode and the execution content of the current task issued by the execution node and execute the current task after the verification is passed.
11. A terminal comprising a processor adapted to implement instructions; and a storage device adapted to store a plurality of instructions, the instructions adapted to be loaded and executed by the processor to:
s1, initializing all participating nodes in the distributed system by adopting uniform random numbers, determining the task period and the initial participating node list L, and determining the updating rule of the candidate participating node list PL of each task period;
s2 the initial participating node executes and completes the initial predefined task, judges whether the current time is a periodic time, if yes, updates the candidate participating node list PL according to the updating rule, otherwise, obtains the candidate participating node list PL updated at the previous periodic time;
s3, determining the current task in the current task period, and generating the random number of the current task according to the random number of the previous task; selecting at least one participating node from a candidate participating node list PL in the current task period according to the random number of the current task, and taking the node as an executing node of the current task to achieve consensus;
the execution node determines the execution mode and the execution content of the current task, and other participating nodes in the candidate participating node list PL verify the execution mode and the execution content of the current task issued by the execution node and execute the current task after the verification is passed.
CN201910672698.4A 2019-07-24 2019-07-24 Consensus method of distributed system based on predefined execution codes Active CN110427763B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201910672698.4A CN110427763B (en) 2019-07-24 2019-07-24 Consensus method of distributed system based on predefined execution codes

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201910672698.4A CN110427763B (en) 2019-07-24 2019-07-24 Consensus method of distributed system based on predefined execution codes

Publications (2)

Publication Number Publication Date
CN110427763A CN110427763A (en) 2019-11-08
CN110427763B true CN110427763B (en) 2021-07-23

Family

ID=68412208

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201910672698.4A Active CN110427763B (en) 2019-07-24 2019-07-24 Consensus method of distributed system based on predefined execution codes

Country Status (1)

Country Link
CN (1) CN110427763B (en)

Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107333248A (en) * 2017-06-29 2017-11-07 北京鸿联九五信息产业有限公司 A kind of real-time sending method of short message and system
CN107623686A (en) * 2017-09-12 2018-01-23 深圳先进技术研究院 Block chain common recognition reaches method, apparatus, equipment and storage medium
CN108182581A (en) * 2017-12-29 2018-06-19 北京欧链科技有限公司 A kind of bookkeeping methods and device of block chain
CN108924252A (en) * 2018-07-31 2018-11-30 泰链(厦门)科技有限公司 Mitigate method, medium and the block catenary system of node storage load in block catenary system
CN109040012A (en) * 2018-06-19 2018-12-18 西安电子科技大学 A kind of data security protecting and sharing method based on block chain and system and application
CN109547530A (en) * 2018-10-17 2019-03-29 北京瑞卓喜投科技发展有限公司 Region common recognition method, system and equipment
CN109558112A (en) * 2018-11-14 2019-04-02 杭州复杂美科技有限公司 Random digit generation method, anti-cheating block catenary system, equipment and storage medium
CN109871279A (en) * 2019-03-11 2019-06-11 京东方科技集团股份有限公司 Task coordination method of knowing together and device, block catenary system, storage medium
CN109948799A (en) * 2019-04-03 2019-06-28 陕西医链区块链集团有限公司 Dynamic random forest consensus mechanism of block chain
CN110049029A (en) * 2019-04-04 2019-07-23 矩阵元技术(深圳)有限公司 Common recognition node determines method, apparatus, computer equipment and storage medium

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109146484A (en) * 2018-08-31 2019-01-04 深圳付贝科技有限公司 Common recognition verification method, digging mine machine and block catenary system based on block chain
CN109412838A (en) * 2018-09-29 2019-03-01 吴志培 Server cluster host node selection method based on hash calculating and Performance Evaluation
CN109981281B (en) * 2019-01-14 2021-11-26 北京领主科技有限公司 Method and device for determining candidate elements based on block chain proposal random consensus
CN109639837B (en) * 2019-01-31 2021-04-06 东南大学 Block chain DPoS (distributed denial of service) consensus method based on trust mechanism

Patent Citations (10)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107333248A (en) * 2017-06-29 2017-11-07 北京鸿联九五信息产业有限公司 A kind of real-time sending method of short message and system
CN107623686A (en) * 2017-09-12 2018-01-23 深圳先进技术研究院 Block chain common recognition reaches method, apparatus, equipment and storage medium
CN108182581A (en) * 2017-12-29 2018-06-19 北京欧链科技有限公司 A kind of bookkeeping methods and device of block chain
CN109040012A (en) * 2018-06-19 2018-12-18 西安电子科技大学 A kind of data security protecting and sharing method based on block chain and system and application
CN108924252A (en) * 2018-07-31 2018-11-30 泰链(厦门)科技有限公司 Mitigate method, medium and the block catenary system of node storage load in block catenary system
CN109547530A (en) * 2018-10-17 2019-03-29 北京瑞卓喜投科技发展有限公司 Region common recognition method, system and equipment
CN109558112A (en) * 2018-11-14 2019-04-02 杭州复杂美科技有限公司 Random digit generation method, anti-cheating block catenary system, equipment and storage medium
CN109871279A (en) * 2019-03-11 2019-06-11 京东方科技集团股份有限公司 Task coordination method of knowing together and device, block catenary system, storage medium
CN109948799A (en) * 2019-04-03 2019-06-28 陕西医链区块链集团有限公司 Dynamic random forest consensus mechanism of block chain
CN110049029A (en) * 2019-04-04 2019-07-23 矩阵元技术(深圳)有限公司 Common recognition node determines method, apparatus, computer equipment and storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
使用Hash函数和MAC产生伪随机数;block2016;《https://www.cnblogs.com/block2016/p/5635522.html》;20160702;第1-2页 *

Also Published As

Publication number Publication date
CN110427763A (en) 2019-11-08

Similar Documents

Publication Publication Date Title
CN107566124B (en) Hash operation-based consensus establishing method, block chain system and storage medium
Andola et al. PoEWAL: A lightweight consensus mechanism for blockchain in IoT
CN109547530B (en) Region consensus method, system and equipment
US11640322B2 (en) Configuring nodes for distributed compute tasks
CN111988203B (en) Node election method, device and storage medium
Das et al. Yoda: Enabling computationally intensive contracts on blockchains with byzantine and selfish nodes
CN110602217B (en) Block chain-based alliance management method, device, equipment and storage medium
CN112187866B (en) Novel block chain consensus method based on shared storage
CN109903178B (en) Method, device and system for determining common social contact object and computing equipment
CN112104482A (en) Consensus method based on parallel voting
Dery et al. Reaching a joint decision with minimal elicitation of voter preferences
CN110990790B (en) Data processing method and equipment
Islam et al. A comparative analysis of proof-of-authority consensus algorithms: Aura vs Clique
CN116669111A (en) Mobile edge computing task unloading method based on blockchain
CN111223227B (en) Target user screening method and device
CN114449476A (en) Block link point consensus method for safety communication in Internet of vehicles
CN113282418A (en) Model aggregation processing method and device
CN110427763B (en) Consensus method of distributed system based on predefined execution codes
Métivier et al. Analysis of fully distributed splitting and naming probabilistic procedures and applications
Dmitriev et al. Self‐Organized Criticality on Twitter: Phenomenological Theory and Empirical Investigation Based on Data Analysis Results
Müller et al. On fairness in voting consensus protocols
Diarra Choosing a consensus protocol for uses cases in distributed ledger technologies
Zhang et al. Nakamoto consensus to accelerate supervised classification algorithms for multiparty computing
CN112685769A (en) Data processing method and device of block chain and electronic equipment
CN112527898A (en) Security calculation method, device, node and storage medium

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