Supply chain traceability-oriented block chain hybrid consensus optimization method
By building a multi-index comprehensive scoring model in the blockchain hybrid consensus optimization method, combining PBFT and improving Raft consensus protocol, introducing Brotli data compression technology and supervision nodes, the scalability and performance bottlenecks of the consensus mechanism in the supply chain traceability scenario are solved, and an efficient, safe and reliable consensus process is achieved.
Patent Information
- Application Number
- CN202510148364.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-11
- Publication Date
- 2025-06-03
AI Technical Summary
The existing blockchain consensus mechanism has scalability and performance bottlenecks in the supply chain traceability scenario, and cannot meet the needs of high-concurrency and large-scale nodes. At the same time, the election of master nodes may be interfered by malicious nodes, affecting the security and consistency of the system.
The blockchain hybrid consensus optimization method for supply chain traceability is adopted, and node scoring and grouping is carried out by building a multi-index comprehensive scoring model, combining PBFT and improved Raft consensus protocol, Brotli data compression technology and supervision nodes are introduced to optimize the consensus process.
It improves the adaptability and efficiency of the system in large-scale and dynamic environments, enhances the security, reliability and efficiency of the consensus mechanism, and reduces communication complexity and network bandwidth usage.
Smart Images

Figure CN120087885A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of blockchain consensus algorithms, and particularly to a blockchain hybrid consensus optimization method for supply chain traceability. Background Art
[0002] A supply chain refers to the whole process from raw material procurement to the delivery of the final product, involving multiple links and participants, such as suppliers, manufacturers, warehousing, logistics, and retailers. With the complexity of the supply chain, supply chain traceability has emerged, using information technology to ensure that the data of each link is traceable, transparent, and tamper-proof. By applying technologies such as blockchain, supply chain traceability can track the source, quality, and transportation path of products in real time, thereby improving the transparency and efficiency of the supply chain and ensuring the safety and compliance of products.
[0003] Blockchain technology, with its characteristics of decentralization, tamper-proofness, and transparency, has played an important role in supply chain traceability. By recording the data of each link in the supply chain (such as raw material sources, production information, transportation paths, etc.) on the blockchain, it ensures that the data is tamper-proof and publicly transparent, thus solving the problems of information asymmetry and tampering in traditional supply chains. The traceability of the blockchain means that the whole process of each product from raw material procurement to final sales can be accurately recorded on the blockchain, and the information of any node can be queried and verified in real time, ensuring the transparency and reliability of the supply chain. Consumers and regulatory agencies can easily trace the full life cycle information of products by scanning QR codes, etc., to ensure the authenticity and safety of products. At the same time, the blockchain also reduces intermediate links, improves the efficiency of the supply chain, enhances the trust among participants, and promotes the intelligence and transparency of supply chain management.
[0004] The consensus mechanism of the blockchain is the core technology to ensure that all nodes in the distributed network reach an agreement and maintain the security and integrity of data. The Proof of Work algorithm (PoW) and Proof of Stake algorithm (PoS) applicable to public blockchains compete to generate new blocks by calculating complex mathematical problems, which have high security but consume a large amount of computing resources and electricity; the Practical Byzantine Fault Tolerance algorithm (PBFT) applicable to consortium blockchains tolerates malicious nodes through a voting mechanism; the Raft algorithm for private blockchains in small and medium-sized clusters ensures consistency through leader election and log replication. For the application scenario of supply chain traceability, the consortium blockchain has become the best technical foundation because its participants are usually trusted organizations, which can provide high security and privacy protection.
[0005] Although the PBFT method in the consortium blockchain has good fault tolerance and low confirmation latency, there are still some deficiencies in the supply chain traceability scenario. Supply chain traceability usually involves complex participating roles, strong liquidity, uneven node distribution, and a large participation scale. As the number of supply chain participants continues to increase, the existing PBFT faces scalability and performance bottlenecks and cannot meet the requirements of high concurrency and large-scale nodes. In addition, the primary node election in PBFT may be interfered with by malicious nodes, affecting the security and consistency of the entire system. This application deeply analyzes the deficiencies of the existing consensus mechanisms in the supply chain traceability scenario and proposes improvement measures from multiple aspects such as primary node selection, scalability optimization, and reduction of communication complexity, aiming to improve the adaptability and efficiency of the system in a large-scale and dynamic environment and ensure the security, reliability, and efficiency of supply chain traceability. Summary of the Invention
[0006] The present invention discloses a blockchain hybrid consensus optimization method for supply chain traceability, which solves the problems of the blockchain consensus mechanism in the supply chain traceability scenario in terms of primary node selection, scalability, and communication complexity.
[0007] To achieve the above object, the present invention provides the following technical solutions: A blockchain hybrid consensus optimization method for supply chain traceability, comprising the following steps:
[0008] S1. In the comprehensive scoring stage, first construct a multi-index comprehensive scoring model for supply chain nodes;
[0009] S2. At the beginning of each consensus cycle, the participating nodes in the supply chain calculate the corresponding comprehensive scores according to the constructed comprehensive scoring model, and sort the scoring results from high to low;
[0010] S3. In the node grouping stage, group the participating nodes by combining the node geographical locations and the comprehensive scores, and select the leader nodes and supervision nodes of each group according to the node comprehensive scores to form multiple groups of consensus architectures;
[0011] S4. In the consensus stage, adopt a hybrid consensus method based on data compression. First, perform inter-group consensus. The PBFT consensus protocol is used between the central nodes of each group to ensure data consistency between different groups; when the inter-group consensus is completed, enter the intra-group consensus stage. An improved Raft consensus protocol with the introduction of supervision nodes is adopted. By introducing supervision nodes, data synchronization and reliable communication between nodes are realized, ensuring intra-group data consistency and transaction correctness. At the same time, the Brotli data compression technology is introduced to optimize the network bandwidth and reduce the data transmission volume, further improving the consensus efficiency; when the client receives sufficient consensus reached information, consensus is reached.
[0012] Preferably, in step S1, in the comprehensive scoring stage, first construct a node multi-index comprehensive scoring model, and evaluate the comprehensive scores of the participating nodes in the supply chain at the beginning of each consensus cycle; this model is based on the performance, historical interaction behaviors, and resource attributes of the nodes in the blockchain system, and comprehensively evaluates the nodes from three dimensions: service level, consensus success rate, and resource attributes. The calculation method is shown in formula (1):
[0013]
[0014] Among them, is the comprehensive score of the i-th node when reaching consensus in the t-th round, is the service level, is the consensus success rate, is the resource attribute, and α, β, γ, δ are the corresponding weight coefficients, and satisfy α + β + γ + δ = 1, with the default values of 0.4, 0.2, 0.2, 0.2, and are dynamically adjusted according to the actual situation.
[0015] Preferably, the service level of node i
[0016]
[0017] Among them, is the supply ratio of node i in the upstream, is the sales ratio of node i in the downstream; NU i is the supply volume of node i, and TU is the total upstream supply; ND i is the sales volume of node i, and TD is the total downstream sales.
[0018] Preferably, the consensus success rate of node i
[0019]
[0020] Among them, is the number of successful consensus times of the i-th node, is the number of failures; is the consensus success ratio; formula (3) smooths the changes of rewards and punishments through the Sigmoid function to avoid extreme situations, and at the same time dynamically adjusts the ratio of rewards and punishments according to the consensus success rate of the nodes.
[0021] Preferably, the resource attribute Consider the impact of node resource constraints on the consensus process, including scoring in dimensions such as CPU, memory capacity, hard disk capacity, and network bandwidth. The calculation method is as shown in (4):
[0022]
[0023] Among them, represents the score of the i-th node in the j-th resource dimension (such as the number of CPU cores, memory, hard disk, bandwidth); μ j is the growth rate control parameter, and its values are 0.2, 0.01, 0.0005, and 0.1 respectively; is the specific value of the i-th node in the j-th resource dimension; w j is the weight of each resource dimension, which are 0.25, 0.25, 0.3, and 0.2 respectively.
[0024] Preferably, in step S3, during the node grouping stage, based on the comprehensive score and geographical location, use the improved K-medoids clustering algorithm to group the nodes, and select the clustering center node of each group as the leader node of the group; among the nodes in each group except the leader node, the node with the highest comprehensive score is used as the supervision node to form a multi-group consensus architecture.
[0025] Preferably, when grouping the nodes, the improved Euclidean distance calculation formula based on the comprehensive score and geographical location is as shown in (5):
[0026]
[0027] Among them, d(i,j) is the weighted Euclidean distance from node i to node j; (x i ,y i ) are the longitude and latitude of node i; (x j ,y j ) are the longitude and latitude of node j; S i and S j are the comprehensive scores of node i and node j respectively; w 1 ,w 2 ,w 3 are the weight coefficients of longitude, latitude, and comprehensive score respectively, and satisfy w 1 +w 2 +w 3 =1, and the coefficients can be adjusted according to actual needs.
[0028] Preferably, using the improved K-medoids clustering algorithm for node grouping includes the following steps:
[0029] (1) Initial center node selection: According to the comprehensive score of the nodes Select the nodes in the top 20% of the scoring rankings as candidate central nodes, randomly select k nodes from them as the initial central nodes, and divide the N nodes into k groups;
[0030] (2) Node assignment: Use the improved Euclidean distance formula to calculate the distances between each remaining node and the k central nodes, and assign the nodes to the group where the nearest central node is located; if the number of nodes in a certain group exceeds the threshold then assign the nodes to the group where the second-nearest central node is located until the nodes are added to a certain group;
[0031] (3) Central node update: For each group, calculate the sum of the distances from all nodes in the group to the central node as the target value, try to replace the candidate central node in the group with a new central node, and select the node with the smallest target value as the new central node;
[0032] (4) Repeat steps (2)-(3) until the central nodes of all groups no longer change. Finally, all nodes are assigned to k groups to form a multi-group consensus architecture.
[0033] Preferably, the consensus stage includes inter-group consensus and intra-group consensus. Among them, the central nodes of each group use the PBFT consensus protocol for inter-group consensus; within the group, consensus is achieved through the Raft protocol with the introduction of supervision nodes, thereby reducing the communication complexity and improving the consensus efficiency; at the same time, combined with the Brotli data compression technology, the network bandwidth is optimized, the data transmission volume is reduced, and the consensus efficiency is further improved; the hybrid consensus method based on the data compression technology includes the following steps:
[0034] (1) Execute PBFT consensus between groups, which is divided into four stages:
[0035] PBFT-REQUEST stage: According to the comprehensive scores of the central nodes of each group,
[0036] select the node with the highest score as the PBFT primary node, and the client sends a request message <PBFT-REQUEST,Client,M> to the primary node;
[0037] PBFT-PRE-PREPARE stage: The primary node uses the Brotli compression algorithm to compress the message body dig(M) in the pre-prepare message <PBFT-PRE-PREPARE,vId,nId,dig(M),i>, and then broadcasts the compressed message to other inter-group central nodes;
[0038] PBFT - PREPARE Phase: The central nodes between groups first decompress the received compressed pre - prepare messages and verify their content; if the verification passes, the nodes will compress the prepare message <PBFT - PREPARE, vId, nId, dig(M), i> using a compression algorithm and broadcast it to other inter - group nodes; when the central nodes between groups receive at least 2f valid prepare messages, they enter the next phase;
[0039] PBFT - COMMIT Phase: The central nodes between groups compress the commit message <PBFT - COMMIT, vId, nId, dig(M), i> using a compression algorithm and broadcast it to other inter - group consensus nodes; when a node receives at least 2f + 1 valid commit messages, it enters the intra - group consensus phase;
[0040] (2) Intra - group execution of Raft consensus
[0041] In the intra - group consensus phase, the central node of each group acts as the leader node, compresses the log message <AppendLog, nId, dig(msg), i> using the Brotli compression algorithm, and then broadcasts the compressed log to the intra - group follower nodes; after receiving the compressed log, the follower nodes cooperate with the supervisor nodes to complete the consensus and feedback information to the leader node;
[0042] The leader node counts the number of received append log prepare messages and records it as Count; when it reaches a consensus and commits the log;
[0043] (3) Reply Phase
[0044] PBFT - REPLY Phase: The central nodes between groups send a message indicating the completion of consensus <PBFT - REPLY, vId, timestamp, Client, i, res> to the client;
[0045] In the above process, vId represents the current view number, nId represents the current request number, M represents the message content, dig(M) represents the digest of message M, Client represents the client number, i represents the node number, f represents the number of Byzantine nodes, and res represents the request execution result.
[0046] Preferably, a supervisor node is introduced to improve the Raft consensus protocol to achieve data synchronization and Byzantine fault tolerance, specifically including:
[0047] During the execution of the Raft protocol, the leader node first broadcasts log entries to all follower nodes within the group;
[0048] After receiving the log, all follower nodes send the data to the supervisor node within the group for verification;
[0049] After receiving the data, the supervision node first performs legality and consistency verification to ensure that the log content has not been tampered with;
[0050] Subsequently, the supervision node uses the Secure Hash Algorithm (SHA) to calculate the digest of the log information and generates a verification message, which is broadcast to other supervision nodes; each supervision node will also receive verification messages from other supervision nodes;
[0051] When the supervision node receives more than valid verification messages, it broadcasts a confirmation message to all nodes in the group and continues to execute the subsequent steps of the Raft protocol; if it fails to receive enough valid verification messages within the specified time, it triggers the leader re-election mechanism and re-executes the in-chip consensus process.
[0052] Compared with the prior art, the beneficial effects of the present invention are as follows: by introducing a multi-index comprehensive scoring model, the present invention effectively improves the security of leader node election within the group. At the same time, the node grouping strategy combining comprehensive scoring and geographical location significantly enhances the organization and scalability of the consensus mechanism; adopting the PBFT and improved Raft hybrid consensus protocol ensures the consistency of data between and within groups while reducing the communication complexity and improving the consensus efficiency; by introducing the Brotli data compression technology, the size of communication messages is reduced, the network bandwidth occupancy is decreased, the network efficiency is effectively improved, and the latency is reduced; by introducing the supervision node, the security of in-group data synchronization is ensured. Overall, the present invention has significant advantages in improving the scalability of the existing consortium blockchain consensus mechanism, reducing the communication complexity, and improving the consensus efficiency, and is particularly suitable for scenarios such as supply chain traceability. Brief Description of the Drawings
[0053] The drawings are used to provide a further understanding of the present invention and constitute a part of the specification. They are used together with the embodiments of the present invention to explain the present invention and do not constitute a limitation to the present invention.
[0054] In the drawings:
[0055] Figure 1 is a flowchart of a blockchain hybrid consensus optimization method for supply chain traceability;
[0056] Figure 2 is a schematic diagram of the consensus process of a blockchain hybrid consensus optimization method for supply chain traceability;
[0057] Figure 3 is a graph of the comparison results of consensus latency under different numbers of nodes of the present invention;
[0058] Figure 4 is a graph of the comparison results of transaction throughput under different numbers of nodes of the present invention. Detailed implementation manners
[0059] The preferred embodiments of the present invention will be described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present invention, and are not used to limit the present invention.
[0060] Embodiment 1:
[0061] As Figure 1 shown, this is the first embodiment of the present invention. This embodiment provides a blockchain consensus optimization method for supply chain traceability, which includes three stages: node comprehensive scoring, node grouping, and node consensus, and specifically includes the following steps:
[0062] Step 1, construct a multi-index comprehensive scoring model for supply chain nodes.
[0063] In the supply chain network, the nodes participating in the consensus can include multiple types of nodes such as suppliers, retailers, and logistics service providers. The present invention first constructs a multi-index comprehensive scoring model. Taking several nodes in a certain supply chain as an example, in order to effectively evaluate these nodes. This model is based on the performance of nodes in the blockchain system in the supply chain, historical interaction behaviors, and resource attributes, and scores the nodes from the following several dimensions:
[0064] Service level According to the role of the node in the supply chain (such as upstream supplier or downstream retailer), calculate the supply ratio and sales ratio of the node in the upstream and downstream. The calculation formula is:
[0065]
[0066] Among them, is the supply ratio of node i in the upstream, is the sales ratio of node i in the downstream; NU i is the supply volume of node i, and TU is the total upstream supply volume; ND i is the sales volume of node i, and TU is the total downstream sales volume.
[0067] Consensus success rate The consensus success rate of a node measures the number of successes and failures in its historical consensus. The success rate of the node is smoothed through the Sigmoid function to avoid extreme changes. The calculation formula is:
[0068]
[0069] Among them, is the number of successful consensus of the i-th node, is the number of failures; is the consensus success rate. This formula smooths the changes in rewards and penalties through the Sigmoid function to avoid extreme situations, and at the same time dynamically adjusts the ratio of rewards and penalties according to the consensus success rate of the nodes.
[0070] Resource attribute Based on the computing resources of the nodes (such as CPU, memory, hard disk capacity, and network bandwidth, etc.), calculate the comprehensive score of its resources. The calculation formula is:
[0071]
[0072] Among them, represents the score of the i-th node in the j-th resource dimension (such as the number of CPU cores, memory, hard disk, bandwidth); μ j is the growth rate control parameter, and its values are 0.2, 0.01, 0.0005, 0.1 respectively; is the specific value of the i-th node in the j-th resource dimension; w j is the weight of each resource dimension, which are 0.25, 0.25, 0.3, 0.2 respectively.
[0073] The finally constructed comprehensive score model of nodes has the calculation formula:
[0074]
[0075] Among them, is the comprehensive score of the i-th node when reaching consensus in the t-th round, is the service level, is the consensus success rate, is the resource attribute, and α, β, γ, δ are the corresponding weight coefficients, and satisfy α + β + γ + δ = 1. By default, they are 0.4, 0.2, 0.2, 0.2, and can be dynamically adjusted according to the actual situation.
[0076] Step 2, Sort the comprehensive scores of the nodes.
[0077] At the beginning of each consensus cycle, calculate the comprehensive scores of each node through the comprehensive score model of nodes established in Step 1
[0078] Sort the scoring results from high to low. The sorted node list will be used as the basis for subsequent grouping.
[0079] Step 3, Use the improved K-medoids clustering algorithm to group the participating nodes.
[0080] Use the improved K-medoids algorithm to group the supply chain nodes. The specific process is as follows:
[0081] (1) Initial central node selection: According to the comprehensive scores of the nodes, select the nodes with the top 20% scores as candidate central nodes, and select k initial central nodes from them;
[0082] (2) Node allocation: Use the improved Euclidean distance formula to calculate the distances between each remaining node and the k central nodes, and allocate the nodes to the group where the nearest central node is located; if the number of nodes in a certain group exceeds the threshold then allocate the node to the group where the second-nearest central node is located until all nodes are allocated;
[0083] (3) Central node update: Update the central nodes according to the distances between the nodes in each group and the central nodes, and select new central nodes to minimize the sum of the distances of all nodes in the group;
[0084] (4) Iterative update: Repeat steps 2 and 3 until the central nodes of all groups no longer change, and finally determine the central nodes of each group.
[0085] Take the central node of each group as the leader node within the group, and select the node with the highest comprehensive score except the leader node in each group as the supervisor node to supervise the subsequent Raft consensus process within the group.
[0086] Furthermore, based on the comprehensive scores of the nodes and the geographical location, the improved Euclidean distance calculation formula is as follows:
[0087]
[0088] where d(i,j) is the weighted Euclidean distance from node i to node j; (x i ,y i ) are the longitude and latitude of node i; (x j ,y j ) are the longitude and latitude of node j; S i and S j are the comprehensive scores of node i and node j respectively; w 1 ,w 2 ,w 3 are the weight coefficients of longitude, latitude, and comprehensive score respectively, and satisfy w 1 +w 2 +w 3 =1, and the coefficients can be adjusted according to actual needs.
[0089] Combining the comprehensive scores of the nodes with geographical location information (longitude, latitude), by calculating the weighted Euclidean distance between each pair of nodes, group the nodes with high similarity to form a multi-group consensus architecture.
[0090] Step 4, a hybrid consensus method based on data compression technology is adopted for node consensus.
[0091] As Figure 2 shown, the specific steps of the hybrid consensus method are as follows:
[0092] (1) PBFT consensus is executed between groups, which is divided into four stages:
[0093] PBFT-REQUEST stage: According to the comprehensive scores of the central nodes of each group, the node with the highest score is selected as the PBFT primary node, and the client sends a request message <PBFT-REQUEST, Client, M> to the primary node.
[0094] PBFT-PRE-PREPARE stage: The primary node uses the Brotli compression algorithm to compress the message body dig(M) in the pre-prepare message <PBFT-PRE-PREPARE, vId, nId, dig(M), i>, and then broadcasts the compressed message to other inter-group central nodes.
[0095] PBFT-PREPARE stage: The node first decompresses the received compressed pre-prepare message and verifies its content. If the verification passes, the node will use the compression algorithm to compress the prepare message <PBFT-PREPARE, vId, nId, dig(M), i> and broadcast it to other inter-group nodes. When the inter-group central node receives at least 2f valid prepare messages, it enters the next stage;
[0096] PBFT-COMMIT stage: Each node uses the compression algorithm to compress the commit message <PBFT-COMMIT, vId, nId, dig(M), i> and broadcasts it to all inter-group consensus nodes. When the node receives at least 2f + 1 valid commit messages, it enters the intra-group consensus stage.
[0097] (2) The Raft consensus process is executed within the group
[0098] In the intra-group consensus stage, the central node of each group acts as the leader node, uses the Brotli compression algorithm to compress the log message <AppendLog, nId, dig(msg), i>, and then broadcasts the compressed log to the intra-group follower nodes. After receiving the compressed log, the follower nodes cooperate with the supervisor nodes to complete the consensus and feedback information to the leader node;
[0099] The leader node counts the number of received append log prepare messages and records it as Count. When this condition is met, the consensus is reached and the log is committed.
[0100] (3) Reply stage
[0101] PBFT - REPLY Phase: The central node between groups sends a message indicating the completion of consensus to the client <PBFT - REPLY, vId, timestamp, Client, i, res>.
[0102] In the above process, vId represents the current view number, nId represents the current request number, M represents the message content, dig(M) represents the digest of message M, Client represents the client number, i represents the node number, f represents the number of Byzantine nodes, and res represents the request execution result.
[0103] Furthermore, this embodiment also provides a Raft consensus mechanism with a supervision node introduced to enhance intra - group data synchronization and consistency guarantee. The specific implementation steps are as follows:
[0104] During the execution of the Raft protocol, the leader node first broadcasts log entries to all follower nodes within the group. These log entries contain transaction records or data operations of the new block and are transmitted in a strict order.
[0105] The follower nodes that receive the log entries send the data to the supervision node and wait for the verification result of the supervision node. Only after the supervision node confirms the legality and consistency of the data can the subsequent steps in the Raft protocol be continued to ensure the consistency and integrity of the data within the group.
[0106] Subsequently, the supervision node calculates the digest of the log information using the Secure Hash Algorithm (SHA) and generates verification messages, which are broadcast to other supervision nodes.
[0107] Each supervision node also receives verification messages from other supervision nodes.
[0108] If the supervision node receives more than valid verification messages, it broadcasts a confirmation message to all nodes within the group and continues with the subsequent steps of the Raft protocol, that is, the data can be officially submitted to the blockchain and stored.
[0109] If the supervision node does not receive a sufficient number of valid verification messages within the specified time (i.e., the number does not reach ), the leader re - election mechanism is triggered, and the in - slice consensus process is executed again. After the leader re - election, the new leader node restarts the Raft protocol and requests all follower nodes to resend their log data to ensure data consistency among all nodes in the blockchain.
[0110] The present invention effectively improves the security of in-group leader node election by introducing a multi-index comprehensive scoring model. At the same time, the node grouping strategy combining comprehensive scoring and geographical location significantly enhances the organization and scalability of the consensus mechanism; the hybrid consensus protocol of PBFT and improved Raft is adopted to ensure the consistency of data between and within groups, reduce the communication complexity, and improve the consensus efficiency; by introducing the Brotli data compression technology, the size of communication messages can be significantly reduced, the network bandwidth occupancy can be reduced, the network efficiency can be effectively improved, and the latency can be reduced; by introducing a supervision node, the security of in-group data synchronization is ensured. Overall, the solution of the present invention has significant advantages in improving the scalability of the existing consortium blockchain consensus mechanism, reducing the communication complexity, and improving the consensus efficiency, and is particularly suitable for scenarios such as supply chain traceability.
[0111] Example 2
[0112] Refer to Figure 3 - Figure 4 This is the second embodiment of the present invention. This embodiment provides a blockchain hybrid consensus optimization method for supply chain traceability. In order to verify the beneficial effects of the present invention, this embodiment will compare the performance of the traditional PBFT consensus method and the LRBFT consensus method in terms of the number of communications, consensus latency, throughput, etc., so as to demonstrate the effectiveness of this method.
[0113] I. Preparation of experimental environment
[0114] This test was carried out on a laptop equipped with an Intel Core i7-12700H processor and 16GB of memory, and the operating system was Windows 11. The experiment used the PyCharm 2023 software platform and implemented this method based on the Python programming language.
[0115] II. Experimental results
[0116] (1) Comparison results of consensus latency
[0117] Consensus latency is one of the important indicators to measure the performance of the consensus method. It refers to the time required from the node initiating the consensus request to the system reaching a consensus. The shorter the consensus latency, the better the performance of the consensus method. The calculation formula of the consensus latency is as follows:
[0118] T delay =T reply -T request ;
[0119] where T delay is the consensus latency, T reply is the time when the master node receives the reply message and the transaction is successful, and T request is the time when the client initiates the consensus request.
[0120] The comparison results of the consensus delay between this method and other methods are as follows Figure 3 shown. The experimental results show that this method is superior to the PBFT and LRBFT algorithms in terms of consensus delay. Especially in the scenario with a large number of nodes, the growth rate of delay is the slowest, indicating better scalability.
[0121] (2) Comparison results of transaction throughput
[0122] Transaction throughput TPS refers to the number of transactions or data processed by the system per unit time, usually expressed as the number of transactions processed per second. The calculation formula is as follows:
[0123]
[0124] where Δt represents the time interval required to process transactions, and Transaction Δt represents the number of transactions processed during this time period. In the experiment, by adjusting the number of nodes, the number of transactions that the system can process within one second was measured. The final test results are as follows Figure 4 shown.
[0125] The experimental results show that this method is superior to the traditional PBFT and LRBFT methods in terms of throughput. When the number of nodes is 20, the throughput of this method is approximately 1850 Tx / s, which is about 13% and 8.9% higher than that of PBFT and LRBFT respectively; when the number of nodes is 40, the throughput is about 1500 Tx / s, which is 36.3% and 25% higher than that of PBFT and LRBFT respectively. Even when the number of nodes further increases, this method still maintains a low throughput decay, demonstrating its superiority and adaptability in large-scale supply chain traceability scenarios.
[0126] (3) Message load analysis
[0127] Assume that 30 nodes participate in the consensus. Using the Brotli technology, this method compresses the messages sent to all consensus nodes during a consensus process. The specific effects are shown in Table 1 below.
[0128] Table 1 Message load analysis table
[0129] Consensus stage Before compression (byte) After compression (byte) Out-group consensus 3578 2870 In-group consensus 6045 5290
[0130] The experimental results show that after adopting the Brotli compression technology, the transmission volume of each message during the blockchain consensus process has been significantly reduced, effectively reducing the communication overhead, and thus improving the overall efficiency of the system.
[0131] (4) Communication overhead analysis
[0132] Communication overhead is a key metric for measuring the complexity of information interaction among nodes in a blockchain network to reach consensus. When the communication overhead is high, the system faces dilemmas such as increased latency, reduced throughput, and excessive consumption of network resources. Therefore, choosing an efficient consensus method can effectively reduce communication complexity and significantly improve the overall performance of the system.
[0133] Suppose there are N nodes participating in the supply chain traceability. The total communication time in the traditional PBFT consensus process is 2N 2 -N; The total communication time in the Raft consensus process is 2N - 2;
[0134] It can be seen that when the number of nodes N increases, the communication overhead of the PBFT protocol grows very fast, showing a quadratic growth trend, while the communication overhead of the Raft protocol grows linearly. For scenarios with a large number of nodes, the communication complexity of the PBFT protocol will become very high, which will lead to a significant decline in system performance.
[0135] The present invention provides a blockchain consensus method for supply chain traceability, which divides N nodes into k groups, and each group has approximately nodes;
[0136] The communication times of the consensus process of this method are calculated as follows:
[0137] The communication times for PBFT consensus in the inter-group consensus stage are 2k 2 -k;
[0138] In the intra-group consensus stage, the leader node broadcasts messages to the remaining followers and supervisors, and the communication times are The followers send messages to the supervisors for verification, and the communication times are The supervisors broadcast verification messages to the supervisors of other groups, and the communication times are k - 1; The supervisors send confirmation messages to the followers within the group, and the communication times are After the intra-group consensus is completed, the followers send commit messages to the leader node, and the communication times are
[0139] The total communication times of the hybrid consensus method for supply chain traceability are shown in the following formula:
[0140] T = 3k 2 + 4N - 5k;
[0141] When the number of nodes is large, adopting a grouping method can effectively reduce the communication complexity and avoid the sharp increase in communication overhead caused by the increase in the number of nodes in the PBFT protocol. Compared with the PBFT protocol, after adopting this method, as the number of nodes increases, the communication overhead will gradually approach that of the Raft protocol, ensuring high efficiency in large-scale supply chain traceability scenarios.
[0142] Generally speaking, compared with the existing consensus methods of consortium blockchains, the method of the present invention has significantly improved efficiency and performance, adapting to the characteristics of complex participating roles, strong liquidity, uneven node distribution, and large participation scale in supply chain traceability scenarios, demonstrating the innovation of this method.
[0143] Finally, it should be noted that the above are only preferred examples of the present invention and are not used to limit the present invention. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art can still modify the technical solutions recorded in the foregoing embodiments or perform equivalent replacements for some of the technical features. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.
Claims
1. A blockchain hybrid consensus optimization method for supply chain traceability, characterized in that: The following steps are involved: S1. In the comprehensive scoring stage, a multi-index comprehensive scoring model for supply chain nodes is first constructed; S2, calculate the comprehensive scores of participating nodes in the supply chain and rank them; S3. In the node grouping stage, the participating nodes are grouped according to their geographical location and comprehensive scores, and the leader nodes and supervisory nodes of each group are selected according to the comprehensive scores of the nodes to form a multi-group consensus architecture; S4. In the consensus stage, a hybrid consensus method based on data compression is adopted. First, inter-group consensus is carried out, and the PBFT consensus protocol is adopted between the central nodes of each group. After the inter-group consensus is completed, the intra-group consensus stage is entered. The improved Raft consensus protocol with the introduction of supervisory nodes is adopted. By introducing supervisory nodes, data synchronization and reliable communication between nodes are achieved. At the same time, Brotli data compression technology is introduced, and consensus is reached when the client receives enough consensus information.
2. A blockchain hybrid consensus optimization method for supply chain traceability according to claim 1, characterized in that: In step S1, in the comprehensive scoring stage, a node multi-index comprehensive scoring model is first constructed, and the comprehensive scores of participating nodes in the supply chain are evaluated at the beginning of each consensus cycle; this model is based on the performance, historical interaction behavior and resource attributes of nodes in the blockchain system in the supply chain, and comprehensively evaluates nodes from three dimensions: service level, consensus success rate and resource attributes. The calculation method is shown in formula (1): in, is the comprehensive score of the i-th node when reaching consensus in the t-th round, For service level, is the consensus success rate, are resource attributes, α, β, γ, and δ are corresponding weight coefficients, and satisfy α+β+γ+δ=1. The default values are 0.4, 0.2, 0.2, and 0.2, which are adjusted dynamically according to actual conditions.
3. A blockchain hybrid consensus optimization method for supply chain traceability according to claim 2, characterized in that: Described level of service The calculation is divided into upstream nodes and downstream nodes. The calculation method is shown in formula (2): in, is the supply ratio of node i in the upstream, is the sales proportion of node i in the downstream; NU i is the supply of node i, TU is the total upstream supply; ND i is the sales volume of node i, and TD is the total downstream sales volume.
4. A blockchain hybrid consensus optimization method for supply chain traceability according to claim 2, characterized in that: The consensus success rate The calculation formula is shown in (3): in, is the number of successful consensus of the i-th node, is the number of failures; is the consensus success rate; Formula (3) smoothes the changes in rewards and penalties through the Sigmoid function to avoid extreme situations, and dynamically adjusts the reward and penalty ratio according to the consensus success rate of the node.
5. The blockchain hybrid consensus optimization method for supply chain traceability according to claim 2 is characterized in that: The resource attributes Considering the impact of node resource limitations on the consensus process, including the scores of CPU, memory capacity, hard disk capacity, and network bandwidth, the calculation method is shown in (4): in, represents the score of the i-th node on the j-th resource dimension; μ j is the growth rate control parameter, and its values are 0.2, 0.01, 0.0005, and 0.1 respectively; is the specific value of the i-th node in the j-th resource dimension; w j are the weights of each resource dimension, which are 0.25, 0.25, 0.3, and 0.2 respectively.
6. The blockchain hybrid consensus optimization method for supply chain traceability according to claim 2 is characterized by: In step S3, at the node grouping stage, based on the comprehensive score The nodes are grouped using the improved K-medoids clustering algorithm based on their geographical locations, and the cluster center node of each group is selected as the leader node of the group. In addition to the leader node in each group, the node with the highest comprehensive score is used as the supervisory node to form a multi-group consensus architecture.
7. A blockchain hybrid consensus optimization method for supply chain traceability according to claim 6, characterized in that: When grouping nodes, based on the comprehensive score of the nodes The improved Euclidean distance calculation formula of the geographic location is shown in (5): Where d(i,j) is the weighted Euclidean distance from node i to node j; (x i ,y i ) is the longitude and latitude of node i; (x j ,y j ) is the longitude and latitude of node j; S i and S j are the comprehensive scores of node i and node j respectively; w1, w2, w3 are the weight coefficients of longitude, latitude and comprehensive score respectively, and satisfy w1+w2+w3=1. The coefficients can be adjusted according to actual needs.
8. The blockchain hybrid consensus optimization method for supply chain traceability according to claim 6 is characterized by: The improved K-medoids clustering algorithm is used to group nodes, including the following steps: (1) Initial central node selection: based on the comprehensive score of the node The top 20% of nodes in the scoring are selected as candidate central nodes, k nodes are randomly selected as initial central nodes, and N nodes are divided into k groups; (2) Node allocation: Use the improved Euclidean distance formula to calculate the distance between each remaining node and the k central nodes, and allocate the node to the group where the nearest central node is located; if the number of nodes in a group exceeds the threshold Then the node is assigned to the group where the next closest node is located until the node joins a group; (3) Central node update: For each group, the sum of the distances from all nodes in the group to the central node is calculated as the target value, and an attempt is made to replace the candidate central nodes in the group with new central nodes. The node with the smallest target value is selected as the new central node. (4) Repeat steps (2)-(3) until the central nodes of all groups no longer change. Eventually, all nodes are assigned to k groups, forming a multi-group consensus architecture.
9. The blockchain hybrid consensus optimization method for supply chain traceability according to claim 1 is characterized by: The consensus stage includes inter-group consensus and intra-group consensus. The central node of each group uses the PBFT consensus protocol to achieve inter-group consensus. The intra-group consensus is achieved by introducing the Raft protocol of the supervisory node. At the same time, combined with Brotli data compression technology, the network bandwidth is optimized, the data transmission volume is reduced, and the consensus efficiency is further improved. The hybrid consensus method based on data compression technology includes the following steps: (1) Consensus among groups PBFT-REQUEST phase: Based on the comprehensive score of each group of central nodes, Select the node with the highest score as the PBFT master node, and the client sends a request message to the master node<PBFT-REQUEST,Client,M> ; PBFT-PRE-PREPARE phase: The master node uses the Brotli compression algorithm to compress the prepared message<PBFT-PRE-PREPARE,vId,nId,dig(M),i> The message body dig(M) in the is compressed, and then the compressed message is broadcast to other inter-group central nodes; PBFT-PREPARE phase: The central node between each group first decompresses the compressed prepared message received and verifies its content; if the verification passes, the node will use the compression algorithm to decompress the prepared message.<PBFT-PREPARE,vId,nId,dig(M),i> Compress and broadcast it to other inter-group nodes; when the inter-group central node receives at least 2f valid preparation messages, it enters the next stage; PBFT-COMMIT phase: The central nodes between groups use compression algorithms to submit messages<PBFT-COMMIT,vId,nId,dig(M),i> Compress and broadcast to other inter-group consensus nodes; when the node receives at least 2f+1 valid submission messages, it enters the intra-group consensus phase; (2) Consensus within the group In the group consensus phase, the central node of each group acts as the leader node and uses the Brotli compression algorithm to compress log messages.<AppendLog,nId,dig(msg),i> Compress the data and then broadcast the compressed log to the follower nodes in the group. After receiving the compressed log, the follower nodes work with the supervisory nodes to complete the consensus and feedback the information to the leader node. The leader node counts the number of append log prepare messages received and records it as Count; When the time comes, consensus is reached and the log is submitted; (3) Resume phase PBFT-REPLY phase: The central node between groups sends a message to the client that the consensus is complete<PBFT-REPLY,vId,timestamp,Client,i,res> ; In the above process, vId represents the current view number, nId represents the current request number, M represents the message content, dig(M) represents the summary of message M, Client represents the client number, i represents the node number, f represents the number of Byzantine nodes, and res represents the request execution result.
10. The blockchain hybrid consensus optimization method for supply chain traceability according to claim 1 is characterized in that: The introduction of supervisory nodes improves the Raft consensus protocol to achieve data synchronization and Byzantine fault tolerance, including: During the execution of the Raft protocol, the leader node first broadcasts the log entry to all follower nodes in the group; After receiving the log, all follower nodes send the data to the supervisory node in the group for verification; After receiving the data, the supervisory node first verifies the legitimacy and consistency to ensure that the log content has not been tampered with; Subsequently, the supervisory node uses a secure hash algorithm to calculate the summary of the log information and generates a verification message, which is broadcast to other supervisory nodes. Each supervisory node also receives verification messages from other supervisory nodes. When the supervisory node receives more than After receiving a valid verification message, the confirmation message is broadcast to all nodes in the group and the subsequent steps of the Raft protocol are continued. If not enough valid verification messages are received within the specified time, the leader re-election mechanism is triggered and the on-chip consensus process is re-executed.
Citation Information
Cited By
Logistics supply chain collaborative optimization method and device based on knowledge graph, equipment, medium and program product
CN121032351A