Data processing method and device based on blockchain system and related equipment

By detecting abnormal heartbeats of the leader node and initiating a switchover message by non-leader nodes, the consensus unavailability problem caused by the failure of leader election in the blockchain system is solved, achieving rapid recovery and system stability, and reducing business losses.

CN115766738BActive Publication Date: 2025-12-16BEIJING TONGBANGZHUOYI TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202211184512.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2025-12-16
Estimated Expiration
2042-09-27

AI Technical Summary

Technical Problem

In blockchain networks, the failure of consensus due to leader election failure or anomalies affects system availability and stability, and is particularly difficult to recover quickly without human intervention, potentially causing business losses.

Method used

Non-leader nodes can detect abnormal heartbeat messages from the leader node, initiate a leader switch message, and trigger a re-election. This ensures that the leader node in the blockchain system sends heartbeat information according to the cycle, and that non-leader nodes can promptly detect abnormalities and initiate a leader switch, thus achieving rapid recovery.

Benefits of technology

It improves the availability and stability of the blockchain system, avoids consensus deadlock and system unavailability, and reduces business losses.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115766738B_ABST
    Figure CN115766738B_ABST
Patent Text Reader

Abstract

The present disclosure provides a data processing method and device based on a blockchain system, and electronic equipment and a computer readable storage medium, relating to the technical field of blockchain. The leader node in the blockchain system sends heartbeat information to the non-leader node of the blockchain system according to a period, and the data processing method based on the blockchain system comprises: the non-leader node determines that the heartbeat message received from the leader node is abnormal; the non-leader node initiates a leader switching message, and the leader switching message is used to indicate that the non-leader node agrees to re-election of the leader, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node. The technical scheme provided by the embodiments of the present disclosure can quickly recover the blockchain system from an abnormal state, and improve the availability and stability of the blockchain system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present disclosure relates to the technical field of blockchain, and particularly relates to a data processing method and device based on a blockchain system, an electronic device and a computer readable storage medium. BACKGROUND

[0002] In a blockchain network system (such as a consortium blockchain network system), in order to solve the trust problem between different subjects (such as different blockchain nodes), a consensus algorithm based on Byzantine fault tolerance or POW (Proof Of Work, Proof of Work) is often used.

[0003] Among them, the consensus algorithm in the blockchain technology can include a leader-driven consensus protocol. Once the leader election fails, the consensus is in a non-working state, which affects the availability of the entire blockchain network. Therefore, the robustness of the leader election is crucial.

[0004] However, in some systems, the following scenarios often occur: the remaining nodes cannot quickly perceive after the leader node hangs up, there are multiple leaders after the blockchain network recovers from partition, and some transaction message processing times out, etc., causing the blockchain system to be unavailable.

[0005] The above problems cannot be quickly recovered without human intervention, which can cause huge losses to the application of the business (such as the business in the financial field).

[0006] Therefore, how to ensure the availability and stability of the blockchain system is a technical problem to be solved by the present application. SUMMARY

[0007] The purpose of the present disclosure is to provide a data processing method and device based on a blockchain system, an electronic device and a computer readable storage medium, which can quickly recover the blockchain system from an abnormal state and improve the availability and stability of the blockchain system.

[0008] Other characteristics and advantages of the present disclosure will become apparent from the following detailed description, or will be learned by practice of the present disclosure.

[0009] The present disclosure provides a data processing method based on a blockchain system, comprising: determining, by a non-leader node, that an abnormality occurs in receiving a heartbeat message from a leader node; initiating, by the non-leader node, a leader switching message, the leader switching message being used to indicate that the non-leader node agrees to leader re-election, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0010] In some embodiments, the non-leader node determines that the receiving of the heartbeat message from the leader node is abnormal, comprising: when the heartbeat message of the leader node is not received within a preset time, the non-leader node determines that the receiving of the heartbeat message from the leader node is abnormal.

[0011] In some embodiments, the non-leader node determines that the receiving of the heartbeat message from the leader node is abnormal, comprising: when the non-leader node receives heartbeat messages sent by at least two leader nodes, the non-leader node determines that the receiving of the heartbeat message from the leader node is abnormal.

[0012] In some embodiments, the method further comprises: when the non-leader node restarts, the non-leader node sends query information to a plurality of nodes in the blockchain system, so that each node in the blockchain system returns a leader node identifier and a term identifier in response to the query information; the non-leader node receives a leader node identifier and a term identifier from the plurality of nodes in the blockchain system; the non-leader node determines a leader node identifier and a term identifier corresponding to the non-leader node according to the leader node identifiers and the term identifiers corresponding to the plurality of nodes in the blockchain system, so that the non-leader node participates in the consensus process in the blockchain system.

[0013] In some embodiments, the leader node identifiers corresponding to the plurality of nodes include a target node identifier, the target node identifier being used to represent that a first node is a leader node in the blockchain system; wherein the non-leader node determines a leader node identifier corresponding to the non-leader node according to the leader node identifiers corresponding to the plurality of nodes in the blockchain system, comprising: if it is determined that the proportion of nodes whose leader node identifier is the target node identifier in the blockchain system exceeds a first number of proportions, the leader node identifier of the non-leader node is set to the target node identifier, so that the non-leader node participates in the consensus process in the blockchain system according to the target node identifier.

[0014] In some embodiments, the term identifiers corresponding to the plurality of nodes include a target term identifier; wherein the non-leader node determines a term identifier corresponding to the non-leader node according to the term identifiers corresponding to the plurality of nodes in the blockchain system, comprising: if it is determined that the proportion of nodes whose term identifier is the target term identifier in the blockchain system exceeds a second number of proportions, the term identifier of the non-leader node is set to the target term identifier, so that the non-leader node participates in the consensus process in the blockchain system according to the target term identifier.

[0015] In some embodiments, the method further comprises: when the non-leader node determines that the transaction duration in the blockchain system is greater than a time threshold, the non-leader node initiates the leader switching message, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0016] In some embodiments, the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node, comprising: when it is determined that the proportion of non-leader nodes initiating the leader switching message exceeds a proportion threshold, the blockchain system re-performs a leader election to re-determine a leader node.

[0017] Embodiments of the present disclosure provide a data processing apparatus based on a blockchain system, comprising: an exception determination module and a leader switching message initiation module.

[0018] The exception determination module is configured to determine that receiving a heartbeat message from the leader node is abnormal, and the leader switching message initiation module is configured to initiate a leader switching message, the leader switching message being used to indicate that the non-leader node agrees to perform a leader re-election, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0019] Embodiments of the present disclosure provide an electronic device, comprising: a memory and a processor; the memory is configured to store program instructions; the processor invokes the program instructions stored in the memory, and is configured to implement the data processing method based on the blockchain system according to any one of the preceding embodiments.

[0020] Embodiments of the present disclosure provide a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the data processing method based on the blockchain system according to any one of the preceding embodiments.

[0021] Embodiments of the present disclosure provide a computer program product or a computer program, which comprises computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to make the computer device execute the data processing method based on the blockchain system.

[0022] The data processing method, device, electronic device and computer readable storage medium based on the blockchain system provided by the embodiments of the present disclosure can enable the leader node in the blockchain system to send heartbeat information to the non-leader node according to a period, so that the non-leader node in the blockchain system can perceive the abnormality of the leader node in time, and the leader node switching message for agreeing to re-election of the leader is initiated in time in the case of abnormality of the leader node. The above technical solution can enable the non-leader node in the blockchain system to perceive the abnormality of the leader node in time, and re-election of the leader node is performed in time, so as to avoid problems such as consensus deadlock of the blockchain system and unavailability of the blockchain system.

[0023] It should be understood that the foregoing general description and the following detailed description are only exemplary and are not limiting of the present disclosure. BRIEF DESCRIPTION OF DRAWINGS

[0024] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present disclosure and, together with the description, further serve to explain the principles of the present disclosure. It is to be expressly understood that the drawings are included solely for purposes of illustration and that they are not to be construed as limiting the present disclosure.

[0025] Figure 1A is a schematic diagram of an architecture of a data processing system based on a blockchain system provided by an embodiment of the present disclosure.

[0026] Figure 1B is a schematic diagram of a structure of a blockchain provided by an embodiment of the present disclosure.

[0027] Figure 1C is a schematic diagram of a process of generating a new block provided by an embodiment of the present disclosure.

[0028] Figure 2 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0029] Figure 3 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0030] Figure 4 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0031] Figure 5 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0032] Figure 6is a flow chart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0033] Figure 7 is a block diagram of a data processing apparatus based on a blockchain system according to an exemplary embodiment.

[0034] Figure 8 A structural schematic diagram of an electronic device suitable for implementing the embodiments of the present disclosure is shown. DETAILED DESCRIPTION

[0035] Example embodiments now will be described more fully hereinafter with reference to the accompanying drawings. Example embodiments, however, can be implemented in many different forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of example embodiments to those skilled in the art. Like reference numerals refer to like elements throughout the figures, and descriptions of the same or similar elements can be omitted.

[0036] The features, structures, or characteristics described in this disclosure can be combined in any suitable manner in one or more embodiments. In the following description, numerous specific details are provided to give a thorough understanding of embodiments of the disclosure. One skilled in the relevant art will recognize, however, that the techniques described herein can be practiced without one or more of the specific details, or with other methods, components, devices, steps, etc. In other instances, well-known structures, devices, implementations, or operations are not shown or described in detail to avoid obscuring aspects of the disclosure.

[0037] The accompanying drawings are included to provide a further understanding of the disclosure and are incorporated in and constitute a part of this specification, illustrate embodiments of the disclosure and together with the description serve to explain the principles of the disclosure. In the drawings:

[0038] The flow charts shown in the drawings are only exemplary and do not necessarily include all of the content and steps, nor must they be executed in the order described. For example, some steps can be further broken down, while some steps can be combined or partially combined, so the actual execution order can be changed according to the actual situation.

[0039] In the description of the present application, unless otherwise specified, " / " means "or", for example, A / B can mean A or B. "And / or" herein is only a description of the association relationship of the associated objects, which means that there can be three relationships, for example, A and / or B, which can mean: A exists alone, A and B exist together, and B exists alone. In addition, "at least one" means one or more, and "multiple" means two or more. "First", "second", and the like do not limit the quantity and execution order, and "first", "second", and the like do not necessarily mean different; the words "contain", "include" and "have" are used to mean open inclusion and mean that in addition to the listed elements / components / etc. There can be other elements / components / etc.

[0040] In order to enable more clear understanding of the above-mentioned purposes, features and advantages of the present application, the present application will be further described in detail below in combination with the drawings and specific embodiments, and it should be noted that the embodiments of the present application and the features in the embodiments can be combined with each other without conflict.

[0041] Figure 1A is a schematic diagram of an architecture of a data processing system based on a blockchain system provided by an embodiment of the present application.

[0042] Please refer to Figure 1A The data processing system based on the blockchain system includes a blockchain network 10 and a terminal device 20, wherein: the blockchain network 10 refers to a network for sharing data between nodes, and the blockchain network can include a plurality of nodes 101. Each node 101 can receive input information during normal operation and maintain shared data (i.e. blockchain) in the blockchain network based on the received input information. In order to ensure information exchange in the blockchain network, information connection can exist between each node, and peer-to-peer (P2P) communication can be achieved between any two nodes, which can be achieved through a wired communication link or a wireless communication link. For example, when any node in the blockchain network receives input information, other nodes obtain the input information according to a consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the blockchain network is consistent.

[0043] The terminal device 20 can access the blockchain network and can communicate with the nodes in the blockchain network, for example, submit a transaction to be chained to the node, obtain data from the node, etc. The terminal device 20 can be a smart phone, a tablet computer, a notebook computer, a desktop computer, a vehicle-mounted intelligent terminal, etc., and the present application does not limit the terminal device 20.

[0044] When the nodes in the blockchain network reach consensus, a leader node can be elected from the nodes in the blockchain network, and other nodes that are not elected can be referred to as non-leader nodes.

[0045] Generally, only one valid leader node exists in a blockchain network to uniformly store blocks in the blockchain network. For example, when N transactions are passed in the blockchain network, the N transactions need to be stored in a block in the blockchain. The leader node can specify the storage order of the N transactions, so that the nodes in the blockchain network store the N transactions according to the same storage data, thereby ensuring the consistency of the blockchain stored in each node. N is an integer greater than or equal to 1.

[0046] In addition, it should be noted that the election of the leader node can use different election algorithms, such as Byzantine algorithm (Byzantine Fault Tolerance, BFT), POW (Proof of Work) consensus mechanism, etc., which are not limited by the present application.

[0047] It should be noted that Figure 1A The number of nodes shown in FIG. 1 is only illustrative, and any number of nodes can be used.

[0048] Each node in the blockchain network has a corresponding node identifier, and each node in the blockchain network can store the node identifiers of other nodes in the blockchain network, so as to subsequently broadcast the generated block to other nodes in the blockchain network according to the node identifiers of the other nodes. Each node can maintain a node identifier list as shown in the following table, and store the node name and node identifier in the node identifier list. The node identifier can be an Internet Protocol (IP) address or any other information that can be used to identify the node. In Table 1, only the IP address is used as an example for illustration.

[0049] Node name Node identification Node 1 XXXXXX Node 2 XXXXXX … … Node N XXXXXX

[0050] Each node in the blockchain network stores a same blockchain. The blockchain is composed of a plurality of blocks. For details, see Figure 1BThe blockchain is composed of a plurality of blocks, the initial block includes a block header and a block body, the block header stores input information characteristic values, a version number, a timestamp and a difficulty value, and the block body stores input information; a next block of the initial block takes the initial block as a parent block, the next block also includes a block header and a block body, the block header stores input information characteristic values of the current block, a block header characteristic value of the parent block, a version number, a timestamp and a difficulty value, and the like, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.

[0051] When generating each block in the blockchain, the node where the blockchain is located verifies the input information when receiving the input information, stores the input information in the memory pool after completing the verification, and updates the hash tree used to record the input information; then, the update timestamp is updated to the time when the input information is received, and different random numbers are tried to perform characteristic value calculation multiple times, so that the calculated characteristic value can satisfy the following formula: Figure 1C

[0052] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x))<TARGET.

[0053] Wherein, SHA256 is a characteristic value algorithm used for calculating characteristic values; version (version number) is version information of a related block protocol in the blockchain; prev_hash is a block header characteristic value of the parent block of the current block; merkle_root is a characteristic value of the input information; ntime is an update time of the updated timestamp; nbits is the current difficulty, which is a constant value within a certain period of time, and is determined again after a fixed period of time; x is a random number; TARGET is a characteristic value threshold, which can be determined according to nbits.

[0054] In this way, when the random number satisfying the above formula is calculated, the information is stored correspondingly, the block header and the block body are generated, and the current block is obtained. Subsequently, the node where the blockchain is located sends the newly generated block to other nodes in the blockchain network according to the node identifiers of the other nodes in the blockchain network, and the other nodes verify the newly generated block, and add the newly generated block to the stored blockchain after completing the verification.

[0055] ​The blockchain network node can run a smart contract, which is a code implementation for execution when certain conditions are met. A developer can define contract logic through a programming language, publish it to the blockchain (smart contract registration), and trigger execution according to the logic of the contract terms, complete the contract logic, and provide functions for upgrading and canceling the smart contract.

[0056] Figure 2 FIG. 1 is a flowchart of a data processing method based on a blockchain system according to an example embodiment. The method provided by the embodiments of the present disclosure can be executed by any non-leader node in the blockchain system, which can be any electronic device with computing processing capability, such as a server or a terminal device. In the following embodiments, the non-leader node is taken as an example of a server, but the present disclosure is not limited thereto.

[0057] In some embodiments, the node that becomes a leader node in the blockchain system can send heartbeat information to other non-leader nodes in the blockchain system according to a period. The heartbeat information is used to inform other non-leader nodes in the blockchain system that the leader node is working normally.

[0058] With reference to Figure 2 The data processing method based on the blockchain system provided by the embodiments of the present disclosure can include the following steps.

[0059] In step S202, the non-leader node determines that the reception of the heartbeat message from the leader node is abnormal.

[0060] In some embodiments, the non-leader node can determine whether the process of receiving the heartbeat information from the leader node is abnormal according to whether the heartbeat information from the leader node is received or the reception time delay of the heartbeat information from the leader node.

[0061] In some embodiments, when the non-leader node does not receive the heartbeat information from the leader node within a timeout, it is considered that the reception of the heartbeat information from the leader node is abnormal.

[0062] In some embodiments, when the non-leader node receives heartbeat information from at least two leader nodes, it is considered that the reception of the heartbeat information from the leader node is abnormal.

[0063] In step S204, the non-leader node initiates a leader switching message, which is used to indicate that the non-leader node agrees to re-election of the leader, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0064] In some embodiments, once the non-leader node considers that the reception of heartbeat information from the leader node is abnormal, it considers that the current leader node is abnormal, and unilaterally initiates a leader switching message to indicate that the non-leader node agrees to re-election of the leader.

[0065] In some embodiments, when it is determined that the proportion of non-leader nodes initiating the leader switching message exceeds the proportion threshold, the blockchain system re-elections the leader to re-determine the leader node. For example, when at least two-thirds of the non-leader nodes in the blockchain system agree to re-election of the leader, it is considered that the current leader node is abnormal and cannot provide normal services for the blockchain system, and then the blockchain system re-elections the leader node.

[0066] The above-mentioned embodiments provide a technical solution that enables the leader node in the blockchain system to periodically send heartbeat information to the non-leader node, so that the non-leader node in the blockchain system can timely perceive the abnormality of the leader node and timely agree to re-election of the leader in the case of abnormality of the leader node. The above-mentioned technical solution enables the non-leader node in the blockchain system to timely perceive the abnormality of the leader node and timely re-election of the leader node, so that the majority of nodes can quickly converge to a consistent and available state, ensuring the stability and availability of the blockchain system, thereby avoiding consensus deadlock of the blockchain system, unavailability of the blockchain system, etc.

[0067] The above-mentioned embodiments have covered the processing solutions for heartbeat loss and heartbeat conflict, provided a fast recovery mechanism for the blockchain in an abnormal state, enabled each node to quickly recover to a consistent and available state together, ensured the availability, stability, and fast recovery from abnormality of the blockchain system, thereby avoiding consensus deadlock, unavailability of the blockchain system, etc., and reducing the loss caused to actual business (such as financial business using the blockchain for storage).

[0068] Figure 3 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0069] Reference Figure 3 The above-mentioned data processing method based on the blockchain system can include the following steps.

[0070] Step S302: When the heartbeat information of the leader node is not received within a predetermined time, the non-leader node determines that the reception of heartbeat information from the leader node is abnormal.

[0071] Step S304, the non-leader node initiates a leader switching message, and the leader switching message is used to indicate that the non-leader node agrees to perform leader re-election, so that the blockchain system performs leader switching operation according to the leader switching message initiated by the non-leader node.

[0072] For the consensus network of the blockchain system, the consensus nodes can be divided into two types of nodes, Leader (leader node) and non-Leader (non-leader node). The Leader node periodically sends a heartbeat message to the consensus network to prove that its network communication function is normal and the node is in a live state. The non-Leader node periodically detects whether the heartbeat message is received. If the heartbeat message is not received within a configured time, the node considers that the Leader has abnormal behavior and will unilaterally initiate a message agreeing to trigger the leader re-election process. This scheme helps to discover the abnormality of the Leader node in a timely manner and reduces the loss caused by the consensus deadlock of the blockchain system to the actual business.

[0073] The above embodiment provides a fast recovery mechanism for the blockchain system in an abnormal state when the heartbeat of the leader node is lost, ensures the availability and stability of the blockchain system, enables the majority of nodes to quickly converge to a consistent and available state, thereby avoiding the problems of consensus deadlock and unavailability of the blockchain system, and improves the stability of the blockchain system.

[0074] Figure 4 is a flowchart of a data processing method based on a blockchain system according to an exemplary embodiment.

[0075] Reference Figure 4 The above data processing method based on the blockchain system can include the following steps.

[0076] Step S402, when the non-leader node receives heartbeat messages sent by at least two leader nodes, the non-leader node determines that the reception of the heartbeat message from the leader node is abnormal.

[0077] Step S404, the non-leader node initiates a leader switching message, and the leader switching message is used to indicate that the non-leader node agrees to perform leader re-election, so that the blockchain system performs leader switching operation according to the leader switching message initiated by the non-leader node.

[0078] In a poor network environment, the blockchain system is prone to network partitioning. After partitioning, nodes in the same partition may reselect a new node as the leader node. That is, in a poor network environment, nodes in a blockchain system may not be able to communicate directly, and nodes that can communicate with each other may select a leader node together. After the network environment recovers, there will be multiple leader nodes sending heartbeat messages regularly, and non-leader nodes may receive heartbeat messages from multiple leaders.

[0079] For example, an initial blockchain system can include five nodes A, B, C, D, and E, where node A is the leader node in the blockchain system. When the network between the nodes in the blockchain system fails, the nodes in the blockchain system can be partitioned, nodes A, B, and C can communicate with each other, and nodes D and E can communicate with each other. Thus, D and E will reselect the leader node so that node D becomes the leader node. Once the network in the blockchain system recovers, there will be two leader nodes in the blockchain system sending heartbeat messages.

[0080] When there are multiple leader nodes in the blockchain network system, the blockchain network system will be in a consensus deadlock and cannot work normally.

[0081] To solve the above problems, the non-leader node in the embodiment unilaterally initiates a leader switch message when it receives heartbeat messages from at least two leader nodes, indicating that the non-leader node agrees to reselect the leader.

[0082] In some embodiments, when it is determined that the proportion of non-leader nodes that initiate leader switch messages exceeds a proportion threshold, the blockchain system reselects the leader to reselect the leader node. For example, when at least two-thirds of the nodes in the blockchain system agree to reselect the leader, it can be considered that the current leader node has an abnormality and cannot provide normal services for the blockchain system, and thus the leader node can be reselected.

[0083] The technical solutions provided by the above embodiments can enable the leader nodes in the blockchain system to send heartbeat information to the non-leader nodes according to a period, so that the non-leader nodes in the blockchain system can perceive the abnormality of the plurality of leader nodes in time, and agree to re-election of the leader in time in the case of abnormality of the leader node. The above technical solutions can enable the non-leader nodes in the blockchain system to perceive the abnormality of the leader node in time, and re-elect the leader node in time, so that the majority of nodes can quickly converge to a consistent available state, guaranteeing the stability and availability of the blockchain system, thereby avoiding consensus deadlock of the blockchain system, unavailability of the blockchain system, and the like.

[0084] The above technical solutions can solve the leader conflict problem, provide a fast recovery mechanism for the blockchain in an abnormal state, enable all nodes to recover to a consistent available state at the fastest speed, guarantee the availability and stability of the blockchain system, thereby avoiding consensus deadlock of the blockchain system, unavailability of the blockchain system, and the like, and reducing the loss caused to actual business (such as a financial business using the blockchain for storage).

[0085] Figure 5 FIG. 1 is a flowchart of a data processing method based on a blockchain system according to an example embodiment.

[0086] Reference Figure 5 The above data processing method based on the blockchain system can include the following steps.

[0087] In step S502, when the non-leader node is restarted, the non-leader node sends query information to a plurality of nodes in the blockchain system, so that each node in the blockchain system returns a leader node identifier and a term identifier in response to the query information.

[0088] The leader node identifier in the node is used to indicate who is the leader node approved by the node. If the leader node identifier in a certain node is the first node identifier, it indicates that the node approves the first node as the leader node.

[0089] The term identifier in the node is used to indicate how many times the node participates in the election process of the leader node. The term identifier of the node changes once every time the node participates in the election of the leader node.

[0090] The election of the leader node is closely related to the term identifier of the node. For example, when the nodes in the blockchain system perform the election of the leader node, only the election information of the node whose leader node identifier and term identifier are the same as those of the node itself is received and approved.

[0091] In some embodiments, when a node in the blockchain system is restarted, the leader node identifier and the term identifier in the node are initialized, so that the leader node identifier and the term identifier of the node are different from the leader node identifiers and the term identifiers of other nodes in the blockchain system, so that the node cannot participate in the consensus process in the blockchain system.

[0092] Therefore, when a node in the blockchain system is restarted, the node sends query information to multiple nodes in the blockchain system to query the leader node identifier and the term identifier currently corresponding to the blockchain system from other nodes.

[0093] Step S504, the non-leader node receives the leader node identifier and the term identifier from multiple nodes of the blockchain system.

[0094] Step S506, the non-leader node determines the leader node identifier and the term identifier corresponding to the non-leader node according to the leader node identifiers and the term identifiers corresponding to multiple nodes of the blockchain system, so that the non-leader node participates in the consensus process in the blockchain system.

[0095] In some embodiments, the leader node identifiers corresponding to multiple nodes in the blockchain system can include a target node identifier, which is used to indicate that the first node is a leader node in the blockchain system. Then, the non-leader node determines the leader node identifier corresponding to the non-leader node according to the leader node identifiers corresponding to multiple nodes of the blockchain system can include the following process: if it is determined that the proportion of nodes with the leader node identifier as the target node identifier exceeds a first proportion in the blockchain system, the leader node identifier of the non-leader node is set to the target node identifier, so that the non-leader node participates in the consensus process in the blockchain system according to the target node identifier.

[0096] In some embodiments, the term identifiers corresponding to multiple nodes in the blockchain system can include a target term identifier. Then, the non-leader node determines the term identifier corresponding to the non-leader node according to the term identifiers corresponding to multiple nodes of the blockchain system can include the following process: if it is determined that the proportion of nodes with the term identifier as the target term identifier exceeds a second proportion in the blockchain system, the term identifier of the non-leader node is set to the target term identifier, so that the non-leader node participates in the consensus process in the blockchain system according to the target term identifier.

[0097] In some embodiments, when any number of consensus nodes in the blockchain system restarts, the leader node and the regency state may be differentiated, and the embodiment adds a query negotiation mechanism for the leader and the regency when the node starts to ensure that the leader node identifier and the regency identifier after the node restart are consistent with other nodes in the blockchain system.

[0098] The embodiment solves the problem of leader regency conflict, provides a fast recovery mechanism in an abnormal state for the blockchain, ensures the availability, stability and fast recovery of the blockchain system, thereby avoiding the consensus deadlock similar to PBFT and the unavailability of the blockchain system.

[0099] Figure 6 is a flowchart of a blockchain system-based data processing method according to an exemplary embodiment.

[0100] Reference Figure 6 The blockchain system-based data processing method described above can include the following steps.

[0101] Step S602, when the non-leader node determines that the transaction duration in the blockchain system is greater than the time threshold, the non-leader node initiates a leader switching message.

[0102] Step S604, when it is determined that the proportion of the non-leader node initiating the leader switching message exceeds the proportion threshold, the blockchain system re-performs leader election to re-determine the leader node.

[0103] In some embodiments, when it is determined that the proportion of the non-leader node initiating the leader switching message exceeds the proportion threshold, the blockchain system re-performs leader election to re-determine the leader node, and clears the intermediate state of the uncompleted transaction, so that the newly elected leader node re-performs consensus processing on the transaction.

[0104] The technical solution provided by the above embodiment adds a timeout processing mechanism for transaction processing, avoids the situation that a malicious node intentionally creates a contract with excessively long stack depth or a transaction with excessively large content, or the situation that the consensus process cannot be completed for a long time due to network reasons or the leader node is malicious, thereby affecting the processing of normal user transactions by the entire blockchain network. When this scenario occurs, the heartbeat mechanism cannot be relied on for detection because the heartbeat mechanism is normally operating and cannot perceive that the consensus process has not been completed for a long time. The timeout processing of the user business message can trigger the leader switching process, and the leader switching process can clear the intermediate state of the consensus, so that the blockchain network recovers the processing of normal transaction messages.

[0105] The embodiment solves the problem of transaction message timeout, provides a fast recovery mechanism in an abnormal state for the blockchain, guarantees the availability, stability and fast recovery in an abnormal state of the blockchain system, and avoids the consensus deadlock similar to PBFT and the problem of unavailability of the blockchain system.

[0106] Based on the same inventive concept, the embodiment of the present disclosure further provides a data processing device based on a blockchain system, as follows. Since the principle of solving problems of the device embodiment is similar to the above-mentioned method embodiment, the implementation of the device embodiment can be referred to the implementation of the above-mentioned method embodiment, and the repeated parts will not be described here.

[0107] Figure 7 is a block diagram of a data processing device based on a blockchain system according to an exemplary embodiment. Referring to Figure 7 , the data processing device 700 based on the blockchain system provided by the embodiment of the present disclosure can include an exception determination module 701 and a leader switching message initiation module 702.

[0108] The exception determination module 701 can be configured to determine that the receiving of the heartbeat message from the leader node is abnormal; and the leader switching message initiation module 702 can be configured to initiate a leader switching message, the leader switching message being used to indicate that the non-leader node agrees to perform leader re-election, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0109] It should be noted that the above-mentioned exception determination module 701 and leader switching message initiation module 702 correspond to S202-S204 in the method embodiment, and the above-mentioned modules have the same examples and application scenarios as the corresponding steps, but are not limited to the contents disclosed in the above-mentioned method embodiment. It should be noted that the above-mentioned modules as part of the device can be executed in a computer system such as a group of computer executable instructions.

[0110] In some embodiments, the exception determination module 701 can include a timeout determination unit.

[0111] The timeout determination unit can be configured to determine that the receiving of the heartbeat message from the leader node is abnormal when the non-leader node does not receive the heartbeat information of the leader node within a preset time.

[0112] In some embodiments, the exception determination module 701 can include a plurality of heartbeat determination units.

[0113] The plurality of heartbeat determination units can be configured to determine that the receiving of the heartbeat message from the leader node is abnormal when the non-leader node receives at least two heartbeat messages sent by the leader node.

[0114] In some embodiments, the data processing apparatus based on the blockchain system can further include: a query information sending unit, an identifier receiving unit and an identifier setting unit.

[0115] The query information sending unit can be configured to send, by the non-leader node, query information to a plurality of nodes in the blockchain system when the non-leader node is restarted, so that each node in the blockchain system returns a leader node identifier and a term identifier in response to the query information; the identifier receiving unit can be configured to receive, by the non-leader node, the leader node identifier and the term identifier from the plurality of nodes in the blockchain system; and the identifier setting unit can be configured to determine, by the non-leader node, a leader node identifier and a term identifier corresponding to the non-leader node according to the leader node identifiers and the term identifiers corresponding to the plurality of nodes in the blockchain system, so that the non-leader node participates in a consensus process in the blockchain system.

[0116] In some embodiments, the leader node identifiers corresponding to the plurality of nodes include a target node identifier, the target node identifier being used to indicate that the first node is a leader node in the blockchain system; and the identifier setting unit can include a first proportion determining sub-unit.

[0117] The first proportion determining sub-unit can be configured to set the leader node identifier of the non-leader node as the target node identifier if it is determined that a proportion of nodes whose leader node identifier is the target node identifier in the blockchain system exceeds a first number of proportions, so that the non-leader node participates in the consensus process in the blockchain system according to the target node identifier.

[0118] In some embodiments, the term identifiers corresponding to the plurality of nodes include a target term identifier; and the identifier setting unit can include a second proportion determining sub-unit.

[0119] The second proportion determining sub-unit can be configured to set the term identifier of the non-leader node as the target term identifier if it is determined that a proportion of nodes whose term identifier is the target term identifier in the blockchain system exceeds a second number of proportions, so that the non-leader node participates in the consensus process in the blockchain system according to the target term identifier.

[0120] In some embodiments, the data processing apparatus based on the blockchain system can further include a duration judgment module.

[0121] The duration judgment module can be configured to initiate, by the non-leader node, a leader switching message when it is determined that a transaction duration in the blockchain system is greater than a time threshold, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

[0122] In some embodiments, the leader switching operation of the blockchain system according to the leader switching message initiated by the non-leader node can comprise: when it is determined that the proportion of the non-leader node initiating the leader switching message exceeds the proportion threshold, the blockchain system re-performs the leader election to re-determine the leader node.

[0123] Since the functions of the apparatus 700 have been described in detail in the corresponding method embodiments, the present disclosure will not be described here again.

[0124] The modules and / or units and / or sub-units described in the embodiments of the present application can be implemented by software or by hardware. The described modules and / or units and / or sub-units can also be arranged in a processor. In some cases, the names of these modules and / or units and / or sub-units do not constitute a limitation on the modules and / or units and / or sub-units themselves.

[0125] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code containing one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than those noted in the accompanying drawings. For example, two blocks represented in succession can actually be executed in parallel, and sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams or flowcharts, and the combination of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0126] In addition, the above-described accompanying drawings are only schematic illustrations of the processes included in the method according to the exemplary embodiments of the present disclosure, and are not for limiting purposes. It is readily understood that the processes shown in the above-described accompanying drawings do not indicate or limit the time sequence of these processes. In addition, it is readily understood that these processes can be executed synchronously or asynchronously, for example, in multiple modules.

[0127] Figure 8 A structural schematic diagram of an electronic device suitable for implementing the embodiments of the present disclosure is shown. It should be noted that, Figure 8 The electronic device 800 shown is only an example, and should not limit the functions and use range of the embodiments of the present disclosure.

[0128] As Figure 8As shown, the electronic device 800 includes a central processing unit (CPU) 801 which can perform various appropriate actions and processes in accordance with a program stored in a read only memory (ROM) 802 or a program loaded into a random access memory (RAM) 803 from a storage section 808. In the RAM 803, various programs and data required for the operation of the electronic device 800 are also stored. The CPU 801, the ROM 802, and the RAM 803 are connected to each other through a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0129] Connected to the I / O interface 805 are an input section 806 including a keyboard, a mouse, etc.; an output section 807 including a display such as a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as necessary. A removable recording medium 811 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 810 as necessary, so that a computer program read therefrom is installed into the storage section 808 as necessary.

[0130] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program in accordance with embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program carried on a computer-readable storage medium, the computer program containing program code for executing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication section 809, and / or installed from the removable recording medium 811. When the computer program is executed by the central processing unit (CPU) 801, the above-described functions defined in the system of the present application are performed.

[0131] It should be noted that the computer-readable storage medium shown in the present disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of computer-readable storage media can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable storage medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained on the computer-readable storage medium can be transmitted by any suitable medium, including but not limited to wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0132] As another aspect, the present application also provides a computer-readable storage medium, which can be contained in the device described in the above embodiments; or can exist independently without being assembled into the device. The above computer-readable storage medium carries one or more programs, when the one or more programs are executed by the device, the device can realize functions including: the non-leader node determines that the heartbeat message received from the leader node is abnormal; the non-leader node initiates a leader switching message, the leader switching message is used to indicate that the non-leader node agrees to leader re-election, so that the blockchain system performs leader switching operation according to the leader switching message initiated by the non-leader node.

[0133] According to an aspect of the present application, a computer program product or computer program is provided, which includes computer instructions stored in a computer readable storage medium. A processor of a computer device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions, so that the computer device performs the method provided in various optional implementations of the above-mentioned embodiments.

[0134] Through the above description of the embodiments, those skilled in the art can easily understand that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions of the embodiments of the present disclosure can be embodied in the form of a software product. The software product can be stored in a non-volatile storage medium (which can be a CD-ROM, U disk, mobile hard disk, etc.), and includes a number of instructions to make a computing device (which can be a personal computer, a server, a mobile terminal, or a smart device, etc.) execute the steps shown in the method according to the embodiments of the present disclosure, for example Figures 2-6 one or more steps.

[0135] Those skilled in the art will readily understand other embodiments of the present disclosure after considering the specification and practicing the disclosure disclosed herein. The present disclosure is intended to cover any variations, uses, or adaptive changes of the present disclosure that follow the general principles of the present disclosure and include common knowledge or conventional technical means in the technical field of the present disclosure that are not claimed by the present disclosure. The specification and embodiments are only considered as exemplary, and the true scope and spirit of the present disclosure are indicated by the claims.

[0136] It should be understood that the present disclosure is not limited to the detailed structure, drawing manner or implementation method shown herein, but rather, the present disclosure is intended to cover various modifications and equivalent arrangements included in the spirit and scope of the appended claims.

Claims

1. A data processing method based on a blockchain system, characterized in that, A leader node in a blockchain system sends heartbeat information to non-leader nodes of the blockchain system according to a period, including: The non-leader node determines that heartbeat messages received from the leader node are abnormal; The non-leader node initiates a leader switching message, the leader switching message being used to indicate that the non-leader node agrees to leader re-election, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node; The method further includes: When the non-leader node is restarted, the non-leader node sends query information to a plurality of nodes in the blockchain system, so that each node in the blockchain system returns a leader node identifier and a term identifier in response to the query information; The non-leader node receives a leader node identifier and a term identifier from the plurality of nodes of the blockchain system; The non-leader node determines a leader node identifier and a term identifier corresponding to the non-leader node according to the leader node identifiers and the term identifiers corresponding to the plurality of nodes of the blockchain system, so that the non-leader node participates in a consensus process in the blockchain system.

2. The method of claim 1, wherein, The non-leader node determines that heartbeat messages received from the leader node are abnormal, including: When heartbeat information of the leader node is not received within a preset time, the non-leader node determines that heartbeat messages received from the leader node are abnormal.

3. The method of claim 1, wherein, The non-leader node determines that heartbeat messages received from the leader node are abnormal, including: When the non-leader node receives heartbeat messages sent by at least two leader nodes, the non-leader node determines that heartbeat messages received from the leader node are abnormal.

4. The method of claim 1, wherein, The leader node identifiers corresponding to the plurality of nodes include a target node identifier, the target node identifier being used to indicate that a first node is a leader node in the blockchain system; wherein the non-leader node determines a leader node identifier corresponding to the non-leader node according to the leader node identifiers corresponding to the plurality of nodes of the blockchain system, including: If it is determined that a proportion of nodes with a leader node identifier being the target node identifier exceeds a first number proportion in the blockchain system, a leader node identifier of the non-leader node is set to the target node identifier, so that the non-leader node participates in a consensus process in the blockchain system according to the target node identifier.

5. The method of claim 1, wherein, The term identifiers corresponding to the plurality of nodes include a target term identifier; wherein the non-leader node determines a term identifier corresponding to the non-leader node according to the term identifiers corresponding to the plurality of nodes of the blockchain system, including: If it is determined that a proportion of nodes with a term identifier being the target term identifier exceeds a second number proportion in the blockchain system, a term identifier of the non-leader node is set to the target term identifier, so that the non-leader node participates in a consensus process in the blockchain system according to the target term identifier.

6. The method of claim 1, wherein, The method further includes: When the non-leader node determines that the transaction duration in the blockchain system is greater than a time threshold, the non-leader node initiates the leader switching message, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node.

7. The method of claim 1 or 6, wherein, The blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node, comprising: When it is determined that the proportion of non-leader nodes initiating the leader switching message exceeds a proportion threshold, the blockchain system re-performs a leader election to re-determine a leader node. 8.A data processing apparatus based on a blockchain system, characterized by comprising: The blockchain system based data processing device is arranged in a non-leader node of a blockchain system, a leader node in the blockchain system sends heartbeat information to non-leader nodes of the blockchain system according to a period, and the blockchain system based data processing device comprises: An exception determination module is configured to determine that an exception occurs in receiving heartbeat messages from the leader node; A leader switching message initiation module is configured to initiate a leader switching message, the leader switching message being used to indicate that the non-leader node agrees to perform a leader re-election, so that the blockchain system performs a leader switching operation according to the leader switching message initiated by the non-leader node; A query information sending unit is configured to send query information to a plurality of nodes in the blockchain system when the non-leader node is restarted, so that each node in the blockchain system returns a leader node identifier and a ruling period identifier in response to the query information; An identifier receiving unit is configured to receive a leader node identifier and a ruling period identifier from the plurality of nodes of the blockchain system; An identifier setting unit is configured to determine a leader node identifier and a ruling period identifier corresponding to the non-leader node according to the leader node identifiers and the ruling period identifiers corresponding to the plurality of nodes of the blockchain system, so that the non-leader node participates in a consensus process in the blockchain system.

9. An electronic device, comprising: Comprise: a memory; and a processor coupled to the memory, the processor being used to execute a blockchain system based data processing method according to any one of claims 1-7 based on instructions stored in the memory.

10. A computer readable storage medium having program instructions stored thereon, the program instructions being executed by a processor to implement a blockchain system based data processing method according to any one of claims 1-7.

Citation Information

Patent Citations

  • A method for applying an Ethernet workshop consensus mechanism of improved PBFT to an alliance chain

    CN109784916A

  • Node synchronization method, device and equipment of block chain and storage medium

    CN111586147A

  • Block chain-based post-transaction data processing method and apparatus, and computer device

    CN111861477A

  • Distributed election method, device and system and medium

    CN113760468A

  • Blockchain node synchronization method, apparatus and device, and storage medium

    WO2021217849A1