An iot layered blockchain construction method and related device
By dynamically adjusting the accuracy and stability weights of candidate consensus nodes through a layered blockchain system, the problem of inaccurate consensus node selection under abnormal network conditions in traditional blockchain architectures is solved, achieving both secure local network consensus and efficient global network consensus.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- TIANJIN GUOLIAN ENERGY TECH CO LTD
- Filing Date
- 2026-03-12
- Publication Date
- 2026-06-05
AI Technical Summary
Traditional single-layer blockchain architectures suffer from throughput bottlenecks and high communication overhead when dealing with high-concurrency IoT data. Furthermore, they struggle to accurately select reliable consensus nodes under abnormal network conditions, leading to a decline in the security of local network consensus.
By adopting a layered blockchain system, the system dynamically adjusts the correlation weights of the accuracy and stability indicators of candidate consensus nodes by acquiring IoT business data collected at the device layer, eliminates nodes with a total reputation value lower than a preset threshold, and performs synchronized storage of blockchain blocks at the global layer, thereby reducing cross-regional communication overhead.
It improves the security of local network consensus and the consensus throughput of the global network under abnormal network conditions, reduces misjudgments caused by network fluctuations and attacks, and enhances the overall reliability and efficiency of the consensus network.
Smart Images

Figure CN122160391A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of blockchain technology, and in particular to a method for constructing a layered blockchain for the Internet of Things and related equipment. Background Technology
[0002] The massive amounts of data generated by the Internet of Things (IoT) urgently require blockchain technology to ensure security. However, traditional single-layer blockchain architectures suffer from throughput bottlenecks when dealing with high-concurrency IoT data. Network-wide broadcasting and consensus lead to extremely high communication overhead, reducing the efficiency of business data processing.
[0003] To address the aforementioned efficiency issues, existing technologies propose a blockchain construction method based on a multi-level architecture and scoring. This technology offloads some data processing to sub-networks. When selecting accounting nodes, fixed evaluation coefficients are assigned to each node based on its historical computing performance and device online time. A weighted comprehensive score is calculated, and high-scoring nodes are selected to form a local consensus network, thereby achieving initial node distribution and alleviating pressure on the main chain.
[0004] However, the underlying network of the open Internet of Things (IoT) is highly dynamic and often faces abnormal network conditions (such as signal oscillations and massive interference attacks). Because existing technologies use fixed evaluation coefficients, they lack the ability to adapt to changes in the network environment. When under abnormal network conditions, behavioral fluctuations caused by objective environmental interference are amplified or masked by these fixed coefficients (for example, honest nodes may be mistakenly filtered out due to a decrease in score caused by objective congestion, or malicious nodes may exploit fixed-weight vulnerabilities to cover up their violations and infiltrate the network). This makes it difficult to accurately select reliable consensus nodes under abnormal network conditions, reducing the security of local network consensus. Summary of the Invention
[0005] This application provides a method and related equipment for constructing a layered blockchain for the Internet of Things, which alleviates the technical problem of difficulty in accurately selecting reliable consensus nodes when facing abnormal network conditions, and improves the security of local network consensus.
[0006] Firstly, this application provides a method for constructing a layered blockchain for the Internet of Things (IoT), applied to a layered blockchain system. The layered blockchain system includes a device layer, a regional layer, and a global layer. The method includes: acquiring IoT business data collected by the device layer, using the IoT business data as the consensus payload, and determining candidate consensus nodes in the regional layer for processing the consensus payload; acquiring the accuracy index and stability index of each candidate consensus node, and acquiring the first correlation weight corresponding to the accuracy index and the second correlation weight corresponding to the stability index, where the accuracy index represents the consistency of the verification results and the stability index represents the network connection status; acquiring network operation status data of the communication network, including communication latency fluctuation amplitude, invalid message drop rate, and consensus drop rate; and when an invalid message drop rate or consensus drop rate is detected... When the rate exceeds the preset attack alarm threshold, the first association weight is adjusted according to the preset first adjustment coefficient, which is greater than 1. When the detected communication delay fluctuation is greater than the preset network oscillation threshold, the second association weight is adjusted according to the preset second adjustment coefficient, which is less than 1. Based on the final first association weight and the final second association weight, the accuracy and stability indicators of each candidate consensus node are weighted and fused to obtain the total reputation value of each candidate consensus node. Candidate consensus nodes with a total reputation value lower than the preset isolation threshold are eliminated, and the remaining candidate consensus nodes are determined as target consensus nodes. The target consensus node is controlled to perform weighted consensus on the consensus payload based on the total reputation value, generate blockchain blocks, and synchronize the blockchain blocks to the global layer nodes in the global layer for on-chain storage.
[0007] By adopting the above technical solution, the layered blockchain system first acquires network operation status data. When an increase in the invalid message drop rate or consensus drop rate is detected in the network operation status data, the first correlation weight of the accuracy indicator is increased; conversely, when excessive fluctuations in communication latency are detected, the second correlation weight of the stability indicator is decreased. This allows the layered blockchain system to adapt to changes in the network environment. Then, the layered blockchain system calculates the total reputation value of candidate consensus nodes based on the final first and second correlation weights, reflecting the reliability of nodes under the current network conditions. Finally, the layered blockchain system eliminates unreliable nodes below a preset isolation threshold based on the total reputation value and controls the remaining target consensus nodes to perform weighted consensus. This alleviates the technical problem of accurately selecting reliable consensus nodes when facing abnormal network conditions and improves the security of local network consensus.
[0008] In conjunction with some embodiments of the first aspect, in some embodiments, obtaining the accuracy and stability indicators of each candidate consensus node specifically includes: obtaining the historical accuracy indicators of each candidate consensus node in the previous consensus period, and the consistency judgment results of each candidate consensus node in the current consensus period, wherein the consistency judgment results indicate whether the data submitted by the candidate consensus node is consistent with the regional consensus results; obtaining a preset historical decay factor, and calculating the historical accuracy indicators and consistency judgment results by performing an exponentially weighted moving average based on the historical decay factor to obtain the accuracy indicators of each candidate consensus node; obtaining the online success rate data, average network latency data, and current network latency data of each candidate consensus node in the current consensus period, wherein the online success rate data represents the ratio of the number of successful communications of the candidate consensus node to the total number of communications; calling a preset nonlinear mapping function to process the difference between the average network latency data and the current network latency data to obtain the latency penalty data of each candidate consensus node, wherein the latency penalty data represents the first penalty coefficient for network latency fluctuations; and multiplying the latency penalty data by the online success rate data to obtain the stability indicators of each candidate consensus node.
[0009] By adopting the above technical solution, the layered blockchain system first calculates an exponentially weighted moving average of the historical accuracy index of candidate consensus nodes in the previous consensus cycle and the current consensus judgment result based on the historical decay factor. This ensures that the generated accuracy index retains historical credit records while smoothly reflecting current performance. Then, the layered blockchain system calls a non-linear mapping function to process the difference between the average network latency and the current network latency to generate latency penalty data. This latency penalty data is then combined with online success rate data to derive a stability index, avoiding linear misjudgments in stability evaluation caused by a single increase in latency. This method mitigates the interference of short-term network fluctuations and accidental behavioral deviations, improving the accuracy and stability index calculation precision.
[0010] In conjunction with some embodiments of the first aspect, in some embodiments, a preset historical decay factor is obtained, and an exponentially weighted moving average is calculated based on the historical decay factor to obtain the accuracy index of each candidate consensus node. Specifically, this includes: calculating the difference between the consistency judgment result of each candidate consensus node and the historical accuracy index to obtain the accuracy deviation value of each candidate consensus node; when the accuracy deviation value of a candidate consensus node is greater than or equal to a preset defection warning threshold, the preset historical decay factor is used as the first target decay factor of the candidate consensus node; when the accuracy deviation value of a candidate consensus node is less than the defection warning threshold, the behavioral fluctuation variance of the candidate consensus node within a preset time window is obtained, and a second penalty coefficient of the candidate consensus node is calculated based on the accuracy deviation value and behavioral fluctuation variance of the candidate consensus node; the preset historical decay factor is obtained, and the historical decay factor is multiplied by the second penalty coefficient to obtain the second target decay factor of the candidate consensus node; based on the first target decay factor or the second target decay factor of each candidate consensus node, an exponentially weighted moving average is calculated based on the historical accuracy index and the consistency judgment result to obtain the accuracy index of each candidate consensus node.
[0011] By employing the aforementioned technical solution, the layered blockchain system first calculates the difference between the consensus judgment result of candidate consensus nodes and historical accuracy indicators to obtain an accuracy deviation value, reflecting the degree of short-term abrupt changes in node behavior. Then, when the accuracy deviation value is less than a warning threshold, the layered blockchain system calculates a second penalty coefficient based on the variance of the candidate consensus node's behavior fluctuation within a preset time window, and adjusts the historical decay factor accordingly to obtain a second target decay factor, thus reducing the weight of abnormal nodes' historical high reputation in the current indicator calculation. Finally, candidate consensus nodes perform calculations based on the adjusted target decay factor to effectively identify indicator feedback for sudden node violations. This method alleviates the problem of nodes using previously accumulated high reputation to mask recent abnormal behavior and improves the sensitivity of identifying defective nodes.
[0012] In conjunction with some embodiments of the first aspect, in some embodiments, based on the final first association weight and the final second association weight, the accuracy index and stability index of each candidate consensus node are weighted and fused to obtain the total reputation value of each candidate consensus node. Specifically, this includes: obtaining the participation index and the third association weight corresponding to the participation index of each candidate consensus node, wherein the participation index is determined based on the response time ranking of the candidate consensus node in the current consensus period; and performing a weighted summation calculation on the accuracy index, stability index, and participation index based on the final first association weight, the final second association weight, and the third association weight to obtain the total reputation value of each candidate consensus node.
[0013] By adopting the above technical solution, the layered blockchain system first determines the participation index based on the response time ranking of candidate consensus nodes within the current consensus cycle. This index reflects the node's enthusiasm for participating in consensus interactions. Then, the layered blockchain system introduces a third association weight corresponding to the participation index, and performs a weighted summation calculation with the accuracy index, stability index, and their respective final weights to obtain the total reputation value of the candidate consensus nodes. This multi-dimensional fusion calculation method avoids misselecting passive nodes at the network edge as target consensus nodes based solely on connectivity, thereby improving the overall activity of candidate consensus nodes in the local consensus network.
[0014] In conjunction with some embodiments of the first aspect, in some embodiments, candidate consensus nodes whose total reputation value is lower than a preset isolation threshold are removed, and the remaining candidate consensus nodes are determined as target consensus nodes. Specifically, this includes: obtaining a preset alarm threshold, where the preset alarm threshold is greater than a preset isolation threshold; when the total reputation value of a candidate consensus node is less than the preset alarm threshold and the total reputation value of a candidate consensus node is greater than or equal to the preset isolation threshold, assigning the corresponding candidate consensus node to a gray list node set; when the total reputation value of a candidate consensus node is less than the preset isolation threshold, assigning the corresponding candidate consensus node to a blacklist node set, and performing communication isolation on the candidate consensus nodes in the blacklist node set in the regional layer network; and determining the remaining candidate consensus nodes other than the gray list node set and the blacklist node set as target consensus nodes.
[0015] By employing the aforementioned technical solution, the layered blockchain system first obtains preset alarm thresholds and preset isolation thresholds that are distributed in a gradient. Then, the layered blockchain system blacklists candidate nodes with total reputation values below the preset isolation threshold and performs communication isolation within the regional layer network, cutting off the pathway for extremely low-reputation nodes to send invalid messages and interfere with the consensus process. Next, the layered blockchain system places nodes between the alarm threshold and the isolation threshold into a gray list, achieving marginalization of potentially unreliable nodes. Finally, the layered blockchain system establishes the candidate nodes other than those on the gray and black lists as target consensus nodes, achieving control over nodes at different reputation levels.
[0016] In conjunction with some embodiments of the first aspect, in some embodiments, synchronizing blockchain blocks to global layer nodes in the global layer for on-chain storage specifically includes: controlling each global layer node in the global layer to probe each other's round-trip latency and constructing the network coordinates of each global layer node based on the round-trip latency; calling a clustering algorithm to perform clustering calculations on the network coordinates of each global layer node to obtain multiple logical groups, each logical group containing at least one global layer node; obtaining the node global reputation and load data of each global layer node, determining the group leader node in each logical group based on the node global reputation and load data, where the node global reputation represents the reliability of the global layer node in the historical global consensus process; controlling the global layer nodes in each logical group and the group leader node of each logical group to perform consensus interaction and append the blockchain block to the global blockchain.
[0017] By employing the aforementioned technical solution, the layered blockchain system first controls global layer nodes to probe each other's round-trip latency and construct network coordinates. Then, based on these network coordinates, the layered blockchain system uses a clustering algorithm to divide physically close nodes into multiple logical groups, structuring the originally dispersed global network. Next, the layered blockchain system, considering the global reputation and load data of the nodes, elects a reliable group leader node with sufficient processing power from each logical group. Finally, the layered blockchain system controls the hierarchical interaction between nodes within each logical group and the group leader node to append blockchain blocks, reducing high-frequency direct communication between geographically distant nodes and shortening the on-chain latency of blockchain blocks in the global network.
[0018] In conjunction with some embodiments of the first aspect, in some embodiments, controlling the global layer nodes within each logical group and the group leader nodes of each logical group to perform consensus interaction and append blockchain blocks to the global blockchain specifically includes: controlling each global layer node within the logical group to generate a feedback signature for the blockchain block and sending the feedback signature to the corresponding group leader node; when the number of feedback signatures collected by the group leader node meets a preset threshold, compressing the collected feedback signatures into a single aggregate signature and generating a commit message with the single aggregate signature; controlling the group leader nodes of each logical group to broadcast commit messages to each other to complete global consensus verification and append the blockchain block to the global blockchain.
[0019] By employing the aforementioned technical solution, the layered blockchain system first controls the global layer nodes within each logical group to send feedback signatures for blockchain blocks to the group leader nodes for centralized collection. This consolidates the signature verification requests, which were originally distributed across the entire network, into the group leader nodes of each group. Then, when the collected feedback signatures meet a preset threshold, the layered blockchain system compresses a large number of independent feedback signatures into a single aggregate signature and encapsulates it to generate a commit message, reducing the data volume of the consensus message. Finally, the layered blockchain system controls the group leader nodes of each logical group to complete global consensus verification by broadcasting commit messages to each other. This method alleviates the network bandwidth consumption caused by broadcasting a large number of independent signatures and improves the consensus throughput of the global layer network.
[0020] In conjunction with some embodiments of the first aspect, in some embodiments, acquiring IoT service data collected at the device layer, using the IoT service data as the consensus payload, and determining candidate consensus nodes in the regional layer for processing the consensus payload specifically includes: acquiring IoT service data through IoT devices in the device layer, obtaining the device key preset by the IoT device and the current timestamp; performing hash calculation on the IoT service data and timestamp using the device key to obtain authentication information of the IoT service data; generating a target local block based on the authentication information, timestamp, and hash value of the previous local block, and appending the target local block to the local blockchain maintained by the IoT device, so as to use the IoT service data as the consensus payload; sending the block status information of the local blockchain to the corresponding regional gateway, and determining the regional gateway as a candidate consensus node.
[0021] By adopting the above technical solution, the layered blockchain system first uses the device keys and timestamps of IoT devices to perform hash calculations on the business data collected at the lower level to generate authentication information, giving the source data unique and tamper-proof cryptographic characteristics. Then, the layered blockchain system combines the authentication information, timestamp, and the hash value of the previous local block to generate the target local block and appends it to the local blockchain, completing the structured solidification of business data at the device end. Finally, the layered blockchain system sends the block state information of the local blockchain to the regional gateway, enabling the regional gateway to participate in the processing as a candidate consensus node based on this state. This method constructs a trusted data transmission chain from the device layer to the regional layer, ensuring the integrity and authenticity of the consensus payload submitted to the regional gateway during transmission.
[0022] In a second aspect, this application provides a layered blockchain system, including one or more processors and a memory; the memory is coupled to the one or more processors, and the memory is used to store computer program code, the computer program code including computer instructions, which the one or more processors call to cause the layered blockchain system to perform the methods described in the first aspect and any possible implementation thereof.
[0023] Thirdly, this application provides a computer-readable storage medium including computer instructions that, when executed on a hierarchical blockchain system, cause the hierarchical blockchain system to perform the methods described in the first aspect and any possible implementation thereof.
[0024] One or more technical solutions provided in the embodiments of this application have at least the following technical effects or advantages: 1. By employing network operation status data including communication delay fluctuations, invalid message drop rates, and consensus drop rates, and dynamically and adaptively adjusting the correlation weights of accuracy and stability indicators of candidate consensus nodes based on this data, the technical problem of lacking adaptive capability when facing abnormal network conditions using fixed evaluation coefficients is effectively alleviated. This leads to the amplification or masking of behavioral fluctuations caused by objective environmental interference in nodes. Consequently, it achieves the technical effect of accurately selecting reliable consensus nodes in highly dynamic IoT networks and improving the security of local network consensus.
[0025] 2. By employing a technical approach that calculates the accuracy deviation of candidate consensus nodes, dynamically adjusts the historical decay factor for nodes with abnormal deviations based on their behavioral fluctuation variance, and then calculates the accuracy index based on the dynamic decay factor, the technical problem of slow response to sudden malicious behavior by nodes, which allows malicious nodes to use their previously accumulated high historical reputation to cover up their recent violations, is effectively mitigated. This approach enables the keen detection of sudden changes in node behavior and weakens their historical high reputation weight, thereby quickly cutting off the continuous occupation of physical wireless communication channels by malicious nodes and preventing the entire network from being paralyzed by flooding attacks. In this way, the technical effectiveness of the consensus network in identifying and punishing suddenly defecting nodes is improved.
[0026] 3. By employing clustering and grouping based on the round-trip latency of global layer nodes, and combining node global reputation and load data to determine the group leader node in each logical group, and completing the global consensus and on-chaining of blockchain blocks through interaction within the logical group, the technical problem of high cross-regional long-distance communication overhead and high on-chain latency caused by disordered broadcasting across the entire network during global consensus in the traditional single-layer blockchain architecture is effectively alleviated. This achieves the technical effect of deeply binding the underlying physical space distribution with the upper-layer blockchain logical grouping, significantly reducing redundant cross-domain communication, and shortening the on-chain latency of blockchain blocks in the global network. Attached Figure Description
[0027] Figure 1 This is a schematic diagram of the overall architecture of the layered blockchain system in the embodiments of this application; Figure 2This is a flowchart illustrating the IoT layered blockchain construction method in this application embodiment; Figure 3 This is another flowchart illustrating the IoT layered blockchain construction method in this application embodiment; Figure 4 This is a schematic diagram of the physical device structure of a layered blockchain system in this application embodiment. Detailed Implementation
[0028] The terminology used in the following embodiments of this application is for the purpose of describing particular embodiments only and is not intended to be limiting of this application. As used in the specification and appended claims of this application, the singular expressions “a,” “an,” “the,” “the,” “the,” and “this” are intended to include the plural expressions as well, unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in this application refers to any or all possible combinations including one or more of the listed items.
[0029] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as implying or suggesting relative importance or implicitly indicating the number of indicated technical features. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature, and in the description of the embodiments of this application, unless otherwise stated, "multiple" means two or more.
[0030] Please see Figure 1 This is a schematic diagram of the overall architecture of a layered blockchain system in an embodiment of this application. Figure 1 As shown, the layered blockchain system adopts a three-layer pyramid-shaped ecosystem architecture: "Device Layer - Regional Layer - Global Layer". The Device Layer, at the bottom, is responsible for self-verification and solidifying the source authentication information of IoT business data through the microchain structure. The Regional Layer, as the middle layer, consists of multiple regional gateways and is responsible for multi-dimensional reputation calculation and local weighted consensus on the data from the Device Layer. The Global Layer, at the top, consists of high-performance nodes and achieves global consistency of blockchain blocks on the blockchain based on topology grouping. Data is generated by the Device Layer, aggregated and consensus-driven by the Regional Layer, and finally flows to the Global Layer to complete network-wide synchronization.
[0031] The method provided in this embodiment is described in detail below. Please refer to [link / reference]. Figure 2 This is a flowchart illustrating the IoT layered blockchain construction method in this application embodiment.
[0032] 101. Obtain IoT business data collected at the device layer, use the IoT business data as the consensus payload, and determine the candidate consensus nodes in the regional layer for processing the consensus payload.
[0033] The device layer refers to the lowest level of the IoT device collection in the layered blockchain system, including various sensors, smart terminals, and other IoT devices. IoT business data represents the raw data generated by IoT devices in the device layer during business operations, such as temperature values collected by temperature sensors and image data captured by cameras. The consensus payload represents the data carrier that needs to be verified for consensus at the regional layer; it is a data unit to be processed formed by structured encapsulation of IoT business data. The regional layer is the intermediate layer between the device layer and the global layer in the layered blockchain system. It is responsible for achieving local consensus on the data uploaded from the device layer and maintaining the regional layer blockchain (referred to as the regional chain). Candidate consensus nodes represent network nodes in the regional layer that are qualified to participate in consensus, typically including regional gateways, edge servers, and other node devices with certain computing and storage capabilities.
[0034] Specifically, the layered blockchain system first continuously monitors the communication ports of various IoT devices in the device layer through network interfaces. When new IoT business data is detected, the layered blockchain system securely collects and extracts this IoT business data. Subsequently, the layered blockchain system formats and encapsulates the extracted IoT business data, transforming and defining it as the consensus payload to be processed in this round of consensus. Next, based on the data characteristics, source region, and load status of each node in the current regional layer network, the layered blockchain system filters and determines candidate consensus nodes in the regional layer that can be responsible for processing the consensus payload.
[0035] In some embodiments, during the process of determining candidate consensus nodes, the layered blockchain system utilizes IoT devices at the device layer to establish an "edge self-certification" mechanism. By hashing business data and timestamps using device keys to generate authentication information and constructing the local block, the originality of the data before it enters the regional layer is ensured. When the regional gateway receives local blockchain state information, it is established as a candidate consensus node based on this self-certification state, thereby transferring the security attributes of the physical layer to the consensus layer.
[0036] Specifically, the layered blockchain system collects IoT business data through IoT devices in the device layer, obtaining the device key and current timestamp preset by the IoT device. The device key is a unique encryption key pre-set during the initial configuration of the IoT device, used for authentication and encryption protection of the data generated by the device; the timestamp records the precise moment of data collection, providing a basis for subsequent data traceability and time-series verification. The layered blockchain system uses the device key to perform keyed message digest calculation on the IoT business data and timestamp. Using the device key as the key parameter for HMAC operation, the HMAC-SHA256 algorithm is used to concatenate the IoT business data and timestamp as message input to generate a fixed-length message authentication code, obtaining the authentication information of the IoT business data. This authentication information simultaneously possesses uniqueness, irreversibility, and verifiability: any tampering with the original business data or timestamp content will result in a change to the authentication information; and only a legitimate verifier holding the same device key can verify the authentication information, effectively preventing the authentication information from being forged.
[0037] The layered blockchain system generates a target local block based on authentication information, timestamps, and the hash value of the previous local block, according to a predetermined block structure. The block header contains metadata such as version number, previous block hash, and timestamp, while the block body contains authentication information and IoT business data. This target local block is appended to the local blockchain maintained by the IoT device, forming a continuous chain structure to solidify and store the IoT business data as the consensus payload. To adapt to the limited computing power and storage space of the underlying IoT devices, the local blockchain is configured as a lightweight microchain structure. The IoT device only retains the block header hash value status of the most recent few periods in its local circular cache using a round-robin approach, eliminating the need for full ledger storage and complex consensus broadcasting, thus achieving cryptographic self-verification of the source data with extremely low power consumption. The layered blockchain system sends the block status information of the local blockchain to the corresponding regional gateway. This block status information includes the latest block height, block hash value, and cumulative transaction count. Upon receiving this information, the regional gateway uses it as a candidate consensus node to participate in the subsequent regional layer consensus process, preparing for the verification and on-chaining of the consensus payload.
[0038] 102. Obtain the accuracy and stability metrics of each candidate consensus node, and obtain the first correlation weight corresponding to the accuracy metric and the second correlation weight corresponding to the stability metric. The accuracy metric represents the consistency of the verification results, and the stability metric represents the status of network connectivity.
[0039] Accuracy metrics are quantitative indicators used to measure the consistency between the verification results submitted by candidate consensus nodes during the consensus process and the final regional consensus results. Values typically range from 0 to 1, with higher values indicating higher verification accuracy. Stability metrics are comprehensive evaluation indicators representing the network connection quality and communication stability of candidate consensus nodes, reflecting their ability to maintain normal communication in a network environment. Verification result consistency indicates the degree of agreement between the results obtained by candidate consensus nodes after independent verification of the consensus payload and the final regional consensus results. Network connection status refers to the quality of communication links between candidate consensus nodes and other nodes, including network performance parameters such as connection success rate, transmission delay, and packet loss rate. The first correlation weight represents the weighting coefficient of the accuracy metrics when calculating the total reputation value of candidate consensus nodes; the second correlation weight represents the weighting coefficient of the stability metrics when calculating the total reputation value of candidate consensus nodes.
[0040] Specifically, the layered blockchain system first extracts historical behavior records of each candidate consensus node from the node management module of the regional layer. This includes the verification results submitted by each node in past consensus cycles, the number of times it participated in consensus, and the matching status between its verification results and the final consensus result. Through statistical analysis, an accuracy index is calculated for each candidate consensus node. For example, if node A's verification results match the final consensus in 95 out of the past 100 consensus cycles, its accuracy index is 0.95. Simultaneously, the layered blockchain system collects real-time network status data of each candidate consensus node through its network monitoring module. This includes parameters such as node online time, average response time, network latency fluctuations, and packet loss rate. These parameters are then used to calculate a stability index. For example, a weighted average is used to combine online rate (60%) and latency stability (40%) in the calculation. The layered blockchain system reads the initial values of the first and second association weights preset for the current consensus cycle from the configuration file or smart contract (the first and second association weights are the initial weight values for the current consensus cycle). These initial weight values are preset based on historical experience and network environment. For example, in a normal network environment, the first association weight is set to 0.6 and the second association weight is set to 0.4, indicating that the accuracy index is slightly more important than the stability index.
[0041] It should be noted that accuracy and stability metrics are the two core dimensions for evaluating the reputation of candidate consensus nodes. In practical applications, the evaluation dimensions can be expanded according to business needs. For example, auxiliary dimensions such as participation can be further introduced. These auxiliary dimensions, together with the core dimensions, constitute the basic data source of the overall reputation evaluation system.
[0042] 103. Obtain network operation status data of the communication network in which it is located. The network operation status data includes communication delay fluctuation range, invalid message drop rate and consensus drop rate.
[0043] Network operation status data represents a set of real-time monitoring data reflecting the current operation and performance of the communication network; communication latency fluctuation amplitude is used to represent the degree of change in data packet transmission latency in the network, which is quantified by calculating the standard deviation or variance of the latency value within a certain time window, and the unit is usually milliseconds; invalid packet drop rate refers to the proportion of packets dropped during network transmission due to format errors, verification failures, timeouts, etc., out of the total number of packets sent, reflecting the degree of abnormal traffic or malicious attacks in the network; consensus drop rate represents the proportion of consensus requests that are dropped during the consensus process due to node failures, verification failures, timeouts, etc.
[0044] Specifically, the layered blockchain system collects network operation data through monitoring agents deployed on various network nodes, employing a combination of active probing and passive eavesdropping. To obtain the amplitude of communication latency fluctuations, the layered blockchain system continuously sends probe packets within a preset time window (e.g., the last 5 minutes) and records the round-trip time (RTT). It calculates the average and standard deviation of these RTT values; the standard deviation represents the amplitude of communication latency fluctuations. For example, an average latency of 50ms and a standard deviation of 20ms indicate significant network latency fluctuations. To obtain the invalid packet drop rate, the layered blockchain system records the total number of received packets and the number of packets dropped for various reasons using a statistical counter on the network interface. It calculates the ratio of dropped packets to the total number of packets. For example, if 500 out of 10,000 received packets are dropped, the invalid packet drop rate is 5%. To obtain the consensus abandonment rate, the layered blockchain system counts the total number of consensus requests initiated within the current consensus cycle and the number of consensus requests abandoned due to timeouts, verification failures, etc., and calculates the ratio of the two to obtain the consensus abandonment rate. For example, if 10 out of 100 consensus requests are abandoned, the consensus abandonment rate is 10%. The layered blockchain system stores this real-time collected network operation status data in a time-series database.
[0045] In some embodiments, comprehensive acquisition and accurate measurement of network operation status data can be achieved in the following ways: The hierarchical blockchain system adopts a distributed network monitoring architecture, deploying multiple monitoring nodes at different levels and locations of the network. Each monitoring node is responsible for collecting network status data within its coverage area. The time consistency of data from each monitoring point is ensured through a time synchronization protocol. Then, the dispersed monitoring data is aggregated to a central analysis platform, and the overall network operation status indicators are calculated using a data fusion algorithm. For example, a weighted average method is used to process delay data from different monitoring points, with the weights determined based on the importance and coverage of the monitoring points.
[0046] 104. When the invalid message drop rate or consensus drop rate is detected to be greater than the preset attack alarm threshold, the first association weight will be adjusted according to the preset first adjustment coefficient, which is greater than 1.
[0047] The preset attack alarm threshold is a critical value used to determine whether the network has suffered an abnormal attack. It is usually preset based on historical data and security policies. The first adjustment coefficient is a multiplier factor used to adjust the first correlation weight, which is used to amplify the weight of the accuracy index in the calculation of the total reputation value.
[0048] Specifically, when the layered blockchain system detects an increase in the invalid message drop rate or consensus drop rate in the network, this usually indicates that the network is under malicious attack or that there are a large number of abnormal nodes. The layered blockchain system continuously monitors network operation status data and compares the invalid message drop rate and consensus drop rate with preset attack alarm thresholds in real time. For example, when the invalid message drop rate exceeds 15% or the consensus drop rate exceeds 15%, an adjustment mechanism is triggered. At this time, the layered blockchain system immediately initiates a weight adjustment process, obtains a pre-configured first adjustment coefficient (e.g., 1.5 or 2.0), and multiplies the current first association weight with the first adjustment coefficient to obtain the adjusted final first association weight. The core logic of the adjustment strategy is that in an attack scenario, the network stability of a node may decrease due to interference from the objective environment, but the verification accuracy, as an intrinsic attribute of the node, better reflects its true reliability. Therefore, by increasing the weight of the accuracy indicator, the consideration of the node's historical credit and verification consistency is strengthened, weakening the impact of network fluctuations on node evaluation, thereby more effectively identifying and screening out truly reliable consensus nodes and preventing malicious nodes from using network chaos to cover up their improper behavior and infiltrate the consensus network.
[0049] Setting the first adjustment coefficient greater than 1: When the network is under attack, the stability indicators of each node in the regional layer generally decline due to physical layer interference. At this time, the stability indicators can no longer accurately distinguish between the performance degradation caused by objective congestion and the abnormal behavior caused by node deliberate malicious actions, and their reference value is reduced accordingly. In contrast, the accuracy indicator reflects the logical consistency of the data submitted by the node, has a stronger resistance to physical layer network noise, and can more realistically reflect the reliability of the node. By dynamically amplifying the first association weight, the layered blockchain system can shift the evaluation focus to the accuracy dimension under attack conditions, enhance the ability to identify and screen malicious nodes, and reduce the probability of them successfully using the chaotic network environment to cover up abnormal behavior.
[0050] In some embodiments, the adaptive adjustment of the first associated weight can be achieved in the following way: The hierarchical blockchain system adopts a dynamic decay adjustment method. After the adjustment is triggered, the first adjustment coefficient is dynamically calculated based on the duration and intensity of the attack. The mapping relationship between the adjustment coefficient and the attack index is established through an exponential function or a logarithmic function. When the attack is relieved, the adjustment coefficient is gradually reduced so that the weight smoothly returns to the normal value, avoiding the impact of sudden weight changes on the consensus network.
[0051] 105. When the communication delay fluctuation is detected to be greater than the preset network oscillation threshold, the second correlation weight is adjusted according to the preset second adjustment coefficient, which is less than 1.
[0052] The preset network oscillation threshold is a critical value used to determine whether there are abnormal fluctuations in network communication latency, reflecting the acceptable range of network stability; the second adjustment coefficient is a multiplier factor used to adjust the second correlation weight, which is used to reduce the weight ratio of stability indicators in the calculation of total reputation value.
[0053] Specifically, when the hierarchical blockchain system detects severe latency fluctuations in the network, it indicates that the network environment is extremely unstable, and the stability indicators of all nodes may be affected. The hierarchical blockchain system analyzes the communication latency fluctuation amplitude data in real time and compares it with a preset network oscillation threshold. For example, when the latency standard deviation exceeds 50ms or the latency volatility exceeds 200% of the normal value, the network is determined to be in an oscillation state. The hierarchical blockchain system then obtains a pre-set second adjustment coefficient (e.g., 0.5 or 0.3), multiplies the current second association weight by the second adjustment coefficient, and obtains the adjusted final second association weight. The design principle of the adjustment mechanism is that in a network oscillation environment, even normal nodes will experience unstable connections and increased latency. At this time, the stability indicators can no longer accurately reflect the true reliability of the nodes, and may even lead to a large number of honest nodes being mistakenly judged as unreliable nodes and wrongly removed due to objective network reasons. By reducing the weight of the stability indicators, the interference of network environment factors on node evaluation is reduced, and the evaluation focus is shifted to accuracy indicators that better reflect the intrinsic quality of the nodes. This ensures that the reliability of each node can be fairly evaluated even under severe network conditions, and avoids wrongly harming honest nodes due to short-term network fluctuations.
[0054] The second adjustment coefficient is set to less than 1: Under network turbulence conditions, the stability indicators of all nodes within the regional layer generally decline due to objective network fluctuations. If the original weights of the stability indicators are maintained, a large number of honest nodes will be incorrectly removed due to increased objective latency, drastically reducing the number of available target consensus nodes in the regional layer and threatening the normal operation of the consensus process. By dynamically compressing the second correlation weight, the layered blockchain system can reduce the interference of objective network jitter on node evaluation results, avoid large-scale misjudgments caused by short-term latency fluctuations, maintain a sufficient number of target consensus nodes in the consensus network under adverse network conditions, and ensure the continuity and stability of the regional layer consensus process.
[0055] In some embodiments, the adaptive reduction of the second correlation weight can be achieved in the following way: The hierarchical blockchain system adopts the volatility correlation adjustment method, dynamically calculates the second adjustment coefficient according to the multiple by which the communication delay fluctuation exceeds the threshold, and establishes an inverse proportional function relationship between the fluctuation amplitude and the adjustment coefficient. For example, when the fluctuation amplitude is 1.5 times the threshold, the coefficient is 0.7, when it is 2 times, the coefficient is 0.5, and when it is more than 3 times, the coefficient drops to 0.3. At the same time, a lower limit of weight (such as 0.1) is set to ensure that the stability index still retains its basic influence.
[0056] 106. Based on the final first association weight and the final second association weight, the accuracy index and stability index of each candidate consensus node are weighted and fused to obtain the total reputation value of each candidate consensus node.
[0057] The final first correlation weight refers to the accuracy index weight value after adjustment in step 104, which may be the initial value or the adjusted value; the final second correlation weight refers to the stability index weight value after adjustment in step 105, which may be the initial value or the adjusted value; the total reputation value represents the quantitative score of the overall reliability of the candidate consensus node, which is the final result of the weighted calculation of multi-dimensional indicators.
[0058] Specifically, the layered blockchain system obtains the accuracy and stability metrics of each candidate consensus node, along with adjusted first and second association weights. The layered blockchain system performs a weighted fusion calculation on each candidate consensus node: before the fusion calculation, it first normalizes the final first and second association weights to ensure that the sum of their dynamic weight ratios always equals 1, thus guaranteeing that the output total reputation value is strictly limited to a preset quantization range of 0 to 1. Subsequently, the layered blockchain system multiplies the node's accuracy metric by the adjusted first association weight and its stability metric by the adjusted second association weight, then adds the two products to obtain the candidate consensus node's total reputation value. For example, if a candidate consensus node has an accuracy metric of 0.85, a stability metric of 0.75, an adjusted first association weight of 0.7, and an adjusted second association weight of 0.3, then its total reputation value = 0.85 × 0.7 + 0.75 × 0.3 = 0.82. The hierarchical blockchain system performs this calculation on each candidate consensus node, obtaining a total reputation value for each node, and then sorts and stores these reputation values to provide a basis for subsequent node selection. This method can comprehensively consider multiple characteristics of nodes and adapt to changes in the network environment through dynamically adjusted weight coefficients, ensuring accurate evaluation of node reliability under different network conditions.
[0059] Furthermore, if the layered blockchain system simultaneously detects concurrent extreme conditions where the invalid message drop rate exceeds the preset attack alarm threshold (under attack) and the communication latency fluctuation exceeds the preset network oscillation threshold (network oscillation), the system will activate a security priority strategy. It will first execute the first adjustment coefficient to amplify the weight of the accuracy indicator, and then normalize and proportionally compress the weight of the stability indicator. This will ensure the physical network's resistance to interference while prioritizing the interception of malicious node penetration.
[0060] In some embodiments, the hierarchical blockchain system obtains the participation index and the corresponding third association weight for each candidate consensus node. The participation index is determined based on the response time ranking of candidate consensus nodes within the current consensus period; the shorter the response time, the higher the ranking and the higher the participation index. For example, the participation index of the first-ranked node is 1.0, decreasing with each subsequent node. The hierarchical blockchain system calculates a weighted sum of the accuracy index, stability index, and participation index based on the final first association weight, the final second association weight, and the third association weight. The specific calculation formula is: Total Reputation Value = Accuracy Index × Adjusted First Association Weight + Stability Index × Adjusted Second Association Weight + Participation Index × Third Association Weight. By introducing the participation index, the hierarchical blockchain system not only examines the reliability of nodes but also assesses their enthusiasm for participating in consensus, avoiding the selection of slow-responding, negative nodes and improving the overall activity and processing efficiency of the consensus network.
[0061] During weighted fusion calculation, the total reputation value is derived using a linear or nonlinear fusion algorithm based on the final first and second association weights. If other dimensions of association weights exist (such as a third association weight), they can also be included in the fusion. To ensure a constant quantification standard for the final reputation value, the hierarchical blockchain system normalizes the adjusted association weights before or during the calculation of the total reputation value, ensuring that the sum of all weights equals 1. This ensures that the total reputation value always maps within a preset legal quantification range.
[0062] 107. Eliminate candidate consensus nodes whose total reputation value is lower than the preset isolation threshold, and determine the remaining candidate consensus nodes as target consensus nodes.
[0063] The preset isolation threshold is a reputation value threshold used to determine whether a candidate consensus node should be completely eliminated. Nodes below this threshold are considered untrusted nodes. The target consensus node represents the set of trusted nodes that have been screened and determined to participate in the actual consensus process at the regional layer. Elimination means removing candidate consensus nodes that do not meet the requirements from the consensus network and prohibiting them from participating in subsequent consensus activities.
[0064] Specifically, the layered blockchain system obtains a preset isolation threshold (e.g., 0.5) from the configuration management module, then iterates through the list of total reputation values of all candidate consensus nodes, comparing each node's total reputation value with the preset isolation threshold. For candidate consensus nodes with a total reputation value lower than the preset isolation threshold, the layered blockchain system marks them as untrusted nodes and removes them from the candidate consensus node list; these nodes are no longer eligible to participate in the current consensus cycle. For candidate consensus nodes with a total reputation value greater than or equal to the preset isolation threshold, the layered blockchain system retains them and reorganizes them into the target consensus node set. The layered blockchain system writes the information of the target consensus nodes (including node identifier, network address, total reputation value, etc.) into the consensus participant list and sends consensus invitation messages to these nodes, notifying them to prepare to participate in the subsequent blockchain block generation process.
[0065] The preset isolation threshold is a dynamic equilibrium point based on a normalized reputation value system. Since the system performs adaptive adjustment and normalization of weights in steps 104 / 105 (see step 106), the calculated total reputation value has equal horizontal comparability under different operating conditions. Therefore, even in extremely abnormal network conditions, the system can still filter out "outliers" with extremely poor accuracy or stability by removing nodes below the isolation threshold, thus achieving a technical closed loop for local network consensus security.
[0066] In some embodiments, the hierarchical blockchain system acquires a preset alarm threshold, the value of which is greater than a preset isolation threshold. When the total reputation value of a candidate consensus node is less than the preset alarm threshold, but greater than or equal to the preset isolation threshold, the hierarchical blockchain system assigns the corresponding candidate consensus node to a graylist node set. Graylist nodes are nodes whose reputation is in a state of alert but not yet completely untrustworthy, such as nodes with a total reputation value between 0.5 and 0.65. These nodes do not participate in weighted consensus in the current consensus cycle and are excluded from the target consensus node list; however, their candidate consensus node status is retained, and the hierarchical blockchain system continuously monitors and records their behavior. Only when their total reputation value rises above the preset alarm threshold in subsequent consensus cycles can they be re-identified as a target consensus node and participate in the subsequent consensus process.
[0067] When the total reputation value of candidate consensus nodes is less than a preset isolation threshold, the hierarchical blockchain system assigns the corresponding candidate consensus nodes to a blacklist set and isolates them from communication within the blacklist set at the regional layer network. Communication isolation measures include blocking the IP addresses of these nodes in firewall rules, removing paths to these nodes from the routing table, and refusing to receive any messages from these nodes at the application layer. The hierarchical blockchain system then identifies the remaining candidate consensus nodes (excluding those in the graylist and blacklist sets) as target consensus nodes. These nodes have a total reputation value higher than a preset alarm threshold and are considered the most trusted consensus participants.
[0068] 108. The control target consensus node performs weighted consensus on the consensus payload based on the total reputation value, generates blockchain blocks, and synchronizes the blockchain blocks to the global layer nodes in the global layer for on-chain storage.
[0069] Weighted consensus refers to the allocation of voting weights among target consensus nodes during the consensus process based on their total reputation value; nodes with higher reputation values have greater voting weights. Blockchain blocks represent data blocks containing payloads to be agreed upon, generated through consensus at the regional layer, and are the constituent units of the regional layer blockchain (i.e., blockchain). Global layer nodes refer to high-performance nodes deployed at the global layer, responsible for maintaining the global blockchain and performing global consensus verification. On-chain storage refers to the process of writing data from blockchain blocks into the global blockchain and persistently saving it.
[0070] Specifically, the layered blockchain system distributes the payload to be consensused to each target consensus node. Each target consensus node independently verifies the legality of the payload (such as data format, signature validity, timestamp validity, etc.) and generates a verification result. During the voting phase, the layered blockchain system calculates the voting weight of each target consensus node based on its total reputation value. For example, using a normalization method, the sum of the total reputation values of all nodes is used as the denominator, and the total reputation value of each node is used as the numerator to obtain the voting weight percentage of each node. Assuming node A has a reputation value of 0.9, node B has a reputation value of 0.8, and node C has a reputation value of 0.7, then A's weight is 0.9 / (0.9+0.8+0.7)≈0.375. The layered blockchain system collects the verification results and weights from each node. When the cumulative weight supporting a certain verification result exceeds a preset threshold (such as 2 / 3), the result is confirmed as a consensus result. The layered blockchain system encapsulates and generates a blockchain block based on the consensus result, containing a block header (timestamp, previous block hash, consensus proof, etc.) and a block body (the payload data to be consensused). Subsequently, the layered blockchain system transmits the generated blockchain blocks to the global layer nodes via the network. After verifying the blockchain blocks, the global layer nodes append them to the global blockchain, completing cross-layer data synchronization and persistent storage.
[0071] In some embodiments, the process of a layered blockchain system synchronizing blockchain blocks to global layer nodes in the global layer for on-chain storage includes: First, the layered blockchain system controls each global layer node in the global layer to probe each other's round-trip time (RTT) by sending timestamp data packets and recording the RTT. Based on the RTT, a distributed network coordinate algorithm (e.g., the Vivaldi algorithm) is used to construct the network coordinates of each global layer node. In the Vivaldi algorithm, each global layer node maintains a coordinate vector in a multi-dimensional Euclidean space (e.g., two to five dimensions). Each node iteratively updates its coordinates by continuously exchanging RTT measurements and coordinate information with other nodes, gradually minimizing the error between the Euclidean distance between node coordinates and the actual RTT measurement. This maps the network topology to the coordinate space, achieving a mapping relationship where smaller inter-node delays result in closer coordinate distances, and larger inter-node delays result in greater coordinate distances.
[0072] Then, the hierarchical blockchain system calls the K-means clustering algorithm to cluster the network coordinates of each global layer node, resulting in multiple logical groups. Each logical group contains at least one global layer node, and nodes within the same logical group are physically close and have low communication latency. In the clustering calculation, the hierarchical blockchain system dynamically determines the number of cluster groups K as ⌈N / M⌉ based on the total number of global layer nodes N and the preset upper limit M for the number of target nodes in each group. The K-means algorithm takes the network coordinates of each global layer node as input and K as the preset number of groups, iteratively performing the redistribution of nodes within the cluster and the updating of cluster center coordinates until the change in coordinates of each cluster center is lower than the preset convergence threshold, or the number of iterations reaches the preset maximum number of iterations, at which point the logical grouping of global layer nodes is completed.
[0073] Next, the hierarchical blockchain system obtains the global reputation of each global layer node (representing the reliability of the global layer node in the historical global consensus process, calculated by statistically analyzing historical consensus participation rate, verification accuracy, etc.) and load data (including CPU utilization, memory usage, network bandwidth utilization, number of processed transactions, etc.) and determines the group leader node in each logical group based on the node's global reputation and load data. Specifically, for each global layer node within each logical group, the hierarchical blockchain system first normalizes each load indicator to the [0, 1] interval, and then performs a weighted summation of the normalized load indicators according to preset sub-weights to obtain the comprehensive load coefficient of the node. The higher the comprehensive load coefficient, the heavier the current load of the node. Then, the group leader score of each node is calculated according to the following formula: Group leader score = Node global reputation × Preset reputation weight - Comprehensive load coefficient × Preset load weight, where the sum of the preset reputation weight and the preset load weight is 1 (for example, the preset reputation weight is 0.6 and the preset load weight is 0.4). Finally, the global layer node with the highest group leader score in each logical group is determined as the group leader node, thus selecting a node that combines high reputation and low current load to serve as the group leader.
[0074] Finally, the hierarchical blockchain system controls the global layer nodes within each logical group and the group leader nodes of each logical group to conduct consensus interaction, appending blockchain blocks to the global blockchain. This hierarchical grouping architecture reduces the overhead of network-wide broadcasting and improves the efficiency of on-chain processing.
[0075] The consensus interaction process between the global layer nodes and the group leader nodes within each logical group in the hierarchical blockchain system is as follows: Each global layer node in the hierarchical blockchain system independently verifies the received blockchain block. After successful verification, it generates a feedback signature (digital signature) for the blockchain block using its private key and transmits the feedback signature to the corresponding group leader node via the network. The group leader node continuously collects feedback signatures from member nodes within the group. When the number of feedback signatures collected by the group leader node meets a preset threshold (e.g., reaching 2 / 3 of the total number of nodes in the group), it indicates that the blockchain block has gained sufficient acceptance within the group. The group leader node then calls a signature aggregation algorithm (such as BLS signature aggregation) to compress the multiple collected feedback signatures into a single aggregated signature, significantly reducing the size of the signature data, and generates a commit message with the single aggregated signature. The hierarchical blockchain system controls the group leader nodes of each logical group to broadcast commit messages to each other, and each group leader node verifies the aggregated signatures and commit messages sent by other group leader nodes. When the commit messages of multiple long nodes (such as more than 2 / 3) reach a consensus, the global consensus verification is completed. The layered blockchain system appends the blockchain block to the end of the global blockchain, updates the blockchain state, and broadcasts the hash value of the new block to the entire network, completing the on-chain storage.
[0076] The IoT layered blockchain construction method described in this application first determines the consensus payload and candidate consensus nodes based on device-level business data, while simultaneously acquiring the accuracy, stability indicators, and corresponding initial weights of the candidate consensus nodes. Then, the layered blockchain system acquires network operating status data, including communication latency fluctuations, and adaptively adjusts the correlation weights of the two types of indicators according to network conditions. Next, the layered blockchain system calculates the total reputation value of the candidate nodes by weighting and fusing the accuracy and stability indicators based on the adjusted weights, and eliminates low-reputation nodes to determine the target consensus node. Finally, the layered blockchain system controls the target node to generate a blockchain block based on the weighted consensus of the total reputation value, and synchronizes it to the global layer nodes for on-chain storage, ensuring that node selection and consensus processes are aligned with the current network conditions. This method alleviates the technical problem of accurately selecting reliable consensus nodes when facing abnormal network conditions and improves the security of local network consensus.
[0077] The method provided in this embodiment will now be described in more detail. Please refer to [link / reference]. Figure 3 This is another flowchart illustrating the IoT layered blockchain construction method in this application embodiment.
[0078] 201. Obtain IoT service data collected at the device layer, use the IoT service data as the consensus payload, and determine the candidate consensus nodes in the region layer for processing the consensus payload. (Refer to the execution process of step 101) 202. Obtain the historical accuracy index of each candidate consensus node in the previous consensus period, and the consistency judgment result of each candidate consensus node in the current consensus period. The consistency judgment result indicates whether the data submitted by the candidate consensus node is consistent with the regional consensus result.
[0079] The previous consensus cycle refers to the complete consensus cycle immediately preceding the current consensus cycle; the historical accuracy index represents a quantitative score of the verification accuracy of candidate consensus nodes in the previous consensus cycle, reflecting the node's past reliable performance; the current consensus cycle refers to the time period of the current round of consensus process being executed by the layered blockchain system; the consistency judgment result represents a Boolean value or score indicating whether the verification data submitted by candidate consensus nodes in the current consensus cycle is consistent with the final regional consensus result, usually represented by 1 for consistency and 0 for inconsistency; the regional consensus result refers to the unified verification conclusion reached by a majority of candidate consensus nodes in the regional layer through voting or negotiation.
[0080] Specifically, the layered blockchain system first queries and extracts the historical accuracy index values stored by each candidate consensus node at the end of the previous consensus cycle from the historical database of the regional layer. These historical values reflect the overall performance of the node in the previous cycle. For example, if node A's historical accuracy index in the previous cycle was 0.92, it means that 92% of its verification results were consistent with the consensus in the previous cycle. Simultaneously, during the execution of the current consensus cycle, the layered blockchain system tracks and records the verification results submitted by each candidate consensus node in real time. After the regional layer completes consensus and forms the final regional consensus result, the layered blockchain system compares the verification results submitted by each candidate consensus node with the regional consensus result to determine if they are consistent. If the verification results submitted by a candidate consensus node are exactly the same as the regional consensus result, the consistency judgment result of that node is recorded as 1 or True; if they are different, it is recorded as 0 or False. This process ensures that the calculation of the accuracy index takes into account historical performance and current behavior, achieving dynamic tracking and evaluation of node reliability.
[0081] In some embodiments, the accurate acquisition of historical accuracy indicators and consistency judgment results can be achieved in the following ways: The hierarchical blockchain system adopts a multi-dimensional consistency judgment method, which not only compares whether the final conclusion of the verification result is consistent, but also compares multiple dimensions such as intermediate states, timestamps, and data formats in the verification process. The consistency judgment result is calculated through a comprehensive scoring mechanism. For example, 1 point is awarded for complete consistency, 0.5 points for partial consistency, and 0 points for complete inconsistency, making the consistency judgment more refined.
[0082] 203. Calculate the difference between the consistency judgment result of each candidate consensus node and the historical accuracy index to obtain the accuracy deviation value of each candidate consensus node.
[0083] Accuracy deviation is used to represent the degree to which a node's behavior deviates from its historical trajectory. The magnitude of the deviation value refers to the momentum of deviation it reflects. When the deviation value is negative, an "increase" in the deviation value is defined as an increase in its absolute value or a displacement of its value towards negative infinity on the number line.
[0084] Specifically, the layered blockchain system performs difference calculations on each candidate consensus node, subtracting its historical accuracy index from the previous consensus cycle from the node's consistency judgment result in the current consensus cycle to obtain the accuracy deviation value. For example, if a candidate consensus node has a historical accuracy index of 0.95 and a current consistency judgment result of 0 (indicating inconsistency between the current verification and the consensus result), then the accuracy deviation value = 0 - 0.95 = -0.95, a negative value indicating a significant decline in the node's performance. Conversely, if a node has a historical accuracy index of 0.70 and a current consistency judgment result of 1, then the accuracy deviation value = 1 - 0.70 = 0.30, a positive value indicating an improvement in the node's performance. After calculating the accuracy deviation values for all candidate consensus nodes, the layered blockchain system stores these deviation values in a node evaluation data table and marks nodes with larger absolute deviation values as key observation targets. A large negative deviation may indicate that the node has begun to act maliciously or has been attacked, while a sustained positive deviation indicates that the node is gradually recovering its reliability.
[0085] In some embodiments, the calculation of accuracy deviation and anomaly identification can be achieved in the following ways: The hierarchical blockchain system can adopt a sliding window statistical method to not only calculate the difference between the current period and the previous period, but also to count the accuracy deviation sequence over the past N periods (such as 5 or 10 periods). By analyzing the changing trend of the deviation (such as continuous decline, oscillation, sudden jump, etc.), the abnormal behavior of the node can be judged more accurately. For example, if the accuracy deviation is negative for 3 consecutive periods and the absolute value increases, it is determined that the node may be gradually acting maliciously.
[0086] 204. When the accuracy deviation of a candidate consensus node is greater than or equal to the preset defection warning threshold, the preset historical decay factor is used as the first target decay factor of the candidate consensus node.
[0087] The defection warning threshold refers to the critical deviation value used to determine whether the behavior of candidate consensus nodes has undergone suspicious mutations. It is usually set to a small negative value (such as -0.2). The historical decay factor is a pre-set coefficient used to balance the weight of historical accuracy indicators and current consistency judgment results. Its value ranges from 0 to 1 (such as 0.3). The smaller the value, the weaker the influence of historical data. The first target decay factor represents the decay factor actually used when the node behavior is normal. It is equal to the preset historical decay factor.
[0088] Specifically, the layered blockchain system obtains a preset defection warning threshold from the configuration parameters, and then compares the accuracy deviation of each candidate consensus node with this threshold. For candidate consensus nodes whose accuracy deviation is greater than or equal to the defection warning threshold (e.g., the threshold is set to -0.2), it indicates that the node's current performance has not significantly declined compared to its historical performance, and the node's behavior is within an acceptable fluctuation range, classifying it as a normal node. For example, if a node's accuracy deviation is -0.15, which is greater than the defection warning threshold of -0.2, these situations indicate that the node's performance is stable or has minimal fluctuations. For such normal nodes, the layered blockchain system directly obtains the system's preset historical decay factor (e.g., 0.3) and assigns it to the candidate consensus node's first target decay factor, without requiring additional punitive adjustments.
[0089] In some embodiments, the determination and application of the first target decay factor can be achieved in the following way: The hierarchical blockchain system adopts dynamic threshold adjustment, and adjusts the defection warning threshold according to the distribution of accuracy deviation values of all candidate consensus nodes in the current regional layer network (such as statistical characteristics such as mean, standard deviation, quantile, etc.). For example, when the overall network environment is good, the threshold is tightened to -0.15, and when the network is attacked and the deviation value of most nodes decreases, the threshold is relaxed to -0.25, so that the threshold can adapt to changes in network conditions.
[0090] 205. When the accuracy deviation of a candidate consensus node is less than the defection warning threshold, obtain the behavioral fluctuation variance of the candidate consensus node within a preset time window, and calculate the second penalty coefficient of the candidate consensus node based on the accuracy deviation and behavioral fluctuation variance of the candidate consensus node.
[0091] The preset time window refers to the time range used to collect historical behavior data of candidate consensus nodes, which usually includes multiple consecutive consensus cycles (such as the most recent 5 or 10 cycles). The behavior fluctuation variance represents the degree of fluctuation in the verification accuracy of candidate consensus nodes within the preset time window. It is obtained by calculating the variance of the accuracy index of each cycle. The larger the value, the more unstable the node behavior. The second penalty coefficient is a punitive adjustment coefficient calculated for candidate consensus nodes that have abnormal deviations. It is used to enhance the weakening of their historical high reputation. The value range is usually greater than 1.
[0092] Specifically, when the layered blockchain system detects that the accuracy deviation of a candidate consensus node is less than the defection warning threshold (e.g., the deviation value drops from the normal fluctuation range to below a negative threshold), it indicates that the node's current performance has significantly deviated from or worsened compared to its historical performance. The layered blockchain system determines that the node is at risk of fraud or suspected of being hijacked, and may exhibit sudden malicious or abnormal behavior. The layered blockchain system first extracts the accuracy index value of the candidate consensus node from the historical database for each period within a preset time window (e.g., the most recent 10 consensus periods), forming a time-series dataset. The layered blockchain system calculates the average of the accuracy index values in the time-series dataset, then calculates the square of the difference between each value and the average, and finally averages all the squared values to obtain the behavioral fluctuation variance. Subsequently, the layered blockchain system considers the absolute value of the accuracy deviation and the behavioral fluctuation variance, and generates a second penalty coefficient using a preset calculation formula. For example, the formula is: Second Penalty Coefficient = 1 + |Accuracy Deviation Value| × k1 + Behavioral Fluctuation Variance × k2, where k1 and k2 are adjustment coefficients (e.g., k1 = 2, k2 = 10). If a node's accuracy deviation is -0.3 and its behavior fluctuation variance is 0.025, then the second penalty coefficient = 1 + 0.3 × 2 + 0.025 × 10 = 1.85. This coefficient will be used to adjust the historical decay factor, imposing a stronger penalty on abnormal nodes, weakening the weight of their historical high reputation in the current evaluation, and enabling their total reputation value to quickly reflect their latest poor performance.
[0093] In some embodiments, the second penalty coefficient can be accurately calculated as follows: the hierarchical blockchain system uses an exponential function to calculate the second penalty coefficient, as shown in the formula: Second penalty coefficient = e (α×|准确度偏离值|+β×行为波动方差) Where α and β are control parameters, the exponential function can subject severely anomalous nodes to nonlinearly increasing penalties, resulting in a more significant inhibitory effect on extreme malicious behavior.
[0094] 206. Obtain the preset historical decay factor, multiply the historical decay factor by the second penalty coefficient, and obtain the second target decay factor of the candidate consensus node.
[0095] The second target attenuation factor represents the attenuation factor actually used for candidate consensus nodes that exhibit abnormal behavior. After being amplified by the second penalty coefficient, its value is greater than the preset historical attenuation factor, which is used to reduce the weight of historical accuracy indicators in the current accuracy calculation.
[0096] Specifically, the hierarchical blockchain system obtains a preset historical decay factor (e.g., 0.3) from the system configuration. This initial decay factor is a standard coefficient used to balance historical and current data under normal circumstances. The hierarchical blockchain system multiplies the obtained historical decay factor by a second penalty coefficient to obtain an amplified second target decay factor. Although the value of the second target decay factor is increased, in the exponentially weighted moving average calculation, a larger decay factor means a lower weight for historical data and a higher weight for current data. The hierarchical blockchain system performs a reasonableness check on the calculated second target decay factor to ensure that it does not exceed the upper limit (e.g., 0.9), preventing excessive fluctuations in the evaluation caused by completely ignoring historical data.
[0097] In some embodiments, the calculation and constraint of the second target decay factor can be achieved in the following way: the hierarchical blockchain system adopts a gradual adjustment method, instead of adjusting the second target decay factor to the target value all at once, but gradually increasing the decay factor over multiple consecutive periods. For example, it is increased to 0.4 in the first abnormal period, to 0.5 in the second period, and to 0.555 in the third period, so as to avoid a sudden drop in node reputation due to a single accidental anomaly and to give the node a chance to recover.
[0098] 207. Based on the first or second target decay factor of each candidate consensus node, perform exponentially weighted moving average calculations on the historical accuracy index and the consistency judgment result to obtain the accuracy index of each candidate consensus node.
[0099] Exponentially weighted moving average is a commonly used time series smoothing technique. By assigning decreasing weights to historical data, it makes recent data have a greater impact while the impact of older data gradually weakens. The accuracy index represents the final score of the verification accuracy of candidate consensus nodes after comprehensively considering historical and current performance.
[0100] Specifically, the layered blockchain system performs an exponentially weighted moving average calculation for each candidate consensus node. The calculation formula is: Accuracy Index = (1 - Target Decay Factor) × Historical Accuracy Index + Target Decay Factor × Consistency Judgment Result. The logic of this formula is that the target decay factor controls the weighting of historical and current data; the smaller the decay factor, the greater the weight of historical data, and the larger the decay factor, the greater the weight of current data. For example, a normal node using a first target decay factor of 0.3 has a historical accuracy index of 0.92 and a current consistency judgment result of 1, so the accuracy index = (1 - 0.3) × 0.92 + 0.3 × 1 = 0.944. Conversely, an abnormal node using a second target decay factor of 0.6 has a historical accuracy index of 0.95 and a current consistency judgment result of 0, so the accuracy index = (1 - 0.6) × 0.95 + 0.6 × 0 = 0.38. The comparison shows that the accuracy of normal nodes smoothly increased from 0.92 to 0.944, while the accuracy of abnormal nodes dropped sharply from 0.95 to 0.38, demonstrating the adaptive decay factor mechanism's keen ability to capture abnormal behavior.
[0101] In some embodiments, the accurate calculation and optimization of accuracy metrics can be achieved in the following way: The hierarchical blockchain system adopts a multi-period recursive calculation method. At the end of each consensus cycle, the currently calculated accuracy metric is used as the historical accuracy metric for the next cycle, forming a continuous recursive update process. For example, the accuracy metric A in cycle t... t =(1-α t )×A t-1 +α t ×C t A t-1 C represents the accuracy metric for the previous period. t For the current periodic consistency determination result, α t The target decay factor is dynamically adjusted, and the accuracy metric is continuously tracked by recursive iteration to track the long-term trend of node behavior.
[0102] 208. Obtain the online success rate data, average network latency data, and current network latency data of each candidate consensus node in the current consensus period. The online success rate data represents the ratio of the number of successful communications by the candidate consensus node to the total number of communications.
[0103] Online success rate data refers to the percentage of times a candidate consensus node successfully completes communication interaction within the current consensus period out of the total number of communication attempts. The value ranges from 0 to 1, reflecting the connection reliability of the node. Average network latency data represents the average round-trip latency of a candidate consensus node communicating with other nodes within a certain historical period (such as the most recent consensus periods), usually in milliseconds. Current network latency data refers to the real-time round-trip latency of a candidate consensus node communicating with other nodes within the current consensus period.
[0104] Specifically, to comprehensively evaluate the network stability of each candidate consensus node, network status data needs to be collected from multiple dimensions. The layered blockchain system first uses a network monitoring module to statistically analyze the communication behavior of each candidate consensus node within the current consensus cycle, recording the total number of communication requests initiated or responded to by each node, and the number of successful connections and data exchanges. For example, if a candidate consensus node initiates 100 communication attempts in the current cycle, with 92 successful and 8 failing due to timeouts, connection failures, or packet loss, then the node's online success rate is 92 ÷ 100 = 0.92. Secondly, the layered blockchain system queries the historical database for network latency records of each candidate consensus node over the past N consensus cycles (e.g., the most recent 5 or 10 cycles), calculating the arithmetic mean of these latency values to obtain the average network latency data. For example, if a node's historical latency records are [45ms, 48ms, 50ms, 47ms, 46ms], then the average network latency data is (45+48+50+47+46) ÷ 5 = 47.2ms. Meanwhile, the hierarchical blockchain system measures the network latency of each candidate consensus node in real time during the current consensus cycle. It obtains the current network latency data by sending timestamped probe data packets and recording the round-trip time. For example, the measured latency of a certain node in the current cycle is 80ms.
[0105] In some embodiments, network state data can be collected in the following way: the hierarchical blockchain system not only measures the latency of the target candidate consensus node from a single monitoring node, but also measures it simultaneously from multiple reference nodes in different geographical locations within the regional layer. Then, the multiple measurement results are weighted averaged or calculated as the median to eliminate the path deviation and local network fluctuations that may exist in single-point measurement and obtain more objective network latency data.
[0106] 209. Call the preset nonlinear mapping function to process the difference between the average network latency data and the current network latency data to obtain the latency penalty data of each candidate consensus node. The latency penalty data represents the first penalty coefficient for network latency fluctuations.
[0107] Nonlinear mapping functions are mathematical functions that can transform input variables into output variables through nonlinear relationships. Commonly used ones include the Sigmoid function, the hyperbolic tangent function (tanh), and the exponential function. The difference is the result of subtracting the average network latency data from the current network latency data. The latency penalty data is a penalty coefficient calculated based on the latency fluctuation amplitude. The value usually ranges from 0 to 1, with smaller values indicating heavier penalties. The first penalty coefficient is specifically for network latency fluctuations.
[0108] Specifically, the layered blockchain system first calculates the difference between the current network latency data and the average network latency data of each candidate consensus node. For example, if a node's average latency is 47.2ms and its current latency is 80ms, then the difference = 80 - 47.2 = 32.8ms, with a positive value indicating an increase in current latency. Then, the layered blockchain system calls a pre-defined non-linear mapping function to process the difference. For example, using the Sigmoid function: Delay penalty data = 1 ÷ (1 + e^(-1 / 2)) (k×差值) The function is defined as follows: where k is an adjustment parameter controlling the steepness of the function (e.g., k=0.1). When the difference is 0, the delay penalty is 0.5; when the difference is positive and large (delay increases), the delay penalty approaches 0 (strong penalty); when the difference is negative (delay decreases), the delay penalty approaches 1 (no penalty). For example, for a difference of 32.8ms, the delay penalty is 0.035. The advantage of using a non-linear mapping function is that it applies a lighter penalty to small delay fluctuations (e.g., differences within ±10ms), allowing for normal network fluctuations; while applying a near-maximum penalty to large delay spikes (e.g., differences exceeding 50ms), effectively identifying network anomalies.
[0109] 210. Multiply the delay penalty data with the online success rate data to obtain the stability index of each candidate consensus node.
[0110] The stability index is a quantitative indicator that comprehensively evaluates the network connection reliability and latency stability of candidate consensus nodes. The value ranges from 0 to 1, and the higher the value, the more stable and reliable the node network is.
[0111] Specifically, the layered blockchain system performs a simple multiplication operation on each candidate consensus node: Stability Index = Latency Penalty Data × Online Success Rate Data. The design logic of this calculation method is as follows: the online success rate data reflects the node's basic ability to successfully establish and maintain communication connections, while the latency penalty data reflects the stability of communication quality under the premise of a successful connection. Multiplying the two achieves a dual constraint on the node's network stability. For example, if a candidate consensus node has an online success rate of 0.92 and a latency penalty data of 0.035 (due to a significant increase in current latency), its stability index is 0.0322. This extremely low stability index indicates that although the node can maintain the connection, network latency has severely deteriorated, resulting in poor overall stability. Conversely, another node has an online success rate of 0.95 and a latency penalty data of 0.85 (with very small latency fluctuations), resulting in a stability index of 0.8075, indicating that this node's network condition is good and stable. Through this multiplicative combination, the layered blockchain system ensures that only nodes with both high connection success rates and low latency fluctuations can obtain a high stability index; any weakness in either aspect will lower the overall score.
[0112] In some embodiments, the stability index can be calculated and optimized in the following way: a layered blockchain system can use a weighted geometric average method instead of simple multiplication, and the calculation formula is: Stability Index = (Online Success Rate Data) w1 ×(Delay penalty data) w2 In this context, w1 and w2 are weighted exponents, and w1 + w2 = 1. By adjusting the weighted exponents, the relative importance of online success rate and latency stability can be controlled. For example, when connection reliability is more important in an IoT environment, w1 = 0.6 and w2 = 0.4 can be set. In financial blockchain, when latency sensitivity is higher, w1 = 0.4 and w2 = 0.6 can be set. The geometric mean can better punish extreme low values of a certain dimension than the arithmetic mean.
[0113] 211. Obtain the first correlation weight corresponding to the accuracy metric and the second correlation weight corresponding to the stability metric. The accuracy metric represents the consistency of the verification results, and the stability metric represents the network connectivity status. (Refer to the execution process of step 102) 212. Obtain the network operation status data of the communication network, which includes communication latency fluctuation, invalid packet drop rate, and consensus drop rate. (Refer to the execution process of step 103) 213. When the invalid packet drop rate or consensus drop rate is detected to be greater than the preset attack alarm threshold, the first association weight is adjusted according to the preset first adjustment coefficient, which is greater than 1. (Refer to the execution process of step 104) 214. When the detected communication delay fluctuation exceeds the preset network oscillation threshold, the second correlation weight is adjusted according to the preset second adjustment coefficient, which is less than 1. (Refer to the execution process of step 105) 215. Based on the final first association weight and the final second association weight, perform a weighted fusion calculation on the accuracy and stability indicators of each candidate consensus node to obtain the total reputation value of each candidate consensus node. (Refer to the execution process of step 106) 216. Remove candidate consensus nodes whose total reputation value is lower than the preset isolation threshold, and determine the remaining candidate consensus nodes as the target consensus nodes. (Refer to the execution process of step 107) 217. The control target consensus node performs weighted consensus on the consensus payload based on the total reputation value, generates blockchain blocks, and synchronizes the blockchain blocks to the global layer nodes in the global layer for on-chain storage. (Refer to the execution process of step 108) The IoT layered blockchain construction method described in this application first obtains the historical accuracy index of nodes and the current consistency judgment result, calculates the accuracy deviation value, and establishes a quantitative basis for identifying node behavior mutations. Then, based on whether the deviation value exceeds the defection warning threshold, the layered blockchain system allocates a first target attenuation factor or a second target attenuation factor, and adjusts the attenuation factor by calculating a second penalty coefficient in conjunction with the behavior fluctuation variance, thus reducing the weight proportion of historically high reputation of abnormal nodes. Next, the layered blockchain system calculates the accuracy index using an exponentially weighted moving average, calls a nonlinear mapping function to process the latency difference to obtain latency penalty data, and multiplies it by the online success rate to obtain a stability index. The layered blockchain system then adjusts the association weights based on network operation status data, weights and fuses the indicators to obtain a total reputation value, selects target consensus nodes according to the threshold, and executes weighted consensus. Finally, the layered blockchain system synchronizes the blockchain blocks to the global layer to complete the on-chain process, alleviating the problems of node indicators being easily affected by accidental deviations and slow identification of defective nodes, thereby improving the reliability of IoT layered blockchain consensus.
[0114] The methods provided in the above embodiments can be executed by a hierarchical blockchain system. The hierarchical blockchain system in the embodiments of this invention is described below from a hardware processing perspective; please refer to [link to relevant documentation]. Figure 4 This is a schematic diagram of the physical device structure of a layered blockchain system in this application embodiment.
[0115] It should be noted that, Figure 4 The structure of the layered blockchain system shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of the present invention.
[0116] like Figure 4As shown, the hierarchical blockchain system includes a Central Processing Unit (CPU) 301, which can perform various appropriate actions and processes based on programs stored in Read-Only Memory (ROM) 302 or programs loaded from storage section 308 into Random Access Memory (RAM) 303, such as performing the methods described in the above embodiments. The RAM 303 also stores various programs and data required for system operation. The CPU 301, ROM 302, and RAM 303 are interconnected via a bus 304. An Input / Output (I / O) interface 305 is also connected to the bus 304.
[0117] The following components are connected to I / O interface 305: input section 306 including audio input devices, push-button switches, etc.; output section 307 including a liquid crystal display (LCD) and audio output devices, indicator lights, etc.; storage section 308 including a hard disk, etc.; and communication section 309 including a network interface card such as a LAN (Local Area Network) card, modem, etc. Communication section 309 performs communication processing via a network such as the Internet. Drive 310 is also connected to I / O interface 305 as needed. Removable media 311, such as a disk, optical disk, magneto-optical disk, semiconductor memory, etc., are installed on drive 310 as needed so that computer programs read from them can be installed into storage section 308 as needed.
[0118] In particular, according to embodiments of the present invention, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of the present invention include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing computer programs for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via communication section 309, and / or installed from removable medium 311. When the computer program is executed by central processing unit (CPU) 301, it performs the various functions defined in the present invention.
[0119] It should be noted that specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), flash memory, optical fiber, portable compact disc read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this invention, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device.
[0120] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of the present invention. Each block in a flowchart or block diagram may represent a module, program segment, or portion of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those shown in the drawings.
[0121] Specifically, the layered blockchain system in this embodiment includes a processor and a memory. The memory stores a computer program, and when the computer program is executed by the processor, it implements the IoT layered blockchain construction method provided in the above embodiment.
[0122] In another aspect, the present invention also provides a computer-readable storage medium, which may be included in the hierarchical blockchain system described in the above embodiments; or it may exist independently and not incorporated into the hierarchical blockchain system. The storage medium carries one or more computer programs that, when executed by a processor of the hierarchical blockchain system, cause the hierarchical blockchain system to implement the IoT hierarchical blockchain construction method provided in the above embodiments.
[0123] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit it. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of this application.
[0124] As used in the above embodiments, depending on the context, the term "when..." can be interpreted as meaning "if...", "after...", "in response to determining...", or "in response to detecting...". Similarly, depending on the context, the phrase "when determining..." or "if (the stated condition or event) is interpreted as meaning "if determining...", "in response to determining...", "when (the stated condition or event) is detected", or "in response to detecting (the stated condition or event)".
[0125] In the above embodiments, implementation can be achieved entirely or partially through software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented entirely or partially in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.
[0126] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.
Claims
1. A method for constructing a layered blockchain for the Internet of Things (IoT), applied to a layered blockchain system, wherein the layered blockchain system includes a device layer, a regional layer, and a global layer, characterized in that, The method includes: The IoT service data collected by the device layer is obtained, the IoT service data is used as the consensus payload, and candidate consensus nodes in the region layer are determined to process the consensus payload. Obtain the accuracy index and stability index of each candidate consensus node, and obtain the first correlation weight corresponding to the accuracy index and the second correlation weight corresponding to the stability index. The accuracy index represents the consistency of the verification results, and the stability index represents the status of network connectivity. Obtain network operation status data of the communication network in which it is located, including communication latency fluctuation range, invalid message drop rate, and consensus drop rate; When the invalid message discard rate or the consensus discard rate is detected to be greater than the preset attack alarm threshold, the first association weight is adjusted according to the preset first adjustment coefficient, where the first adjustment coefficient is greater than 1. When the communication delay fluctuation is detected to be greater than the preset network oscillation threshold, the second correlation weight is adjusted according to the preset second adjustment coefficient, where the second adjustment coefficient is less than 1. Based on the final first association weight and the final second association weight, the accuracy index and stability index of each candidate consensus node are weighted and fused to calculate the total reputation value of each candidate consensus node. Candidate consensus nodes whose total reputation value is lower than a preset isolation threshold are removed, and the remaining candidate consensus nodes are determined as target consensus nodes; The target consensus node is controlled to perform weighted consensus on the payload to be consensused based on the total reputation value, generate blockchain blocks, and synchronize the blockchain blocks to the global layer nodes in the global layer for on-chain storage.
2. The method according to claim 1, characterized in that, The accuracy and stability metrics for obtaining each of the candidate consensus nodes specifically include: Obtain the historical accuracy index of each candidate consensus node in the previous consensus period, and the consistency judgment result of each candidate consensus node in the current consensus period. The consistency judgment result indicates whether the data submitted by the candidate consensus node is consistent with the regional consensus result. Obtain a preset historical decay factor, and calculate an exponentially weighted moving average of the historical accuracy index and the consistency judgment result based on the historical decay factor to obtain the accuracy index of each candidate consensus node. Obtain the online success rate data, average network latency data, and current network latency data of each candidate consensus node in the current consensus period. The online success rate data represents the ratio of the number of successful communications by the candidate consensus node to the total number of communications. A preset nonlinear mapping function is invoked to process the difference between the average network latency data and the current network latency data to obtain the latency penalty data of each candidate consensus node. The latency penalty data represents the first penalty coefficient for network latency fluctuations. Multiplying the latency penalty data by the online success rate data yields the stability index of each candidate consensus node.
3. The method according to claim 2, characterized in that, The step of obtaining a preset historical decay factor and calculating an exponentially weighted moving average of the historical accuracy index and the consistency determination result based on the historical decay factor to obtain the accuracy index of each candidate consensus node specifically includes: Calculate the difference between the consistency determination result of each candidate consensus node and the historical accuracy index to obtain the accuracy deviation value of each candidate consensus node; When the accuracy deviation of the candidate consensus node is greater than or equal to the preset defection warning threshold, the preset historical decay factor is used as the first target decay factor of the candidate consensus node. When the accuracy deviation of the candidate consensus node is less than the defection warning threshold, the behavior fluctuation variance of the candidate consensus node within a preset time window is obtained, and a second penalty coefficient of the candidate consensus node is calculated based on the accuracy deviation and the behavior fluctuation variance. Obtain a preset historical decay factor, multiply the historical decay factor by the second penalty coefficient, and obtain the second target decay factor of the candidate consensus node; Based on the first or second target decay factor of each candidate consensus node, an exponentially weighted moving average is calculated for the historical accuracy index and the consistency determination result to obtain the accuracy index of each candidate consensus node.
4. The method according to claim 1, characterized in that, Based on the final first association weight and the final second association weight, the accuracy and stability indicators of each candidate consensus node are weighted and fused to obtain the total reputation value of each candidate consensus node, specifically including: Obtain the participation index of each candidate consensus node and the third association weight corresponding to the participation index. The participation index is determined based on the response time ranking of the candidate consensus nodes in the current consensus period. Based on the final first association weight, the final second association weight, and the third association weight, the accuracy index, the stability index, and the participation index are weighted and summed to obtain the total reputation value of each candidate consensus node.
5. The method according to claim 1, characterized in that, Candidate consensus nodes whose total reputation value is lower than a preset isolation threshold are removed, and the remaining candidate consensus nodes are determined as target consensus nodes, specifically including: Obtain a preset alarm threshold, wherein the preset alarm threshold is greater than the preset isolation threshold; When the total reputation value of the candidate consensus node is less than the preset alarm threshold and the total reputation value of the candidate consensus node is greater than or equal to the preset isolation threshold, the corresponding candidate consensus node is assigned to the gray list node set. When the total reputation value of the candidate consensus node is less than the preset isolation threshold, the corresponding candidate consensus node is assigned to the blacklist node set, and communication isolation is performed on the candidate consensus node in the blacklist node set in the regional layer network. The remaining candidate consensus nodes, excluding the gray list node set and the black list node set, are determined as the target consensus nodes.
6. The method according to claim 1, characterized in that, Synchronizing the blockchain blocks to the global layer nodes in the global layer for on-chain storage specifically includes: The system controls each global layer node in the global layer to detect each other's round-trip delay and constructs the network coordinates of each global layer node based on the round-trip delay; A clustering algorithm is called to perform clustering calculations on the network coordinates of each global layer node to obtain multiple logical groups, each of which contains at least one global layer node. Obtain the global reputation and load data of each global layer node, and determine the group leader node in each logical group based on the global reputation and load data. The global reputation of the node represents the reliability of the global layer node in the historical global consensus process. The global layer nodes within each logical group and the group leader nodes of each logical group are controlled to perform consensus interaction, and the blockchain blocks are appended to the global blockchain.
7. The method according to claim 6, characterized in that, Controlling the global layer nodes within each logical group and the group leader node of each logical group to conduct consensus interaction, and appending the blockchain blocks to the global blockchain, specifically includes: The system controls each global layer node within the logic group to generate a feedback signature for the blockchain block and sends the feedback signature to the corresponding group leader node. When the number of feedback signatures collected by the group leader node meets a preset threshold, the collected feedback signatures are compressed into a single aggregate signature, and a commit message with the single aggregate signature is generated. The group leader nodes of each logical group broadcast the commit message to each other to complete global consensus verification and append the blockchain block to the global blockchain.
8. The method according to claim 1, characterized in that, Acquire IoT service data collected by the device layer, use the IoT service data as the consensus payload, and determine candidate consensus nodes in the region layer for processing the consensus payload, specifically including: IoT service data is collected through IoT devices in the device layer, and the preset device key and current timestamp of the IoT device are obtained. The device key is used to perform a hash calculation on the IoT service data and the timestamp to obtain the authentication information of the IoT service data. Based on the authentication information, the timestamp, and the hash value of the previous local block, a target local block is generated and appended to the local blockchain maintained by the IoT device, so as to use the IoT business data as the payload to be reached for consensus. The block status information of the local blockchain is sent to the corresponding regional gateway, and the regional gateway is identified as the candidate consensus node.
9. A layered blockchain system, characterized in that, Includes one or more processors and memory; The memory is coupled to the one or more processors, the memory being used to store computer program code, the computer program code including computer instructions, the one or more processors invoking the computer instructions to cause the hierarchical blockchain system to perform the method as described in any one of claims 1-8.
10. A computer-readable storage medium comprising computer instructions, characterized in that, When the computer instructions are executed on the hierarchical blockchain system, the hierarchical blockchain system performs the method as described in any one of claims 1-8.