FIELD OF THE TECHNOLOGY

The present disclosure relates to the communications technology.

BACKGROUND OF THE DISCLOSURE

A distributed system is a computing system that is commonly used at present, and is applied to various fields such as block chains and distributed service frameworks (for example, ZooKeeper).

In a working process of the distributed system, nodes need to reach a consensus on a to-be-processed message from a client, that is, all nodes or most nodes in the distributed system confirm a received message, and then synchronously store/process the message.

For example, when the distributed system is applied to a private block chain or a federal block chain, the nodes reach, based on a consensus algorithm, a consensus on a transaction record committed by the client (that is, determine reliability of the transaction record), and store the transaction record in block chains maintained by the nodes, thereby ensuring consistency of the transaction record stored by the nodes.

A consensus algorithm used by a distributed system implemented in the related technology focuses on consensus reaching efficiency or on ensuring fault-tolerant performance in a consensus reaching process. The fault-tolerant performance means that it is ensured that most nodes can still reach a consensus when there is a faulty node or a malicious node.

For a consensus algorithm provided in the related technology for ensuring the consensus reaching efficiency, it is difficult to ensure consensus reliability due to that a faulty node and a malicious node cannot be detected.

SUMMARY

Embodiments of the present disclosure provide a distributed system and a message processing method. The distributed system includes a client and a plurality of nodes. The client includes processing circuitry that is configured to send a message including a digital signature of the client. The distributed system is in a first consensus mode for reaching a consensus on the message. The processing circuitry obtains results from a subset of the nodes that receive the message. The results have respective digital signatures of the subset of the nodes. After verifying the digital signatures of the subset of the nodes, the processing circuitry of the client determines, based on the results, whether one or more of the nodes in the distributed system is malfunctioned.

In an embodiment, the distributed system further includes the nodes. One of the nodes is configured as a leader node and remaining nodes of the nodes are configured as follower nodes. In an example, the message from the client further includes first unique information. The subset is of the follower nodes. Each of the results includes second unique information. For each of the follower nodes, the processing circuitry of the client is further configured to determine whether the respective follower node is an erroneous node based on a determination that the second unique information in the result sent by the respective follower node is different from the first unique information in the message from the client. The processing circuitry of the client determines that the respective follower node is a faulty node when a result is not received from the respective follower node. In an example, the message from the client includes a first sequence number. Each of the results includes a second sequence number. For each of the follower nodes, the processing circuitry of the client is further configured to determine that the respective follower node sends an inconsistent sequence number when the second sequence number is different from the first sequence number. The processing circuitry of the client determines that the leader node is a malicious node when a number of the follower nodes sending the inconsistent sequence numbers exceeds a threshold.

In an embodiment, the processing circuitry of the client triggers the nodes in the distributed system to switch to a second consensus mode when the client determines at least one of: the leader node is the malicious node, at least N of the follower nodes are the faulty nodes, and at least M of the follower nodes are the erroneous nodes. N and M are positive integers.

In an embodiment, after receiving the trigger from the client to switch to the second consensus mode, the processing circuitry of each of the nodes sends a hash value in a message stored by the respective node and a digital signature of the respective node to other nodes in the distributed system. The processing circuitry of the respective node receives hash values in messages from the other nodes. The processing circuitry of the respective node determines whether the hash value stored by the respective node is consistent with the hash values from the other nodes and sends a consistency confirmation to the client when the hash value stored by the respective node is determined to be consistent with the hash values from the other nodes.

In an embodiment, the processing circuitry of the client determines whether the consistency confirmation from each of the nodes is received. When the client does not receive the consistency confirmation from at least one of the nodes within a pre-determined time, the processing circuitry of the client notifies the nodes to switch to the second consensus mode. When the client receives the consistency confirmation from each of the nodes within the pre-determined time, the processing circuitry of the client notifies the nodes to switch to the first consensus mode.

In an embodiment, after receiving the trigger to switch to the second consensus mode, the processing circuitry of each of the nodes sends a hash value in a message stored by the respective node and a digital signature of the respective node to other nodes in the distributed system. The processing circuitry of the respective node receives another hash value in a message from one of the other nodes and determines whether the hash value stored by the node is consistent with the other hash value from the one of the other nodes. When the hash value of the respective node is determined to be consistent with the other hash value, the processing circuitry of the respective node sends a data confirmation to the one of the other nodes. The data confirmation includes a digital signature of the respective node and indicates that the message stored by the respective node is consistent with the message from the one of the other nodes. When the respective node receives the data confirmation from each of the other nodes, the processing circuitry of the respective node sends a data confirmation to the client.

In an embodiment, the processing circuitry of the client determines whether the message stored in the respective node is consistent with the messages stored in the other nodes based on the respective data confirmations. When each of the data confirmations is received within a pre-determined time, the processing circuitry of the client notifies the nodes to switch back to the first consensus mode and terminates switching to the second consensus mode. When at least one of the data confirmations is not received within the pre-determined time, the processing circuitry of the client notifies the nodes to switch to the second consensus mode.

In an embodiment, the processing circuitry of the leader node switches the nodes to the first consensus mode when a number of times that the nodes reach a consensus on the received message from the client in the second consensus mode exceeds a first consensus threshold of the leader node.

In an embodiment, the processing circuitry of one of the follower nodes is configured to count a number of times that a consensus is reached on the received message when receiving a notification to switch to the first consensus mode and send a switch acknowledgement to the leader node when the counted number of times exceeds a second consensus threshold of the one of the follower nodes.

Aspects of the disclosure also provide a non-transitory computer-readable storage medium storing instructions which when executed by one or more computers cause the one or more computers to perform the message processing method.

The embodiments of the present disclosure have such beneficial effects:

(1) Reliability of communication in the distributed system is ensured by using a digital signature: A digital signature is used for both parties in communication, that is, a digital signature of a message is carried when the message is sent, and reliability of the received message is ensured by verifying the digital signature.

(2) The follower nodes directly return the results to the client when receiving the message sent by the leader node, and add information such as a uniqueness field, a sequence number of the message, and a digital signature to the result, so that the client can directly determine consensus reaching between the follower nodes according to the results returned by the follower nodes, thereby efficiently detecting the abnormal node.

