An improved method of Raft consensus algorithm based on UTXO

By introducing UTXO technology, the leader election and log replication processes of the Raft consensus algorithm are improved, solving the security problem of the Raft algorithm in malicious node environments and enabling efficient operation on low-computing-power devices, thereby improving the algorithm's security and computing resource utilization.

CN117812084BActive Publication Date: 2026-11-27GUANGXI PUBLIC INFORMATION IND CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311397296.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-10-26
Publication Date
2026-11-27
Estimated Expiration
2043-10-26

AI Technical Summary

Technical Problem

The Raft consensus algorithm poses security risks in distributed systems with malicious nodes, cannot effectively counter the exploitation of malicious nodes, and has high computational performance requirements when deployed on low-computing-power devices, failing to maximize the utilization of network computing resources.

Method used

By introducing UTXO technology, a node behavior evaluation system is built by recording the weight of node behavior and using UTXO. This adds a verification step to the leader node election and log replication process, including data integrity and UTXO verification of voting requests, log distribution, packaging-forwarding and forwarding verification-reward/penalty steps, thereby improving security and versatility.

Benefits of technology

It improves the security and computational resource utilization of the Raft algorithm in public blockchain environments, enables deployment on low-computing-power devices, reduces computational resource consumption, and enhances the utilization of edge devices.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117812084B_ABST
    Figure CN117812084B_ABST
Patent Text Reader

Abstract

The application discloses an improved method of Raft consensus algorithm based on UTXO, which comprises an improvement of leader node election based on UTXO and an improvement of log replication; the improvement of the leader node election comprises adding voting request content in the link of initiating a voting request by a candidate node and adding a series of checking links in the link of voting for the candidate node by a follower node; the improvement of the log replication comprises adding a log distribution link in the starting link of the log replication process, adding a log packaging-forwarding link after the log distribution link, and adding a log forwarding checking-node reward and punishment link after the log packaging-forwarding link. Based on the problem that the Raft algorithm cannot cope with the malpractice, the application adds a coping scheme for the malpractice of the node, so that the Raft algorithm has the feasibility when being applied to a distributed system containing the malpractice node.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of blockchain technology, specifically relating to an improved method for the Raft consensus algorithm based on UTXO. Background Technology

[0002] UTXOs (Unspent Transaction Outputs) are unspent transaction outputs and a core concept in blockchain transactions. Only UTXOs can participate in transactions, and UTXOs are generated based on UTXOs from previous blocks. Therefore, the entire UTXO-based transaction system will not encounter any problems. Consequently, no party needs to retrieve the other party's entire historical transaction record for verification. Transaction participants and verifiers only need to store and verify UTXOs. This design greatly reduces the storage and computational burden caused by storing and calculating historical transaction data.

[0003] The Raft algorithm, proposed in 2014 by Stanford professor John Ousterhunt, is a consensus algorithm widely used in distributed systems due to its strong advantages in fault tolerance and efficiency. However, because Raft is based on a simplified version of the Byzantine Generals Problem, it assumes all nodes in the distributed system are benevolent. Therefore, Raft can only handle node failures in a distributed system. In distributed systems with malicious nodes, Raft is at risk of being exploited, leading to the collapse of the entire distributed system's trust structure. Real-world public blockchain applications are essentially distributed systems containing malicious nodes, and these systems have high requirements for both security and efficiency. Therefore, if the Raft algorithm can be improved to include mechanisms to deal with malicious nodes while maintaining its current efficiency, thus enhancing security, it can be applied to public blockchain-level blockchain applications.

[0004] The following section will explain the Raft algorithm and related terminology to facilitate understanding of subsequent improvement schemes.

[0005] First, it is necessary to clarify the three states of a node in the Raft algorithm:

[0006] 1. Follower Node: The most common node state in a network. It is responsible for receiving log synchronization instructions from the leader node and passively maintaining data consistency in the network. It does not actively establish connections with data source clients. When it receives a vote request from a candidate node, it returns voting feedback or rejects the vote request based on the request content.

[0007] 2. Candidate Node: An intermediate state between the follower node and the leader node state. After initiating a voting request, it will change to either the follower node or the leader node state depending on the voting results.

[0008] 3. Leader Node: There can only be 0 or 1 leader node in the network. As the data receiver, it is responsible for receiving the data that clients need to write to the network, broadcasting the data to all nodes, and feeding back the data writing results to the clients based on the feedback from each node. Under special circumstances, the leader node may directly transform into a follower node state.

[0009] Secondly, it is necessary to clarify the two important functional components that each node has:

[0010] 1. Election Timeout: Used to count down to a potential election. The election timeout is usually random and ranges from 150ms to 300ms.

[0011] 2. Term Counter: Used to record the highest term (Term) held by a candidate node or leader node in the network.

[0012] Finally, it needs to be clarified that during the operation of the Raft algorithm, each node performs two main activities:

[0013] 1. Leader Election

[0014] When the Raft algorithm is applied to a distributed system, a node is needed to fulfill the responsibilities of a leader node in order to maintain the normal operation of the entire network. After the leader node election process is completed, a unique leader node will be generated in the network to lead the network's log replication process.

[0015] The leader election process of the Raft algorithm is explained based on the above basic concepts.

[0016] Step 0: Assume there are 5 nodes in the distributed system. Initially, all nodes are in the follower state, and the election timer starts counting down after a random count is generated. (The letters F / C / L represent the three node states, and the numbers in the upper right corner indicate the current term counter size for each node).

[0017] Step 1: When a node's election timer times out, the node's state changes from a follower node to a candidate node, and the leader node election process begins. The specific steps are as follows:

[0018] Step 1-1: Term counter for the auto-incrementing node;

[0019] Step 1-2: Broadcast the voting request to other nodes in the network;

[0020] Step 1-3: After receiving the voting request, the other nodes in the network first verify the relationship between the term count attached to the voting request and the term count counter of their own node. If the term count counter of their own node is less than the term count attached to the voting request, proceed to step 1-4-1. If the term count counter of their own node is greater than or equal to the term count attached to the voting request, proceed to step 1-4-2.

[0021] At this point, the branching situation is generated based on the verification results:

[0022] Step 1-4-1: Update the term counter of this node to match the term number in the request, return voting feedback, and reset the election timer of this node;

[0023] Step 1-4-2: Reject the vote request;

[0024] Step 2: This step is a branch of Step 1:

[0025] If the election timer times out again while a candidate node is collecting vote requests, the node continues to maintain its candidate node state and repeats steps 1-1 and 1-2 until the conditions for changing other states are met.

[0026] Step 3: This step is a branch of Step 1:

[0027] When a candidate node receives votes from a majority of nodes in the network (the number of votes is half the total number of nodes in the network plus one, i.e., N / 2+1, where N is the total number of nodes in the network), the candidate node becomes the leader node.

[0028] Step 3-1: The leader node will maintain a new leader node timer (the timeout period is usually less than one-third of the minimum timeout period of the election timer). Whenever the leader node timer times out, it will send a heartbeat signal to all other nodes.

[0029] Step 3-2: Upon receiving the heartbeat signal, all nodes will reset their election timer to remain in the follower node state. This completes the normal leader node election process. The process continues until the leader node fails (network failure or node failure preventing the heartbeat signal from reaching the follower nodes). In this case, the follower node whose election timer expires first will repeat the above process to initiate an election.

[0030] Step 4: This step addresses a special situation that may occur during online activities:

[0031] If, during the process of collecting vote requests, a candidate node receives a heartbeat signal from a leader node with the same or higher term (this usually occurs when another candidate node completes the election process and becomes the leader node before this node) or a vote request from a candidate node with a higher term (this usually occurs when another candidate node's election timer times out almost simultaneously with this node, and neither node receives vote feedback from a majority of nodes in the network due to splitting votes or network fluctuations, causing the other candidate node to trigger step 2), the candidate node will directly change its state to follower node state and synchronously update its term counter.

[0032] Step 5: This step addresses a special situation that may occur during online activities:

[0033] If, while continuously sending heartbeat signals, the leader node receives a heartbeat signal from a leader node with a higher term (this usually occurs when a follower node fails to receive a heartbeat signal from the leader node multiple times due to network fluctuations, triggering step 1 and completing step 3), the leader node will directly change its state to follower node state and synchronously update its term counter.

[0034] 2. Log Replication

[0035] The Raft algorithm ensures data consistency among different nodes in a distributed system through a log replication process. After this process is complete, requests sent by clients to any node in the system will return identical data. Even if the leader node fails, the newly elected leader node can continue to fulfill its leadership responsibilities based on the previously retained correct data.

[0036] The log replication process of the Raft algorithm is explained based on the above basic concepts.

[0037] Step 0: Assume there are 5 nodes in the distributed system, including one leader node and four follower nodes. Initially, the log entries of each node are empty.

[0038] Step 1: The client sends a data write request to the distributed system. After receiving the request, the leader node first writes the data to the local log. At this time, the data is still in an uncommitted state (indicated in red).

[0039] Step 2: The leader node sends an append entry request to all follower nodes. After receiving the request, the follower nodes first write the data to their local logs. At this time, the data is also in an unconfirmed state.

[0040] Step 3: Includes: Step 3-1: After verifying the written data and confirming that it does not conflict with the local entry, the follower node sends additional feedback to the leader node;

[0041] Step 3-2: After receiving additional feedback from a majority of nodes, the leader node changes the data status to Committed (indicated in black) and simultaneously sends a message to the client that the data writing is complete.

[0042] Step 4: The leader node sends an append entry request to all follower nodes again. Upon receiving the request, each follower node changes the data status in its local log to an acknowledgement status. At this point, the log replication process is complete, and all nodes hold consistent data.

[0043] A review and analysis of existing literature reveals several proposed modifications to the Raft algorithm. Reference 1 (application number: 201811186202.4) proposes a double-verification scheme for the leader node's identity and the correctness of the block submission request when the leader node initiates a block commit request after the leader node election is complete. However, this verification method is overly simplistic and does not optimize the leader node election or log replication processes, and it still carries the risk of malicious nodes being elected as leaders. Reference 2 (application number: 202011613735.3) proposes a method to calculate the voting weight coefficient of candidate nodes based on historical node behavior data and then votes on all candidate nodes according to their weight. This scheme only optimizes the leader node election process and does not address malicious behavior in the log replication process. Reference 3 (Application No.: 202210609471.7) proposes a further improvement based on References 1 and 2. It analyzes the historical behavior of nodes, normalizes the analyzed data, and calculates weighted indicators for various behaviors to give a comprehensive score for each node. This score will be used for leader node election ranking and the pre-packaging of high-confidence blocks in the log replication process. This scheme cannot punish malicious nodes; it only reduces the probability of malicious nodes being elected as leader nodes after scoring them. Furthermore, the node scoring calculation requires supervisory nodes to operate, and in the case of a public blockchain, there is a possibility that malicious nodes could become supervisory nodes, thus still posing a risk of collapse of the distributed system's credit system. Additionally, the complex evaluation calculation process reduces the algorithm's efficiency to some extent. Moreover, it places certain demands on the computing performance of nodes in the distributed system; therefore, this improved scheme cannot incorporate edge devices with poor computing performance into the distributed system, thus failing to maximize the utilization of network computing resources. Summary of the Invention

[0044] The purpose of this invention is to address the shortcomings of existing technologies by proposing an improved Raft consensus algorithm based on UTXO. This invention introduces UTXO technology to convert a node's historical behaviors, such as confirming block content and forwarding transaction requests, into equivalent weights in a deterministic manner. These weight-related transaction information is recorded using UTXOs and stored in the blockchain. Finally, the weights in the UTXOs form a node behavior evaluation system to constrain malicious behavior. Each node stores all block data on the chain. When electing a leader node or submitting transaction requests, each node needs to stake its current UTXOs as a confidence level. For malicious behavior, such as submitting false transaction requests, the leader node will reclaim the malicious node's UTXOs and broadcast this penalty across the network, significantly increasing the cost of malicious behavior and thus improving the security of the Raft algorithm. Furthermore, leveraging the low computational resource consumption of UTXOs during generation and verification, nodes in the distributed system can be deployed to various low-computing-power edge devices while maintaining algorithm efficiency, thus improving the utilization of network computing resources while preserving algorithm efficiency.

[0045] To achieve the above objectives, the present invention adopts the following technical solution:

[0046] An improved Raft consensus algorithm based on UTXO includes improvements to leader election and log replication based on UTXO. The improvements to leader election include adding voting request content to the stage where candidate nodes initiate voting requests and adding a series of verification stages to the stage where follower nodes vote for candidate nodes. The improvements to log replication include adding a log distribution stage at the beginning of the log replication process, adding a log packaging and forwarding stage after the log distribution stage, and adding a log forwarding verification and node reward / penalty stage after the log packaging and forwarding stage.

[0047] The present invention further explains that the improvement of the leader node election specifically includes: (1) when a candidate node initiates a voting request, the candidate node needs to attach all the UTXOs it owns in the voting request; (2) after receiving the voting request, the follower node needs to perform three-step verification: 21) verify the data completeness of the content attached in the voting request; 22) verify the size relationship between the term number attached in the voting request and the term counter of the node; 23) perform two-step verification on the UTXOs contained in the voting request; and then decide whether to return voting feedback based on the result of the three-step verification.

[0048] The present invention further explains that the verification of the data integrity of the additional content in the voting request includes: encrypting and verifying the content body of the additional content in the voting request, that is, encrypting the content body using the same encryption algorithm and comparing the resulting encrypted string with the encrypted string of the content body in the voting request; if the content is consistent, it proves that the request has data integrity and proceeds to the next verification step; otherwise, it proves that the request may have been subjected to a man-in-the-middle attack, or that the requester has not complied with the smart contract's agreement to encapsulate the content body, indicating that the requester may have privately tampered with the local smart contract, and the following node will directly reject the voting request.

[0049] The present invention further explains that the two-step verification of the UTXO contained in the voting request includes:

[0050] The first step is to verify the UTXOs contained in the transaction strings within the content body on the blockchain to confirm whether they actually exist on the chain and have not expired. The specific verification process is as follows:

[0051] a) First, use the node information of the candidate node to search on the chain to obtain all transaction information of the candidate node on the current chain;

[0052] b) Verify whether the transaction information attached to the request body actually exists in the corresponding block. This requires verifying the block height, the transaction's position in the block, and the transaction's unique ID.

[0053] c) Verify whether the UTXO attached to the request body is used in its subsequent transactions, or whether there are other UTXOs belonging to the candidate node but the candidate node did not encapsulate them in the request body;

[0054] If any abnormality occurs during the above verification process, including incomplete UTXO information or the use of a fake or expired UTXO, the voting request will be rejected directly; otherwise, the next verification step will be performed.

[0055] The second step is to accumulate the weights in the UTXOs contained in the transaction string in the request content body and compare them with the accumulated weights in the UTXOs held by this node.

[0056] If the cumulative weight of the candidate node is greater than the cumulative weight of this node, a voting response is returned and the election timer of this node is reset; otherwise, the voting request is rejected.

[0057] The present invention further explains that the weight is determined based on the node's response speed in log replication.

[0058] The present invention further explains that the improved log replication process is as follows:

[0059] Step 1-1: Delegate the client's data interaction permissions to all nodes. The client's data write requests are distributed to the leader node or other follower nodes according to the distribution strategy. This ensures that when data write requests occur frequently, the requests will not accumulate at the client for a long time, nor will they put a huge single point of pressure on the leader node. Instead, the request pressure is distributed among the nodes.

[0060] Steps 1-2: After receiving the first distribution request, each node starts maintaining a packaging timer. Before the packaging timer expires, all requests distributed to that node will be packaged into a single request. If the node is a follower node, it will forward the packaged request to the leader node. In order to ensure the normal operation of the subsequent forwarding verification process, the packaged request needs to include all UTXOs owned by the node when forwarding. The leader node will only proceed with the subsequent process after completing the request packaging or receiving the packaged request forwarded by the follower node.

[0061] Steps 1-3: After receiving the packet request forwarded by the follower nodes, the leader node needs to validate the content of the request body:

[0062] First, the leader node needs to check with each client to see if the content of each request in the packaged request is consistent with the actual request content of the client. If the verification is incorrect, it can be assumed that the follower node that participated in forwarding has modified the request content or used a fake request. In this case, the forwarding behavior is regarded as an attack on the leader node, defined as malicious behavior, and the follower node that forwarded the packaged request is regarded as a malicious node.

[0063] Secondly, the leader node needs to verify the UTXO attached to the package request by the follower node. If the verification fails, the forwarding behavior is also regarded as an attack on the leader node, defined as malicious behavior, and the follower node that forwards the package request is regarded as a malicious node.

[0064] After verification, the leader node reclaims the legitimate UTXOs of malicious nodes in the blockchain, writes them into a block, and begins the log replication process as punishment for the malicious nodes. For normal forwarding and packaging requests, the leader node will calculate the cumulative weight of the attached UTXOs based on the attached UTXOs, generate a new UTXO with a weight greater than this cumulative weight, and assign it to the node as a reward for the normal node. The packaging request and the reward transaction will be written into a block together to begin the log replication process.

[0065] Step 2: After receiving a request, a normal node writes the data to its local log, while a malicious node writes incorrect data to its local log. At this point, all data is in an unacknowledged state. The leader node needs to start maintaining a node feedback queue of size (N-1) / 3 to record the addresses of nodes that provide additional feedback.

[0066] Step 3-1: After verifying the written data and confirming that it does not conflict with the local entry, the follower node sends additional feedback to the leader node;

[0067] Step 3-2: Whenever the leader node receives an additional feedback, it records the information of the follower node that provided the additional feedback into the node feedback queue;

[0068] When the queue is full, the log replication process can be considered complete. At this time, the leader node generates new UTXOs with progressively decreasing weights for the nodes in the queue according to the order in which the nodes reported to the queue. This is a reward for the positive behavior of the nodes participating in the log replication process, and these reward transactions are packaged into blocks. At the same time, the leader node changes the data status to the confirmed status and reports to the client that the data writing is complete.

[0069] Step 4: The leader node sends an append entry request to all follower nodes again. This append entry will include the reward transaction information for a new batch of UTXOs generated in Step 3-2 to reward participation in the log replication process, as well as the information on the final version of the block after the leader node adds these transaction information.

[0070] After receiving the request, the follower node first adds the reward transaction information to the block locally and packages it, and then confirms whether the information of the final version of the local block is consistent with that of the leader node. After confirmation, the data status in the local log is changed to the confirmed status; at this point, the log replication process is complete.

[0071] Advantages of this invention:

[0072] 1. This invention makes improvements to the existing Raft algorithm in the following three aspects:

[0073] Security: This improved method utilizes the weights in UTXOs to construct a node behavior evaluation system to constrain node behavior, thereby preventing malicious nodes from being elected as leader nodes. It also proposes a punishment scheme for malicious behavior in the network, enabling it to address malicious node situations in distributed systems. This allows it to be applied to distributed systems containing malicious nodes or to public blockchain applications. In other words, it expands the applicability of the Raft algorithm from the original private blockchain level to the public blockchain level.

[0074] Efficiency: This improved method utilizes UTXO to improve and optimize the relevant processes of the Raft algorithm. Taking advantage of the low resource consumption of UTXO during verification and generation, the operating efficiency of the Raft algorithm is not significantly affected after the improvement.

[0075] General applicability: This improved method utilizes UTXO to optimize the Raft algorithm, enhancing its security while maintaining its efficiency. This makes the algorithm feasible for deployment on low-computing-power nodes in public network environments, fully integrating various edge computing nodes into the distributed system node network and improving the utilization rate of edge computing nodes.

[0076] 2. Compared with the scheme in Reference 3, the improved method of the present invention has the following three advantages:

[0077] (1) It has a mechanism for punishing malicious nodes:

[0078] Reference 3 improves Raft by requiring each transaction initiated by a node to be verified for legitimacy by 2f+1 nodes before a consensus is reached and the transaction is packaged into a block. This operation does indeed prevent malicious behavior, thus giving the algorithm fault tolerance for malicious behavior. However, since it does not punish malicious behavior, the cost of such behavior remains zero.

[0079] In this improved method, a reward and punishment consensus mechanism triggered by node behavior is constructed by introducing UTXOs. The weights in the UTXOs are used to form a node behavior evaluation system to constrain node behavior. This not only includes fault tolerance for malicious behavior but also the ability to punish malicious nodes. When malicious behavior occurs, the weights in the malicious node's UTXO are reclaimed by the network, greatly increasing the cost of malicious behavior.

[0080] (2) Feasibility of deployment on public blockchains:

[0081] Reference 3, in its improvement of the leader election process, introduces a third node, other than the master and slave nodes, as a supervisory node to initiate and lead the master node election process. The existence of this special supervisory node allows malicious nodes to exploit vulnerabilities to become supervisory nodes and subsequently leader nodes, leading to a collapse of the entire network's credibility. Therefore, the improvement method in Reference 3 cannot be applied to completely public blockchains, but it can be applied to consortium blockchains with access control mechanisms. This expands the applicability of the Raft algorithm from the private blockchain level to the consortium blockchain level.

[0082] In this improved method, there is no special supervisory node. The entire leader election process and log replication process are jointly participated in by all nodes in the network. At the same time, by improving the leader election process and log replication process, the method has the ability to tolerate or punish malicious behavior at each stage of the process, making the improved Raft algorithm feasible to deploy on public blockchains.

[0083] (3) It has lower computing power overhead and greater versatility:

[0084] Reference 3 proposes using data analysis to examine the past behavior of nodes and then predict the legality of their transactions based on the analysis results. This extensive data analysis and predictive analysis process significantly increases node resource consumption. Even though Reference 3 states that data analysis is performed by supervisory nodes and predictive analysis occurs during the log replication process of the leader node while waiting for additional feedback, in actual network operation, the communication process for leader node election and log replication is extremely short. Therefore, to fully utilize this very short interval of resource usage, additional node computing power must be added; otherwise, such computationally intensive data analysis and predictive analysis will only increase the overall network response latency. Thus, the improved scheme in Reference 3 can only be used in consortium blockchain-level distributed systems with a few resident large core computing nodes, and cannot be applied to distributed systems with a large number of edge computing nodes.

[0085] In this improved method, instead of using data analysis methods that require a lot of resources, we use UTXO, a technology that uses less resources in both generation and verification. This allows the entire algorithm to be deployed in distributed systems with a large number of edge computing nodes, making it more versatile. Attached Figure Description

[0086] Figure 1 This is a diagram illustrating how candidate nodes initiate voting requests to improve the process.

[0087] Figure 2 A diagram illustrating the format for encapsulating additional content requested.

[0088] Figure 3 This is a diagram illustrating how to improve the process by following the node's verification request and sending voting feedback.

[0089] Figure 4 This is a schematic diagram of the data integrity verification process.

[0090] Figure 5 This is a diagram illustrating the log distribution process.

[0091] Figure 6 This is a diagram illustrating the log packaging and forwarding process.

[0092] Figure 7 This is a diagram illustrating the log forwarding verification and node penalty process.

[0093] Figure 8 This is a diagram illustrating the log forwarding verification-node reward process.

[0094] Figure 9This is a diagram illustrating the reward transaction format for the log forwarding verification-node reward process.

[0095] Figure 10 This is a diagram illustrating a request received from a client by a leader node in the presence of a malicious node.

[0096] Figure 11 This diagram illustrates how the improved leader node sends append entry requests to other nodes.

[0097] Figure 12 A diagram illustrating the sending of additional feedback to the improved follower node.

[0098] Figure 13 This is a diagram illustrating how the improved leader node sends an additional entry request to other nodes. Detailed Implementation

[0099] The improved method for leader election and log replication based on UTXO of the present invention will be further explained below with reference to the accompanying drawings.

[0100] 1. Improvement plan for leader node election:

[0101] Based on the analysis in the technical background, the existence of malicious nodes in public blockchain applications allows them to prematurely time out or modify their own term counters by altering their own timer, thus becoming candidates for the next term. In the Raft algorithm, follower nodes always respond to the first voting request they receive that exceeds their current term and reset their timer (step 1-4-1 of the Raft algorithm above). At this point, a malicious node can exploit the election timer or term counter vulnerability to successfully become the leader node, and subsequently use the leader node's identity to initiate a log replication process with falsified data, thereby achieving malicious gains.

[0102] Therefore, based on this vulnerability, this solution proposes using the weights in the UTXO to guide the leader election process, thereby selecting a relatively optimal leader node to dominate the network's log replication process. The weights in the UTXO are mainly derived from the behavioral feedback of each node in the log replication process; the more positive the behavioral feedback, the larger the weight held by the node, thus becoming the relatively optimal node in the network.

[0103] The core idea of ​​the improvement is to first add voting request content to the candidate node's voting request stage on the Raft algorithm; secondly, to add a series of verification steps to the follower node's voting for the candidate node; and finally, to improve the verification method, the result branch of successful verification also needs to be improved. That is, steps 1-2, 1-3, and 1-4-1 of the Raft algorithm are improved, and the specific improved process is as follows:

[0104] Improvement steps 1-2: such as Figure 1 As shown, when a candidate node initiates a voting request, the candidate node needs to attach all the UTXOs it owns in the voting request.

[0105] UTXOs need to be encapsulated as transaction strings. The encapsulated content must be encrypted using an encryption algorithm (this algorithm should be pre-built into the blockchain's smart contract and written into the node after it is admitted to the network, ensuring its privacy and preventing access by any party outside the network). The resulting encrypted string must be attached to the request to ensure the request is not subject to man-in-the-middle attacks during transmission (which involve intercepting and modifying data without the knowledge of the communicating parties), thus guaranteeing the data integrity of the candidate node election request. The specific format for the additional content encapsulation is as follows: Figure 2 As shown.

[0106] Even though the candidate node's UTXO, the transaction where the UTXO is located, and the block information are available in all blockchains, the candidate node still needs to provide evidence of this information when participating in the election. This reduces the data reading and verification pressure on each node in the subsequent verification process, thereby further lowering the entry threshold for nodes in the network.

[0107] Improvement steps 1-3: such as Figure 3 As shown, follower nodes need to perform three verification steps after receiving a voting request:

[0108] (1) Verify the data completeness of the requested additional content;

[0109] (2) Verify the relationship between the number of terms attached to the voting request and the term counter of this node;

[0110] (3) Perform two-step verification on the UTXO contained in the request.

[0111] Finally, based on the results of the three-step verification, a decision is made on whether to return to the voting feedback, that is, to decide whether to proceed to the next branch to improve step 1-4-1 or step 1-4-2.

[0112] The following section will mainly explain the process details of data integrity verification and UTXO two-step verification:

[0113] (a) Data completeness verification:

[0114] The content body of the additional content in the voting request needs to be encrypted and verified. This involves encrypting the content body using the same encryption algorithm and comparing the resulting encrypted string with the encrypted string of the content body in the request. If the content matches, it proves that the request has data integrity and proceeds to the next verification step. Otherwise, it indicates that the request may have been subjected to a man-in-the-middle attack, or that the requester did not comply with the smart contract's agreement to encapsulate the content body. This suggests that the requester may have privately tampered with the local smart contract, and the following nodes will directly reject the voting request. A brief description of the specific process is as follows: Figure 4 As shown.

[0115] (II) Two-step verification of UTXO:

[0116] Step 1: Verify the UTXOs contained in the transaction string within the content body on the blockchain to confirm whether they actually exist on the chain and have not expired. The specific verification process is as follows:

[0117] First, the node information of the candidate node is used to search on the chain to obtain all transaction information of the candidate node on the current chain.

[0118] To verify whether the transaction information attached to the request body actually exists in the corresponding block, it is necessary to check the block height, the transaction's position in the block, and the transaction's unique ID.

[0119] Verify whether the UTXO attached to the request body is used in its subsequent transactions, or whether there are other UTXOs belonging to the candidate node that the candidate node did not encapsulate in the request body.

[0120] If any abnormality occurs during the above verification process, such as incomplete UTXO information or the use of a fake or expired UTXO, the voting request will be rejected directly. Otherwise, proceed to the next verification step.

[0121] Step 2: Accumulate the weights of the UTXOs contained in the transaction string within the request body (the weights of the UTXOs obtained by each node will vary depending on the node's response speed in log replication, which will be explained in detail in the section on improved log replication below) and compare them with the accumulated weights of the UTXOs held by the current node. If the accumulated weights of the candidate node are greater than the accumulated weights of the current node, proceed to improved step 1-4-1. Otherwise, proceed to step 1-4-2.

[0122] Improvement step 1-4-1: such as Figure 3 As shown, after the node completes the verification process of steps 1-3 and passes the verification, it returns voting feedback and resets the election timer of this node.

[0123] It's worth noting that in the original step 1-4-1, follower nodes update their term counters after sending their voting feedback, logically limiting a single follower node to voting only once within the same term. However, in the improved step 1-4-1, follower nodes do not update their term counters after sending their voting feedback. Instead, they wait until a new leader node is elected and sends a heartbeat signal before updating the term counter. This logically allows a single follower node to vote multiple times within the same term. In other words, the overall leader election principle changes from a first-come, first-served principle to a best-effort principle, thereby achieving the goal of selecting the relatively optimal node in the network.

[0124] Meanwhile, due to the change in voting principles, and the need to consider situations such as node failure (failed nodes cannot receive or respond to any requests) and malicious node behavior (malicious nodes will not vote for any nodes other than themselves in the leader election process), the following will mainly explain the selection criteria for the improved leader election process.

[0125] Under this improved voting mechanism, each candidate node that initiates a legitimate voting request receives voting feedback from other nodes whose cumulative weight is less than its own. Therefore, when a single node is allowed to vote multiple times, using the number of votes as the standard for election is clearly the best strategy. However, since the election timer countdown is randomly generated and network fluctuations may occur, even if two candidate nodes in the same term initiate the election process, the time difference between receiving voting feedback from other follower nodes may be significant. Therefore, it is impossible to determine the specific elected node by comparing the number of votes from multiple candidate nodes in real time. Furthermore, in a network without a leader node, monitoring the leader election process through a third-party node also has vulnerabilities, allowing malicious nodes to directly manipulate the leader election process. Therefore, a formula for determining the number of votes for leader election is fixed through a smart contract. When a candidate node's number of votes reaches the threshold of this formula, that node can be considered the relatively optimal node in the current network, triggering the contract process to automatically elect the leader node. Furthermore, since the total number of nodes in the network is constantly changing, this directly affects the specific number of votes each node receives, and indirectly affects the number of votes required for election. Therefore, the formula for calculating the vote threshold needs to fully consider the impact of changes in the number of nodes on the election results while ensuring the uniqueness of the leader node election outcome. The derivation process of the formula will be explained below.

[0126] This assumes a total of N nodes in the network, including both faulty and malicious nodes:

[0127] There are f malicious nodes in the network. During the election, malicious nodes will not respond to normal voting requests. Malicious nodes tend to concentrate the votes of all malicious nodes in an attempt to become the leader node. That is, a total of f malicious node votes are concentrated in the same malicious node. The malicious votes of these malicious nodes will also be recorded in the total vote count. However, the network needs to use constraints to ensure that malicious nodes cannot be elected as the leader node.

[0128] Meanwhile, there are f faulty nodes in the network. Faulty nodes will not respond to voting requests due to network interruption or node crash, but they still need to be included in the total number of votes, that is, a total of f faulty node votes.

[0129] Therefore, according to the principle of majority rule, at least f+1 nodes in the network need to reach a consensus to elect a normal leader node to prevent malicious nodes from being elected as leaders. This means there must be a total of f+1 normal nodes. Therefore, we can deduce that the relationship between N and f is N = 3f+1. This situation is called the limit case for normal network operation, meaning the minimum number of normal nodes is f+1. Below this number, the network may experience malfunctions (inability to elect a leader node) or collapse (malicious nodes being elected as leaders). In this case, to ensure the uniqueness of the leader election result, only candidate nodes that receive f+1 votes can be considered the relatively optimal node in the network and thus elected as leaders. Therefore, the formula for calculating the vote threshold is (N-1) / 3+1, meaning the minimum requirement for a candidate node to be elected as a leader is that the number of votes received must be greater than or equal to (N-1) / 3+1. It should be noted that when a candidate node starts its election, it defaults to providing votes for itself; therefore, a total of (N-1) / 3 votes from external sources are required to be considered an elected leader node.

[0130] By improving the leader election process, the algorithm prevents malicious nodes from becoming leaders while using minimal computational resources for information verification, and selects the leader node with the best relative performance in the network. This enhances the algorithm's security while maintaining its efficiency.

[0131] 2. Improvements to log replication:

[0132] Based on the analysis in the technical background, in the log replication process of the original Raft algorithm, the leader node is usually the only node in the network that interacts with the client's data. This makes it easy for the leader node to fail when the client's data write requests occur frequently, thus frequently triggering the election process and causing the network to be in a temporary failure state for a long time.

[0133] Even if the leader node can efficiently handle a large number of data write requests, the frequent triggering of the log replication process will cause a large network load in the network, indirectly increasing the performance requirements of the nodes in the network. This will be detrimental to low-computing-power nodes joining the network.

[0134] Therefore, the first approach to improve the log replication process is to achieve the following requirements through process improvements:

[0135] (1) Reduce the single point of pressure on the leader node when data write requests occur frequently;

[0136] (2) Reduce the large network load caused by frequent triggering of the log replication process;

[0137] To address the above requirements, step 1 needs to be improved. The specific improvement plan is as follows:

[0138] Improvement step 1-1: such as Figure 5 As shown, this step aims to address requirement a above. It adds a log distribution step at the beginning of the log replication process. Client data interaction permissions are delegated to all nodes. Clients then distribute data write requests to the leader node or other follower nodes according to a specific distribution strategy (this strategy can employ common dynamic node allocation strategies such as Kubernetes; the core focus of this improvement is not on the distribution strategy itself, and will not be elaborated upon here). This ensures that when data write requests occur frequently, they do not accumulate at the client for extended periods, nor do they create significant single-point pressure on the leader node; instead, the request pressure is distributed across all nodes.

[0139] When a follower node receives a data write request, it does not immediately forward the request to the leader node, as direct forwarding would not reduce the single point of failure on the leader node. Instead, the follower node collects multiple requests within a unit of time, packages them, and then forwards them to the leader node, thus reducing the single point of failure on the leader node by reducing the number of requests. The specific request packaging and forwarding strategy will be explained in improvement steps 1-2.

[0140] Improvement steps 1-2: such as Figure 6 As shown, this step aims to address requirement b mentioned above. By adding a log packaging-forwarding step after the log distribution step, each node starts maintaining a packaging timer after receiving the first distribution request. Requests distributed to that node before the packaging timer expires will be packaged into a single request. If the node is a follower node, it will forward the packaged request to the leader node. To ensure the proper functioning of subsequent forwarding verification steps, the packaged request needs to include all UTXOs owned by the node during forwarding. The specific packaging method also needs to follow steps 1-2 of the leader node improvement scheme.

[0141] The leader node will only proceed with subsequent processes after completing the request packaging or receiving a packaging request forwarded by follower nodes. The core idea of ​​this improvement is to reduce network load by decreasing the frequency of log replication processes triggered in the network.

[0142] Specifically, in some application scenarios, the large size of data write request messages may cause a significant load on the network after packaging. Therefore, each node needs to maintain a request limit pool to limit the total size of the request message in a single package. When the packaging timer has not expired but the request limit pool is close to full, the node needs to package the existing requests in advance, actively reset the packaging timer to zero, and then continue the forwarding process.

[0143] It is worth noting that the timeout time of the packaging timer and the size of the request limit pool mentioned above need to be agreed upon in the smart contract. However, when designing them, it is also necessary to consider various factors such as the data writing frequency of the application scenario, the average message size of the data writing request, the average latency of network node communication, and the acceptable range of the average response latency of the application scenario. Therefore, this article does not make strong numerical definitions for these variable elements that need to consider the actual scenario.

[0144] The core idea of ​​the above-mentioned improvement to step 1 is to share the pressure on the leader node and network load by consuming the computing resources of follower nodes. However, this modification also presents a security vulnerability. Due to the existence of malicious nodes in public blockchain applications, malicious nodes can continuously send fake client requests to the leader node, consuming the leader node's computing resources, thereby causing the leader node to fail and leading to a distributed system failure. Furthermore, based on the above-mentioned improved leader node election process, the system needs to use the weights in UTXOs to construct a node behavior evaluation system to prevent malicious nodes from being elected as leader nodes. It is also expected that the elected leader node will have good network communication. Therefore, based on the above requirements, the second improvement to the log replication process is to achieve the following requirements through process improvements:

[0145] By imposing corresponding penalties on malicious behavior of nodes, the cost of such behavior (e.g., sending false client requests to the leader node, failing to write correct log entries to the local log during the log replication process, and sending append feedback) is increased, thereby constraining malicious behavior of nodes.

[0146] Provide corresponding rewards for normal node behavior to encourage positive node behavior;

[0147] By using the weights in UTXO to construct a node behavior evaluation system, the system can be used to improve the leadership node election process and prevent malicious nodes from being elected as leadership nodes.

[0148] To address the above requirements, step 1 needs further improvement. The specific improvement plan is as follows:

[0149] Improvement steps 1-3: such as Figure 7 and Figure 8 As shown, for situations where the leader node receives a packaged request forwarded by a follower node, a log forwarding verification-node reward / penalty step is added after the log packaging-forwarding step (i.e., requests distributed to the leader node only have a log packaging step in improved step 1, while requests distributed to follower nodes need to go through a log packaging-forwarding-forwarding verification-node reward / penalty step in improved step 1). This step specifically verifies the forwarded packaged request against the client and, based on the verification result, increases or completely removes the weight in the node's UTXO, thereby punishing malicious nodes and rewarding normal nodes. The specific process is as follows:

[0150] After receiving the forwarded packet request, the leader node needs to validate the content of the request body:

[0151] First, the leader node needs to verify with each client that the content of each request in the packaged request matches the client's actual request content. (To mitigate the additional network overhead of sending requests back to the client for verification, the verification method here should combine unique value and hash value verification. That is, use a message digest algorithm such as MD5 to hash each request content to obtain a hash value. During verification, only the unique value of the request and the corresponding hash value are sent back to the client, thereby reducing network overhead. The client should complete the hash calculation of the request content when sending the request, and find the corresponding hash value based on the unique value index after receiving the verification request for comparison. Using hash encryption can not only reduce network overhead but also prevent man-in-the-middle attacks.) If the verification request is incorrect, it can be assumed that the follower nodes participating in forwarding have modified the request content or used a fake request. In this case, the forwarding behavior is considered an attack on the leader node, defined as malicious behavior, and the follower nodes that forwarded the packaged request are considered malicious nodes.

[0152] Secondly, the leader node needs to verify the UTXO attached to the packet request by the follower nodes. The specific verification process can be found in the first step of the two-step UTXO verification in steps 1-3 of the improved leader node election scheme above. If the verification fails, the forwarding behavior is also regarded as an attack on the leader node, defined as malicious behavior, and the follower node that forwards the packet request is regarded as a malicious node.

[0153] After verification, the leader node reclaims the legitimate UTXOs of malicious nodes in the blockchain, writes them into a block, and begins the log replication process (at this point, the block contains no log entries, only the punishment information for the node. The reclaimed UTXOs will directly point to the network-designated reclaim account address. This reclaim account should be created during network initialization, and the number of UTXOs at this address should not decrease during network operation. If UTXOs in the reclaim account address are traded, it signifies the collapse of the network's credit system). This serves as punishment for the malicious nodes.

[0154] It's important to note that such penalties will result in legitimate client requests sent to the malicious node not receiving a response, even if these requests haven't been maliciously modified by the malicious node. Therefore, clients need to configure a response timeout policy to resend requests sent to that node that haven't received a write response when malicious behavior occurs, by switching to a different node.

[0155] For normal forwarding and packaging requests, the leader node will calculate the cumulative weight of the attached UTXOs based on the attached UTXOs, generate a new UTXO with a weight greater than this cumulative weight, and assign it to the node (i.e., the new weight = cumulative weight + incremental weight; the specific calculation method for the incremental weight needs to be declared in advance in the smart contract. This incremental weight can be a fixed value or dynamically increased or decreased based on the block height and the number of nodes in the network. Combining multiple UTXOs into a new UTXO can also reduce the network overhead of election requests and packaging request forwarding, as well as reduce the resource overhead of nodes when verifying UTXOs, thus improving the overall network performance). This is a reward for the normal node, and the packaging request and reward transaction are written together into the block to start the log replication process. The specific reward transaction content is as follows: Figure 9 As shown.

[0156] For malicious nodes that fail to write correct log entries and send append feedback to their local logs during the log replication process, steps 2, 3, and 4 of the log replication process need improvement. The improved log replication process also incorporates a reward scheme for normal nodes. By continuously increasing the rewards for normal node behavior and combining this with the aforementioned penalties for malicious node behavior, the goal is to build a node behavior evaluation system. The specific improvement plan is as follows:

[0157] like Figure 10 As shown, in the initial case, the default leader node has already completed the relevant steps of improvement step 1, and the block already contains various information such as packaging requests and reward / penalty transactions.

[0158] Improvement step 2: such as Figure 11As shown, a normal node writes data to its local log upon receiving a request, while a malicious node writes incorrect data to its local log. At this point, all data is in an unacknowledged state. The leader node then needs to maintain a node feedback queue of size (N-1) / 3 to record the addresses of nodes providing subsequent feedback.

[0159] Step 3-1: After verifying that the written data does not conflict with the local entries, the follower node sends additional feedback to the leader node.

[0160] Improvement step 3-2: such as Figure 12 As shown, each time the leader node receives additional feedback, it records the information of the follower node that provided the additional feedback into the node feedback queue.

[0161] When the queue is full, the log replication process is considered complete. At this point, the leader node generates new UTXOs with progressively decreasing weights for the nodes in the queue based on their order of participation in the log replication process. This is a reward for the nodes' positive behavior of participating in the log replication process, and these reward transactions are packaged into a block. Simultaneously, the leader node changes the data status to confirmed and sends a notification to the client that the data writing is complete.

[0162] It is particularly important to note that the weights or calculation methods of these newly generated UTXOs assigned to nodes participating in the log replication process, like the incremental weights of the forwarding and packaging requests mentioned above, must be declared in advance in the smart contract. Their generation principle must adhere to a decreasing order based on generation sequence, ensuring that the node that provides the first supplementary feedback (i.e., the node with the best computational performance in the current network or the lowest network latency with the leader node) receives the largest weight reward. The decreasing magnitude can use a halving or a corresponding coefficient-based decreasing method, which requires specific analysis in the corresponding application scenario. In improved step 2, by limiting the size of the node feedback queue to (N-1) / 3, the result, including the leader node itself, reaches (N-1) / 3+1, which matches the number of feedbacks required to confirm log completion, thus ensuring the scarcity of the weight reward. That is, only the first (N-1) / 3 following nodes that provide feedback can receive the weight reward, while malicious nodes refuse to return supplementary feedback to the leader node and therefore cannot receive any UTXO reward.

[0163] Improvement step 4: such as Figure 13 As shown, the leader node sends an append entry request to all follower nodes again. This append entry will include reward transaction information for a new batch of UTXOs generated in step 3-2 to reward participation in the log replication process, as well as information on the final version of the block after the leader node adds these transaction information.

[0164] Upon receiving the request, the follower node first synchronously adds the reward transaction information to the block locally, packages it, and confirms whether the final version of its block is consistent with the leader node. After confirmation, it changes the data status in its local log to "confirmed." This completes the log replication process.

[0165] By improving the log replication process, several process environments were added to enhance algorithm security and overall network performance. Additionally, two reward mechanisms were added: one for sharing the single-point pressure on the leader node and network load, and another for actively participating in the log replication process through log appending feedback. A penalty mechanism was also added for malicious behavior such as attacking the leader node. This system utilizes the weights in the UTXO to construct a node behavior evaluation system to constrain node behavior, ensuring both the scarcity of weights and the fairness of the corresponding weight rewards for positive and negative behaviors.

[0166] Finally, the weights in the UTXO can be used to influence the leader election process. The node with the best computational performance and the lowest communication latency with previous leaders can theoretically receive the most weight reward. Thus, the weight can be used to determine whether a candidate node is more suitable to be elected as the leader node than the current node, thereby realizing the second step of the two-step verification of UTXO in steps 1-3 of the improved leader election scheme.

[0167] This invention proposes an improved Raft algorithm based on UTXO. The implementation of this improved method aims to construct a distributed application system, including an application system as a client and a node network composed of several nodes. The improved Raft algorithm is used as the consensus algorithm for the node network to maintain network stability. The following section will explain the implementation details of the algorithm using a cloud-network-edge-device integrated evidence storage platform:

[0168] The cloud-network-edge-device integrated evidence storage platform, as the underlying capability platform, is responsible for outputting the ability to retain and prove key data to the upper-layer application systems. The platform architecture design refers to public blockchain applications and combines the design methods of distributed systems, with a two-layer architecture of application interface layer and node network layer:

[0169] The application interface layer is built using the traditional PaaS application architecture. It serves as a communication bridge between the upper-layer application and the node network layer. It connects to the upper-layer application to output corresponding capability interfaces and connects to the node network layer to act as a client of the network layer and directly interact with nodes in the network.

[0170] In addition to having basic data writing and write feedback functions, the client of the application interface layer also needs to configure the corresponding request distribution strategy and response timeout strategy according to the consensus requirements of the improved Raft algorithm.

[0171] Meanwhile, due to the configuration of request distribution strategy and response timeout strategy, data write operations may fail and be resent, or require a long time to reach a series of consensuses in the network. Therefore, the interface provided to the upper layer application should adopt an asynchronous design strategy to ensure the stability of external application interaction with the application interface layer.

[0172] The node network layer utilizes blockchain and smart contract technologies to build a node network and implement the platform's core function: data storage. The smart contract is an implementation of the improved Raft algorithm proposed in this application. Specifically, it involves writing chaincode in languages ​​such as Go, Java, and Node.js to implement various constraints and verification rules within the algorithm. The completed chaincode is then packaged and deployed to a blockchain technology platform based on Hyperledger Fabric. Through a series of initialization operations, the basic node network is built and the blockchain is created. At this point, the algorithm serves as the smart contract maintaining the node network, and the data structure used for data storage within the network is called the storage chain. The smart contract not only contains the constraints related to the aforementioned situations but also includes strategies already present in the original Raft algorithm, such as node joining / leaving the network, network split-brain handling, and side-chain handling. All subsequent actions within the storage chain will be processed in accordance with this smart contract.

[0173] Meanwhile, thanks to the use of the improved Raft algorithm for smart contracts, the platform can deploy these smart contracts to various devices with computing and storage capabilities, including large application servers, personal devices, and edge devices such as smart cameras with computing and storage functions, all of which can be considered nodes on this platform. Every node joining the network needs to deploy this contract locally and digitally sign it according to the node admission process to ensure consensus on the smart contract among nodes.

[0174] It is important to note that because this evidence storage chain is a public-level blockchain, meaning that nodes in the network only reach consensus on the smart contract, not on the platform acting as a client, the cloud-network-edge-device integrated evidence storage platform is merely an entry point to the network. Nodes within it only interact with non-network nodes through this entry point. Therefore, other similar platforms could exist to implement the same technical functions and reach consensus on the smart contract. In this case, the platform could also act as another client on the network, and nodes should be able to freely choose different clients for data interaction. That is, nodes can selectively be managed by different clients, which may depend on the number of requests that the client can obtain and the amount of weight that a node might receive under that platform.

[0175] Obviously, the above embodiments are merely examples for clearly illustrating the present invention, and are not intended to limit the implementation of the present invention. Those skilled in the art will recognize that other variations or modifications can be made based on the above description; it is neither necessary nor possible to exhaustively list all possible implementations; however, obvious variations or modifications derived therefrom are still within the scope of protection of the present invention.

Claims

1. An improved method for the Raft consensus algorithm based on UTXO, characterized in that: This includes improvements to UTXO-based leader election and log replication; The improvements to the leader node election include adding voting request content to the process where candidate nodes initiate voting requests and adding a series of verification steps to the process where follower nodes vote for candidate nodes; specifically including: (1) When a candidate node initiates a voting request, the candidate node needs to attach all the UTXOs it owns in the voting request; (2) After receiving a voting request, the following node needs to perform three verification steps: 21) Verify the data completeness of the additional content in the voting request; 22) Verify the relationship between the number of terms attached to the voting request and the term counter of this node; 23) Perform two-step verification on the UTXO contained in the voting request; Then, based on the results of the three-step verification, a decision is made as to whether to return a voting feedback; The improvements to log replication include adding a log distribution stage at the beginning of the log replication process, adding a log packaging and forwarding stage after the log distribution stage, and adding a log forwarding verification and node reward / penalty stage after the log packaging and forwarding stage. The improved log replication process is as follows: Step 1-1: Delegate the client's data interaction permissions to all nodes. The client's data write requests are distributed to the leader node or other follower nodes according to the distribution strategy. This ensures that when data write requests occur frequently, the requests will not accumulate at the client for a long time, nor will they put a huge single point of pressure on the leader node. Instead, the request pressure is distributed among the nodes. Steps 1-2: After receiving the first distribution request, each node starts maintaining a packaging timer. Before the packaging timer expires, all requests distributed to that node will be packaged into a single request. If the node is a follower node, it will forward the packaged request to the leader node. In order to ensure the normal operation of the subsequent forwarding verification process, the packaged request needs to include all UTXOs owned by the node when forwarding. The leader node will only proceed with the subsequent process after completing the request packaging or receiving the packaged request forwarded by the follower node. Steps 1-3: After receiving the packet request forwarded by the follower nodes, the leader node needs to validate the content of the request body: First, the leader node needs to check with each client to see if the content of each request in the packaged request is consistent with the actual request content of the client. If the verification is incorrect, it can be assumed that the follower node that participated in forwarding has modified the request content or used a fake request. In this case, the forwarding behavior is regarded as an attack on the leader node, defined as malicious behavior, and the follower node that forwarded the packaged request is regarded as a malicious node. Secondly, the leader node needs to verify the UTXO attached to the package request by the follower node. If the verification fails, the forwarding behavior is also regarded as an attack on the leader node, defined as malicious behavior, and the follower node that forwards the package request is regarded as a malicious node. After verification, the leader node reclaims the legitimate UTXOs of malicious nodes in the blockchain, writes them into a block, and begins the log replication process as punishment for the malicious nodes. For normal forwarding and packaging requests, the leader node will calculate the cumulative weight of the attached UTXOs based on the attached UTXOs, generate a new UTXO with a weight greater than this cumulative weight, and assign it to the node as a reward for the normal node. The packaging request and the reward transaction will be written into a block together to begin the log replication process. Step 2: After receiving a request, a normal node writes the data to its local log, while a malicious node writes incorrect data to its local log. At this point, all data is in an unacknowledged state. The leader node needs to start maintaining a node feedback queue of size (N-1) / 3 to record the addresses of nodes that provide additional feedback. Step 3-1: After verifying the written data and confirming that it does not conflict with the local entry, the follower node sends additional feedback to the leader node; Step 3-2: Whenever the leader node receives an additional feedback, it records the information of the follower node that provided the additional feedback into the node feedback queue; When the queue is full, the log replication process can be considered complete. At this time, the leader node generates new UTXOs with progressively decreasing weights for the nodes in the queue according to the order in which the nodes reported to the queue. This is a reward for the positive behavior of the nodes participating in the log replication process, and these reward transactions are packaged into blocks. At the same time, the leader node changes the data status to the confirmed status and reports to the client that the data writing is complete. Step 4: The leader node sends an append entry request to all follower nodes again. This append entry will include the reward transaction information for a new batch of UTXOs generated in Step 3-2 to reward participation in the log replication process, as well as the information on the final version of the block after the leader node adds these transaction information. After receiving the request, the follower node first adds the reward transaction information to the block locally and packages it, and then confirms whether the information of the final version of the local block is consistent with that of the leader node. After confirmation, the data status in the local log is changed to the confirmed status. The log copying process is now complete.

2. The improved Raft consensus algorithm based on UTXO according to claim 1, characterized in that: The verification of the data integrity of the additional content in the voting request includes: encrypting the content body of the additional content in the voting request using the same encryption algorithm, and comparing the resulting encrypted string with the encrypted string of the content body in the voting request; if the content matches, it proves that the request has data integrity and proceeds to the next verification step; otherwise, it proves that the request may have been attacked by a man-in-the-middle, or that the requester has not complied with the smart contract's agreement to encapsulate the content body, indicating that the requester may have privately tampered with the local smart contract, and the following node will directly reject the voting request.

3. The improved Raft consensus algorithm based on UTXO according to claim 2, characterized in that: The two-step verification of the UTXO contained in the voting request includes: The first step is to verify the UTXOs contained in the transaction strings within the content body on the blockchain to confirm whether they actually exist on the chain and have not expired. The specific verification process is as follows: a) First, use the node information of the candidate node to search on the chain to obtain all transaction information of the candidate node on the current chain; b) Verify whether the transaction information attached to the request body actually exists in the corresponding block. This requires verifying the block height, the transaction's position in the block, and the transaction's unique ID. c) Verify whether the UTXO attached to the request body is used in its subsequent transactions, or whether there are other UTXOs belonging to the candidate node but the candidate node did not encapsulate them in the request body; If any abnormality occurs during the above verification process, including incomplete UTXO information or the use of a fake or expired UTXO, the voting request will be rejected directly; otherwise, the next verification step will be performed. The second step is to accumulate the weights in the UTXOs contained in the transaction string in the request content body and compare them with the accumulated weights in the UTXOs held by this node. If the cumulative weight of the candidate node is greater than the cumulative weight of this node, a voting response is returned and the election timer of this node is reset; otherwise, the voting request is rejected.

4. The improved Raft consensus algorithm based on UTXO according to claim 3, characterized in that: The weights are determined based on the node's response speed in log replication.

Citation Information

Patent Citations

  • Raft-based blockchain consensus methods

    CN109525636B

  • Block chain consensus method and device, electronic equipment and storage medium

    CN112822239A

  • Raft consensus mechanism improvement method based on node past behavior analysis

    CN115022022A

  • Alliance chain consensus method and device

    CN113612618A

  • Method and apparatus maintaining private data with consortium blockchain

    US20220343323A1