Internet of Things clustering optimization method based on fragmentation block chain
Through the k-means algorithm and Cuckoo-GA optimization shard configuration, combined with dual deep Q learning and reputation management models, the blockchain scalability and security problems in the Internet of Things are solved, and the Internet of Things with high throughput and low latency is achieved Blockchain sharding strategy.
Patent Information
- Application Number
- CN202411342086.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-25
- Publication Date
- 2024-12-31
AI Technical Summary
In the Internet of Things, traditional blockchain technology has scalability problems when processing large-scale transactions and data, resulting in limited throughput and processing capabilities, and it is difficult to ensure high throughput in dynamic combination characteristics and high proportion cross-shash transaction scenarios. quantity and safety.
The grouping method based on the k-means algorithm is adopted to combine Cuckoo-GA and double deep Q learning (double DQN) optimization framework to dynamically adjust the number of shards and node configuration, enhance security through reputation management model, and improve computing efficiency through DNN compression.
It improves the scalability and security of blockchain, reduces the risk of malicious attacks, optimizes the sharding and transaction processing efficiency of IoT devices, and adapts to dynamic network structure and high computing costs.
Smart Images

Figure CN119232582A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of large-scale Internet of Things (IoT) commercial applications, and in particular to an IoT clustering optimization method based on sharded blockchain. Background Art
[0002] In today's digital age, Internet of Things (IoT) technology has attracted great attention with its powerful potential and wide application fields. IoT technology closely connects the physical world with the digital world, and interacts various devices, sensors and systems with each other, bringing people unprecedented convenience and intelligent experience. From smart homes to smart cities, from industrial automation to agricultural monitoring, IoT is changing our lifestyle, work style and social operation mode. With the continuous advancement and innovation of technology, IoT will continue to evolve and develop to create a more intelligent, efficient and sustainable future for us. Since a large number of IoT devices constantly access wireless networks, there are a large number of connected devices and sensors in IoT, which may be vulnerable to cyber attacks and data leakage risks. Protecting the security of IoT devices and data has become an important task, and security measures such as authentication, data encryption and network defense need to be strengthened to ensure user privacy and data security. On the other hand, various computing tasks of different applications are delivered to the IoT network, and the data generated between IoT devices are shared. Collaborative Internet of Things is a further development and extension of the traditional IoT concept, emphasizing the collaboration and cooperation between various devices and subjects in the IoT system. Through collaboration, devices can jointly utilize each other's sensor data, storage and computing power to achieve more efficient information processing and intelligent decision-making. Therefore, in a collaborative environment, it is extremely important to establish trust between IoT users.
[0003] However, the centralized architecture in the current IoT network is challenged by single point of failure (SPOF), data privacy, reliability and robustness. Blockchain technology is based on cryptography and P2P networks, and has the characteristics of natural immutability and decentralization. Blockchain technology is widely used to solve problems such as single point of failure, privacy leakage, and unfair arbitration in IoT networks. The data generated by IoT devices can be recorded and verified through blockchain technology to ensure the integrity and immutability of the data. The decentralized and distributed characteristics of blockchain make data more difficult to be attacked or tampered with, providing higher data security. Blockchain technology can establish a decentralized data exchange platform, so that IoT devices can directly share and trade data without relying on centralized third-party institutions. This helps promote cooperation and resource sharing between devices and promote the development of the IoT ecosystem.
[0004] Although blockchain has been applied to a variety of distributed system scenarios, such as connected vehicles, content distribution networks, and smart grids, the disadvantage is that current blockchain technology has scalability issues when processing large-scale transactions and data. Since each block must be verified and stored by nodes in the network, the throughput and processing power of blockchain are limited. The scalability of current blockchain systems hinders its implementation in large-scale IoT. In this context, a parallel paradigm called sharding is proposed, which divides the entire system into multiple shards to achieve higher throughput. Zilliqa (coin symbol: ZIL) is a public chain platform based on sharding technology, which aims to solve the scalability and performance challenges faced by traditional blockchains. Zilliqa uses sharding technology to divide the entire network into multiple small shards, each of which can process transactions in parallel. This sharding design enables Zilliqa to achieve high-throughput transaction processing, and the throughput can also scale linearly as the network size grows.
[0005] With the rise of blockchain sharding, many IoT systems and applications based on sharded blockchains have begun to emerge. However, there are some issues that need to be considered when applying sharded blockchains to collaborative computing IoT. First, due to the self-organizing nature of IoT networks, dynamic and collaborative computing tasks may lead to the emergence of dynamic combination characteristics. Traditional network sharding methods randomly divide IoT devices into different shards, and a dynamic cluster-based sharding protocol is needed to better adapt to this dynamic combination feature. Second, when it comes to a high proportion of cross-shard transactions (CST), current sharded blockchains face the problems of low throughput and high latency. Although increasing the number of shards can improve throughput, it will also increase the proportion of CST. Therefore, a trade-off needs to be considered when selecting the number of shards to achieve higher throughput and ensure the efficiency of CST. Finally, the number of validators within a shard decreases linearly with the increase in the number of shards, which increases the possibility of malicious nodes colluding and may lead to false blocks. Therefore, a trade-off between high throughput and security needs to be made to select the appropriate number of shards. In order to support the needs of IoT, alternative sharding models may need to be adopted to increase throughput and ensure the security of shards. In summary, for the application of sharded blockchain in the scenario of IoT, factors such as dynamic combination characteristics, cross-shard transaction efficiency, trade-off of the number of shards, and shard security need to be considered to ensure that the requirements of high throughput and security in the IoT environment are met.
[0006] As a classic clustering algorithm, the k-means algorithm is widely used in the fields of data analysis and pattern recognition. Through the k-means algorithm, IoT devices can be dynamically grouped into different shards based on the similarity between samples to adapt to dynamic combination characteristics. This can better cope with the self-organizing nature of the IoT network. Secondly, the k-means algorithm can automatically determine the appropriate number of shards based on transaction patterns and requirements, thereby improving the efficiency and overall throughput of cross-shard transactions. By reasonably selecting the number of shards, the efficiency of cross-shard transactions can be improved while ensuring high throughput, meeting the performance requirements of the IoT system. In addition, as a classic clustering algorithm, the k-means algorithm has good scalability and is also applicable to large-scale data sets. This enables the k-means algorithm to effectively perform sharding and clustering operations when processing large IoT data, improving the efficiency and processing power of the IoT system.
[0007] However, the traditional k-means algorithm cannot flexibly adapt to dynamic and complex network structures. The k-means algorithm is very sensitive to the selection of the initial centroid, and different initial centroids may lead to different clustering results. The k-means algorithm requires the number of clusters k to be specified in advance. However, in practical applications, it is often difficult to determine the appropriate number of clusters in advance. Choosing an inappropriate k value may lead to inaccurate or incomplete clustering results. How to achieve the selection and adaptive optimization of the number of shards, shard size, and time interval in the clustering process is a major challenge for collaborative computing in the Internet of Things. Summary of the invention
[0008] In view of this, the purpose of the present invention is to provide an Internet of Things clustering optimization method based on sharded blockchain, which optimizes the reward and punishment mechanism of nodes and can ensure high throughput even under malicious attacks.
[0009] To achieve the above purpose, the present invention adopts the following technical solution: an Internet of Things clustering optimization method based on sharded blockchain, comprising the following steps:
[0010] Step S1, k-means-based IoT device grouping: Dynamically group IoT devices to reduce the proportion of cross-shard transactions (CST) and use the K-means algorithm for clustering.
[0011] Step S2, K-Shard algorithm design reconfiguration node: At the end of each cycle (epoch), the Cuckoo-GA algorithm is executed, which is a reconfiguration strategy that combines cuckoo search and genetic algorithm.
[0012] Step S3, double DQN workflow: A double deep Q learning (double DQN) optimization framework is used to handle the high dynamic characteristics and large dimensionality of IoT devices and data transaction flows.
[0013] Step S4, consensus strategy: After the epoch configuration is completed, each node waits for external users to submit transactions, and then runs the internal consensus protocol within the committee to ensure the consistency of the transaction set.
[0014] Step S5, calculate reputation: After the epoch ends, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated to perform rewards and punishments.
[0015] In a preferred embodiment, the step S1 of dynamically grouping IoT devices to reduce the proportion of cross-shard transactions (CST) and clustering using the K-means algorithm specifically includes the following steps:
[0016] Step S10, with respect to the atomic operations of sending and receiving described previously, the verification of CST will be doubled. That is, if the proportion of CST is high, the throughput will be affected. Therefore, in order to reduce the proportion of CST and maintain the underlying community structure, a K-means-based IoT device grouping scheme is proposed. Given a DTFG snapshot G = (V, E) at time period t, V represents a vertex set consisting of M IoT devices, and E represents the DTFG binary social matrix Y (t) =[y i ,j (t) ]. Assume that K is the number of target groups. In the classic K-means algorithm, the initial K center vertices are randomly selected and clustered according to the minimum distance from the vertex to the center vertex. Then, when the grouping is obtained, the center vertex is updated. These grouping and center updates are iterated until convergence. However, the traditional K-means algorithm is widely used in numerical-based clustering scenarios, which is incompatible with our graph application. Therefore, the sample vertex distance and center vertex update are redefined in the DTFG scenario.
[0017] In order to estimate the similarity between different samples for reasonable classification, the Jaccard correlation coefficient is used to measure the correlation between each pair of vertices instead of the Euclidean distance:
[0018]
[0019] Where N(i) and N(j) are the neighbor vertices of vertex i and j, N(i)∩N(j) is the intersection of the neighbor vertices between vertex i and j, and N(i)∪N(j) is the union of the neighbor vertices between vertex i and j. The ratio of intersection to union gives the similarity between two vertices. If the intersection is 0, then the similarity between two vertices is 0.
[0020] For the central vertex, the classic K-means algorithm updates it by averaging the coordinates of all sample points in the cluster, however, this coordinate does not exist in the graph. Alternatively, here we select the vertex with the largest sum of similarities with other vertices in the group as the new central vertex, which can be described as follows:
[0021]
[0022] in represents the new center vertex of the kth UG, v k is the vertex set of the kth UG.
[0023] S11. Afterwards, when all groups are obtained, the K central vertices should be updated. Specifically, each UG should update the central vertex by selecting the vertex with the largest sum of similarities with all other vertices in the group, that is:
[0024]
[0025] The above grouping and updating process will continue to iterate until convergence and the central vertex no longer changes. Then, the grouping process is completed and K UGs are created based on the clustering results.
[0026] However, as an unsupervised learning algorithm, the quality of the grouping results is difficult to evaluate. In addition, it is also very sensitive to the number of clusters K. Here, the community modularity θ is introduced, which is a parameter for evaluating the strength of grouping features. The definition is expressed as follows:
[0027]
[0028] where hi and hj are the degrees of vertices i and j respectively (all edges connected to a vertex), Gi and Gj are the affiliated groups of vertices i and j, and e refers to the total number of edges in the entire graph. Here, when vertices i and j belong to the same group, there is δ(G i ,G j )=1; the calculated value of θ is between 0 and 1, while in actual networks, its actual value is usually between 0.3 and 0.7. Here, the larger the value of θ, the more obvious the clustering feature. In order to transform the grouping method into a dynamic DTFG and optimize the grouping results, modularity is used as a reward to optimize the selection of the number of groups K.
[0029] In a preferred embodiment, the step S2 further includes the following steps:
[0030] Step S20: First generate enough initial solutions, let solutionsCount be the number of solutions currently generated. Place w at several random locations L 1 ,L 2 ,...,Ln ∈[0,1], use the function popUp() to evict L 1 ,L 2 ,...,L n A constant number of nodes around use the pushIn() function to assign all expelled nodes to new random positions in the range [0,1] and let these nodes join the new committee. After generating the initial solution set, the adaptability() function of the genetic algorithm is used to filter the current solution set, remove unqualified solutions, and then randomly select parents for crossover and mutation, and add the generated offspring to achieve the purpose of evolution by crossover or mutation of the solution set. Next, evaluate whether the threshold securityLevel of the current set of solutions meets the predefined security threshold θ. If the threshold is met, the algorithm randomly selects a security scheme from the current set as the final reconfiguration scheme. Use the committeeSet() function to configure the committee for the current network, and then broadcast the committee's configuration c, the random seed s of this round, and the committee's UTXO to all nodes C of the committee.
[0031] By combining the K-means algorithm and the Cuckoo-GA algorithm, a local search mechanism can be introduced into the global search process of Cuckoo-GA to better optimize the solution space. As a means of local search, the K-means algorithm can help individuals find better clustering results in the solution space, thereby improving the overall optimization effect. This combination method can be applied to various optimization problems, especially those involving clustering and group behavior.
[0032] In a preferred embodiment, the step S3 further includes the following steps:
[0033] In order to handle the highly dynamic and large-dimensional characteristics of IoT devices and data transaction flows, as well as the joint optimization objectives in terms of user grouping and system scalability, a dual deep Q-learning (double DQN) approach is adopted to optimize long-term rewards. Generally speaking, the DRL framework contains an offline DNN construction stage to approximate the action-state value function Q(S,A) with the corresponding states and actions, and an online deep Q-network stage for dynamic network update and policy formulation. In particular, in view of the challenging factor of long training time, in the designed framework, through the interaction between the IoT blockchain environment (IBCenv) and the double DQN agent, the double DQN model is first trained to learn the optimal policy in an offline manner with respect to the number of shards and other blockchain parameter selections. Then, the MCN of the blockchain system can execute an intelligent policy to reasonably execute IoT grouping with the optimized number of groups, and adaptively adjust the block size and block interval online. In this case, the challenging problem of long execution time can be avoided.
[0034] In a preferred embodiment, the step S4 further includes the following steps:
[0035] After all member nodes of the committee complete the epoch configuration, they wait for external users to submit transactions. Subsequently, the committee needs to run an internal consensus protocol to agree on a set of transactions. During consensus, nodes communicate through a smaller p2p overlay created within each committee. RapidChain's consensus method has the best 1 / 2 resilience and consists of four synchronous rounds: propose, echo, pending, accept. RepChain has five rounds: propose, echo, submit, accept, and respond. In the response phase, honest nodes can determine whether the leader is corrupt. Therefore, nodes can accept or refuse to send responses to the leader to improve efficiency. Combine the above two methods and improve them. In the Propose phase, the Leader of each committee will send a message to all nodes in the committee.<P,v,H(m)> , where P represents the proposal phase, H(m) is the hash summary of the proposed content, and v is the number of iterations. In the echo phase, the nodes chat about the received proposal content again to confirm that the content received by all honest nodes in the first round is the same. Therefore, if the leader sends more than one version of the message, the honest nodes will find out, and the Pending phase is appended to save the proposal information and replace the nodes in time. In the Accept phase, the node accepts the proposal when it receives f+1 consistent proposals, and then gossipes the proposal together with the proof S that the node accepts the proposal. In the final Confirm phase, all nodes must submit voteList to facilitate the subsequent calculation of the reputation value. After the consensus is successful, the committee needs to add the transaction set to the committee ledger.
[0036] In a preferred embodiment, the step S5 further includes the following steps:
[0037] After the epoch is over, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated. Since the reputation value can distinguish the comprehensive capabilities of the node (computing power, activity, etc.), the reputation mechanism can help the committee select nodes with stronger computing power and better performance to serve as leaders during the leader election. On the other hand, if the sum of the node reputation values between committees is roughly similar, the node distribution of each committee is balanced, and the ratio of honest nodes to malicious nodes, active nodes to inactive nodes in each committee is similar, it will be difficult for malicious nodes to control the entire committee. At this time, the security level of the committee is relatively high, and the reputation score calculation formula is as follows:
[0038]
[0039] ε(i) is the value of transaction i, preventing small transactions from being honest and large transactions from being dishonest. ε(i) is used to mark the node's vote on transaction i. eBay simply applies the mark {-1, 0, 1} to correct, unknown, and incorrect votes. However, even if the node behaves maliciously, it can still make a lot of profit. Therefore, the innovative introduction of r p The proportionality factor Combined with the labeling of ε(i), the model punishes dishonest behavior more than it rewards honest behavior. It is the proportional coefficient of the node reputation value graph, which is used to punish or reward nodes with different behaviors to different degrees. The function design is as follows:
[0040]
[0041] The node value is mapped to a piecewise function, and then rewards or penalties are allocated according to the proportion of the mapped value. Assuming that the initial reputation value of the node is zero, it can be seen from the mapping function that the proportional coefficient of the initial reputation value starts from close to zero, so honest nodes are not prone to potential attacks on the system due to the rapid accumulation of reputation values, thereby improving the security level of the system. In contrast, nodes that do evil at the beginning will be punished more severely. However, the punishment is not infinite. If the reputation value of a node is very low, the mapping of the node is close to zero. At this time, if the node performs well, it will return faster to incentivize the node to maintain honest behavior.
[0042] Compared with the prior art, the present invention has the following beneficial effects: The present invention proposes a blockchain sharding strategy for IoT collaborative computing, reasonable IoT sharding, and improved scalability of blockchain. Specifically, we propose K-Shard, the first sharded blockchain protocol that combines the cuckoo rule with a genetic algorithm, solving the problem of high reconfiguration delay. K-Shard enhances security against potential attacks by introducing an effective reputation management model. In addition, in order to address the challenge of high computational cost, a DNN compression method is considered in the proposed scheme. By pruning redundant weights, the deployment of DNNs can save memory and computing time without affecting accuracy, thereby solving the problem of DNN deployment with limited hardware resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 This is an overall flow chart of the K-Shard IoT clustering blockchain sharding strategy based on deep reinforcement learning in an embodiment of the present invention;
[0044] Figure 2 This is a network framework diagram of the K-Shard Internet of Things clustering blockchain sharding strategy based on deep reinforcement learning in an embodiment of the present invention.
[0045] Figure 3 This is a specific flow chart of the K-Shard IoT clustering blockchain sharding strategy based on deep reinforcement learning in an embodiment of the present invention. DETAILED DESCRIPTION
[0046] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.
[0047] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.
[0048] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.
[0049] Please refer to Figures 1 to 3 , the K-Shard IoT clustering blockchain sharding strategy based on deep reinforcement learning includes the following steps:
[0050] S1. IoT device grouping based on k-means: Dynamically group IoT devices to reduce the proportion of cross-shard transactions (CST) and use K-means algorithm for clustering.
[0051] S2. K-Shard algorithm design reconfigures nodes: At the end of each cycle (epoch), the Cuckoo-GA algorithm is executed, which is a reconfiguration strategy that combines cuckoo search and genetic algorithm.
[0052] S3. Double DQN workflow: A double deep Q learning (double DQN) optimization framework is used to handle the high dynamic characteristics and large dimensionality of IoT devices and data transaction flows.
[0053] S4. Consensus strategy: After the epoch configuration is completed, each node waits for external users to submit transactions, and then runs the internal consensus protocol within the committee to ensure the consistency of the transaction set.
[0054] S5. Calculate reputation: After the epoch ends, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated to perform rewards and punishments.
[0055] From the above description, it can be seen that the beneficial effects of the present invention are: the present invention proposes a blockchain sharding strategy for IoT collaborative computing, reasonable IoT sharding, and improved scalability of blockchain. Specifically, we proposed K-Shard, the first sharded blockchain protocol that combines the cuckoo rule with a genetic algorithm, solving the problem of high reconfiguration delay. K-Shard enhances security against potential attacks by introducing an effective reputation management model. In addition, in order to address the challenge of high computational costs, we consider adopting a DNN compression method in the proposed scheme. By pruning redundant weights, the deployment of DNNs can save memory and computing time without affecting accuracy, thereby solving the problem of DNN deployment with limited hardware resources.
[0056] Furthermore, the step S1 of dynamically grouping IoT devices to reduce the proportion of cross-shard transactions (CST) and clustering using the K-means algorithm specifically includes the following steps:
[0057] S10. With respect to the atomic operations of sending and receiving described previously, the verification of CST will be doubled. That is, if the proportion of CST is high, the throughput will be affected. Therefore, in order to reduce the proportion of CST and maintain the underlying community structure, a K-means-based IoT device grouping scheme is proposed. Given a DTFG snapshot G = (V, E) at time period t, V represents the vertex set consisting of M IoT devices, and E represents the DTFG binary social matrix Y (t) =[y i ,j (t) ], represents the transaction edge set of the DTFG snapshot at a certain moment. Assume that K is the number of target groups. In the classic K-means algorithm, the initial K center vertices are randomly selected and clustered according to the minimum distance from the vertex to the center vertex. Then, when the grouping is obtained, the center vertex is updated. These groupings and center updates are iterated until convergence. However, the traditional K-means algorithm is widely used in numerical-based clustering scenarios, which is incompatible with our graph application. Therefore, the sample vertex distance and center vertex update are redefined in the DTFG scenario.
[0058] In order to estimate the similarity between different samples for reasonable classification, the Jaccard correlation coefficient is used to measure the correlation between each pair of vertices instead of the Euclidean distance:
[0059]
[0060] Where N(i) and N(j) are the neighbor vertices of vertex i and j, N(i)∩N(j) is the intersection of the neighbor vertices between vertex i and j, and N(i)∪N(j) is the union of the neighbor vertices between vertex i and j. The ratio of intersection to union gives the similarity between two vertices. If the intersection is 0, then the similarity between two vertices is 0.
[0061] For the central vertex, the classic K-means algorithm updates it by averaging the coordinates of all sample points in the cluster, however, this coordinate does not exist in the graph. Alternatively, here we select the vertex with the largest sum of similarities with other vertices in the group as the new central vertex, which can be described as follows:
[0062]
[0063] in represents the new center vertex of the kth UG, v k is the vertex set of the kth UG. UG represents a set of vertices. The new center vertex is updated by selecting the vertex with the largest sum of similarities with all other vertices in the group, so that the center point of each group can more accurately represent the group.
[0064] S11. Afterwards, when all groups are obtained, the K central vertices should be updated. Specifically, each UG should update the central vertex by selecting the vertex with the largest sum of similarities with all other vertices in the group, that is:
[0065]
[0066] The above grouping and updating process will continue to iterate until convergence and the central vertex no longer changes. Then, the grouping process is completed and K UGs are created based on the clustering results.
[0067] However, as an unsupervised learning algorithm, the quality of the grouping results is difficult to evaluate. In addition, it is also very sensitive to the number of clusters K. Here, the community modularity θ is introduced, which is a parameter for evaluating the strength of grouping features. The definition is expressed as follows:
[0068]
[0069] where hi and hj are the degrees of vertices i and j respectively (all edges are connected to a vertex), Represents the transaction edge set of the DTFG snapshot at a certain moment. i ,G j ) usually represents the Dirac delta function, which means that when G i Equal to G jIt takes the value 1 when vertices i and j are in the same group, otherwise it takes the value 0, which is used for screening when summing. Gi and Gj are the subsidiary groups of vertices i and j, and e refers to the total number of edges in the entire graph. Here, when vertices i and j belong to the same group, there is δ(G i ,G j )=1; the calculated value of θ is between 0 and 1, while in actual networks, its actual value is usually between 0.3 and 0.7. Here, the larger the value of θ, the more obvious the clustering feature. In order to transform the grouping method into a dynamic DTFG and optimize the grouping results, modularity is used as a reward to optimize the selection of the number of groups K.
[0070] Furthermore, the step S2 also includes:
[0071] S20, first generate enough initial solutions, let solutionsCount be the number of solutions currently generated. Place w at several random locations L 1 ,L 2 ,...,L n ∈[0,1], use the function popUp() to evict L 1 ,L 2 ,...,L n A constant number of nodes around use the pushIn() function to assign all expelled nodes to new random positions in the range [0,1] and let these nodes join the new committee. After generating the initial solution set, the adaptability() function of the genetic algorithm is used to filter the current solution set, remove unqualified solutions, and then randomly select parents for crossover and mutation, and add the generated offspring to achieve the purpose of evolution by crossover or mutation of the solution set. Next, evaluate whether the threshold securityLevel of the current set of solutions meets the predefined security threshold θ. If the threshold is met, the algorithm randomly selects a security scheme from the current set as the final reconfiguration scheme. Use the committeeSet() function to configure the committee for the current network, and then broadcast the committee's configuration c, the random seed s of this round, and the committee's UTXO to all nodes C of the committee.
[0072] By combining the K-means algorithm and the Cuckoo-GA algorithm, a local search mechanism can be introduced into the global search process of Cuckoo-GA to better optimize the solution space. First, an initial population containing enough solutions is generated, each solution represents a possible solution. The population is defined as solutionsCount solutions, which are initially distributed at random positions. Use the position update functions popUp() and pushIn() to adjust the position of the current solution to a random position. The specific details include mapping the position values L1, L2...Ln to the interval [0,1]. Use the fitness function adaptability() to calculate the fitness of the current solution to determine the quality of the solution. In the process of global search, the K-means algorithm is introduced for local search optimization. The specific steps are as follows: divide the current population into several groups; apply the K-means algorithm to each group, calculate the similarity of each solution in the group, and update the center point of each group; select the center point with the largest similarity as the new solution. Use the global search mechanism of the cuckoo search algorithm to generate new solutions (cuckoo eggs) and randomly replace some existing solutions. Calculate the fitness of the new solution. If the new solution is better than the current solution, replace the current solution with the new solution. Keep the solution with the highest fitness in the current population and explore the new solution space by random walk and flight. Use the concept of committee (similar to the host nest in cuckoo search) to calculate the new fitness by randomly selecting solutions and updating committee members (i.e., the set of solutions). Repeat the above process until the preset number of iterations is reached or the stopping condition is met (such as finding the optimal solution or reaching a specific fitness level). As a means of local search, the K-means algorithm can help individuals find better clustering results in the solution space, thereby improving the overall optimization effect. This combined method can be applied to various optimization problems, especially those involving clustering and group behavior.
[0073] S21. The design of genetic algorithm in K-Shard involves three main operators: selection, crossover and mutation. Selection operator: Introduce feature selection method to design selection operator. Set the lower limit of safety threshold θ, function adaptability() is used to filter out subsets below the threshold, and evaluate the quality of the result subset through evaluation() function.
[0074] Input is the initial solution set, and output is the filtered solution set, where naturalSelection represents the number of low-quality solutions that have been filtered out, leaving only a small number of high-quality solutions. During the screening process, each solution is checked and each committee in each solution is traversed. The safety level of the committee is denoted by C secLevel , calculated as the average reputation value C of all nodes in the committee repave The average reputation value N of all nodes in the network repaveThe difference between. S sec C representing all committees in a single solution secLevel set. The committee with the lowest security level, denoted as max(S sec ), is the security level S of this solution secLevel . S secLevel A higher S value indicates lower solution security and should be filtered out first. After filtering out a certain number of suboptimal solutions, the remaining high-quality solutions are output. Crossover operator: More diverse solutions can be generated through crossover. The male and female committees to be crossed are selected through the random seed s of this epoch. During this process, the characteristics of the parent and mother are exchanged and inherited to each offspring, and then these offspring are added to the solution set.
[0075] Mutation operator: From an evolutionary perspective, mutation is a way to pursue the diversity of the solution set. The process of the mutation operator is to randomly select a node from the solution set for mutation to become a member of other committees. During this process, the maternal characteristics of the committee mutate and are inherited to each offspring, and the offspring are added to the solution set. K-Shard combines the advantages of the two algorithms and improves the search efficiency and effect. This algorithm is formalized in the form of a mathematical equation to prove its ability to converge to the global optimal solution of the problem.
[0076]
[0077] where represents the degree of evolution of the solution set at iteration i. O i+1 is the offspring set genetically generated by evolution a at iteration i + 1, and Z i+1 is the elimination subset of evolution a at iteration i + 1. When set i+1 is becomes zero, it is 1, where a and η represent the evolution factor and the adaptability factor respectively (0 < a < 1, 0 ≤ η < 1). η determines the impact of evolution on the solution set. When the initial solution set generated by the cuckoo rule is iterated repeatedly, the algorithm will converge to the optimal solution with a probability of 1. The cuckoo genetic algorithm provides a strong proof of convergence.
[0078] As described above, the reconfiguration phase allows K-Shard to reconfigure committee members to counter slow adaptive attacks or join / leave attacks that may be implemented at the end of an epoch. At the end of each epoch, the reference committee executes the Cuckoo-GA algorithm and generates a reconfiguration plan that only requires the reconfiguration of a small number of nodes, making it difficult for attackers to target corruption and unable to successfully attack a single shard. After the epoch ends, the reference committee has the ability to reconfigure in a timely manner according to the predetermined reconfiguration plan. The process of proposing and implementing a reconstruction plan is divided into two different stages. This allows new nodes and cuckoo nodes to move at the same time, effectively reducing the duration of the reconfiguration phase.
[0079] Furthermore, the step S3 is specifically as follows:
[0080] In order to handle the highly dynamic and large-dimensional characteristics of IoT devices and data transaction flows, as well as the joint optimization objectives in terms of user grouping and system scalability, a dual deep Q-learning (double DQN) approach is adopted to optimize long-term rewards. Generally speaking, the DRL framework contains an offline DNN construction stage to approximate the action-state value function Q(S,A) with the corresponding states and actions, and an online deep Q-network stage for dynamic network update and policy formulation. In particular, in view of the challenging factor of long training time, in the designed framework, through the interaction between the IoT blockchain environment (IBCenv) and the double DQN agent, the double DQN model is first trained to learn the optimal policy in an offline manner with respect to the number of shards and other blockchain parameter selections. Then, the MCN of the blockchain system can execute an intelligent policy to reasonably execute IoT grouping with the optimized number of groups, and adaptively adjust the block size and block interval online. In this case, the challenging problem of long execution time can be avoided.
[0081] Furthermore, the step S4 is specifically as follows:
[0082] After all member nodes of the committee complete the epoch configuration, they wait for external users to submit transactions. Subsequently, the committee needs to run an internal consensus protocol to agree on a set of transactions. During consensus, nodes communicate through a smaller p2p overlay created within each committee. RapidChain's consensus method has the best 1 / 2 resilience and consists of four synchronous rounds: propose, echo, pending, accept. RepChain has five rounds: propose, echo, submit, accept, and respond. In the response phase, honest nodes can determine whether the leader is corrupt. Therefore, nodes can accept or refuse to send responses to the leader to improve efficiency. Combine the above two methods and improve them. In the Propose phase, the Leader of each committee will send a message to all nodes in the committee.<P,v,H(m)> , where P represents the proposal phase, H(m) is the hash summary of the proposed content, and v is the number of iterations. In the echo phase, the nodes chat about the received proposal content again to confirm that the content received by all honest nodes in the first round is the same. Therefore, if the leader sends more than one version of the message, the honest nodes will find out, and the Pending phase is appended to save the proposal information and replace the nodes in time. In the Accept phase, the node accepts the proposal when it receives f+1 consistent proposals, and then gossipes the proposal together with the proof S that the node accepts the proposal. In the final Confirm phase, all nodes must submit voteList to facilitate the subsequent calculation of the reputation value. After the consensus is successful, the committee needs to add the transaction set to the committee ledger.
[0083] Furthermore, the step S5 is specifically as follows:
[0084] After the epoch is over, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated. Since the reputation value can distinguish the comprehensive capabilities of the node (computing power, activity, etc.), the reputation mechanism can help the committee select nodes with stronger computing power and better performance to serve as leaders during the leader election. On the other hand, if the sum of the node reputation values between committees is roughly similar, the node distribution of each committee is balanced, and the ratio of honest nodes to malicious nodes, active nodes to inactive nodes in each committee is similar, it will be difficult for malicious nodes to control the entire committee. At this time, the security level of the committee is relatively high, and the reputation score calculation formula is as follows:
[0085]
[0086] ε(i) is the value of transaction i, preventing small transactions from being honest and large transactions from being dishonest. ε(i) is used to mark the node's vote on transaction i. eBay simply applies the mark {-1, 0, 1} to correct, unknown, and incorrect votes. However, even if the node behaves maliciously, it can still make a lot of profit. Therefore, the innovative introduction of r p The proportionality factor Combined with the labeling of ε(i), the model punishes dishonest behavior more than it rewards honest behavior. It is the proportional coefficient of the node reputation value graph, which is used to punish or reward nodes with different behaviors to different degrees. The function design is as follows:
[0087]
[0088] The node value is mapped to a piecewise function, and then rewards or penalties are allocated according to the proportion of the mapped value. Assuming that the initial reputation value of the node is zero, it can be seen from the mapping function that the proportional coefficient of the initial reputation value starts from close to zero, so honest nodes are not prone to potential attacks on the system due to the rapid accumulation of reputation values, thereby improving the security level of the system. In contrast, nodes that do evil at the beginning will be punished more severely. However, the punishment is not infinite. If the reputation value of a node is very low, the mapping of the node is close to zero. At this time, if the node performs well, it will return faster to incentivize the node to maintain honest behavior.
[0089] Please refer to Figure 1 , Embodiment 1 of the present invention is:
[0090] K-Shard IoT clustering blockchain sharding strategy based on deep reinforcement learning, this embodiment proposes K-Shard, a secure, highly incentivized and low-latency sharding blockchain system based on the cuckoo rule, in the context of the IoT blockchain. K-Shard is reconstructed through the optimization rules of genetic algorithms and cuckoo rules, so that new nodes can be added in parallel, solving the problem of long reconstruction delay. K-Shard adopts a reputation scheme based on a reward and punishment mechanism to detect and mark malicious nodes as early as possible, so that the nodes are evenly distributed. Through deep reinforcement learning (DRL) joint training, the number of clusters (number of shards) is optimized and the consensus parameters are adjusted.
[0091] like Figure 1 As shown, the K-Shard IoT clustering blockchain sharding strategy of deep reinforcement learning in this embodiment includes the following steps:
[0092] S1. IoT device grouping based on k-means: Dynamically group IoT devices to reduce the proportion of cross-shard transactions (CST) and use K-means algorithm for clustering.
[0093] S2. K-Shard algorithm design reconfigures nodes: At the end of each cycle (epoch), the Cuckoo-GA algorithm is executed, which is a reconfiguration strategy that combines cuckoo search and genetic algorithm.
[0094] S3. Double DQN workflow: A double deep Q learning (double DQN) optimization framework is used to handle the high dynamic characteristics and large dimensionality of IoT devices and data transaction flows.
[0095] S4. Consensus strategy: After the epoch configuration is completed, each node waits for external users to submit transactions, and then runs the internal consensus protocol within the committee to ensure the consistency of the transaction set.
[0096] S5. Calculate reputation: After the epoch ends, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated to perform rewards and punishments.
[0097] That is, in this embodiment, the K-means algorithm is first used to dynamically group IoT devices to reduce the proportion of cross-shard transactions, and the Cuckoo-GA algorithm is used to efficiently reconfigure the nodes at the end of each cycle to cope with the dynamic joining and exit of nodes, ensuring the balance and security of the network. In addition, the strategy also introduces a double deep Q learning (double DQN) framework to optimize the processing of devices and data streams to adapt to their highly dynamic and large-scale characteristics. At the same time, through the internal consensus protocol, it is ensured that each node can synchronize and verify the transaction set after completing the epoch configuration. Finally, the reputation score of the node is calculated by analyzing the consensus results to further improve the security and reliability of the system. This comprehensive strategy not only optimizes the sharding efficiency, but also enhances the performance and security of the entire blockchain system in IoT applications.
[0098] Please refer to Figures 1 to 3 , Embodiment 2 of the present invention is: the k-means-based IoT device grouping in step S1 of the above embodiment 1 specifically includes the following steps:
[0099] S10. With respect to the atomic operations of sending and receiving described previously, the verification of CST will be doubled. That is, if the proportion of CST is high, the throughput will be affected. Therefore, in order to reduce the proportion of CST and maintain the underlying community structure, a K-means-based IoT device grouping scheme is proposed. Given a DTFG snapshot G = (V, E) at time period t, V represents the vertex set consisting of M IoT devices, and E represents the DTFG binary social matrix Y (t) =[y i ,j (t)]. Assume that K is the number of target groups. In the classic K-means algorithm, the initial K center vertices are randomly selected and clustered according to the minimum distance from the vertex to the center vertex. Then, when the grouping is obtained, the center vertex is updated. These grouping and center updates are iterated until convergence. However, the traditional K-means algorithm is widely used in numerical-based clustering scenarios, which is incompatible with our graph application. Therefore, the sample vertex distance and center vertex update are redefined in the DTFG scenario.
[0100] In order to estimate the similarity between different samples for reasonable classification, the Jaccard correlation coefficient is used to measure the correlation between each pair of vertices instead of the Euclidean distance:
[0101]
[0102] Where N(i) and N(j) are the neighbor vertices of vertex i and j, N(i)∩N(j) is the intersection of the neighbor vertices between vertex i and j, and N(i)∪N(j) is the union of the neighbor vertices between vertex i and j. The ratio of intersection to union gives the similarity between two vertices. If the intersection is 0, then the similarity between two vertices is 0.
[0103] For the central vertex, the classic K-means algorithm updates it by averaging the coordinates of all sample points in the cluster, however, this coordinate does not exist in the graph. Alternatively, here we select the vertex with the largest sum of similarities with other vertices in the group as the new central vertex, which can be described as follows:
[0104]
[0105] in represents the new center vertex of the kth UG, v k is the vertex set of the kth UG.
[0106] S11. Afterwards, when all groups are obtained, the K central vertices should be updated. Specifically, each UG should update the central vertex by selecting the vertex with the largest sum of similarities with all other vertices in the group, that is:
[0107]
[0108] The above grouping and updating process will continue to iterate until convergence and the central vertex no longer changes. Then, the grouping process is completed and K UGs are created based on the clustering results.
[0109] However, as an unsupervised learning algorithm, the quality of the grouping results is difficult to evaluate. In addition, it is also very sensitive to the number of clusters K. Here, the community modularity θ is introduced, which is a parameter for evaluating the strength of grouping features. The definition is expressed as follows:
[0110]
[0111] where hi and hj are the degrees of vertices i and j respectively (all edges connected to a vertex), Gi and Gj are the affiliated groups of vertices i and j, and e refers to the total number of edges in the entire graph. Here, when vertices i and j belong to the same group, there is δ(G i ,G j )=1; the calculated value of θ is between 0 and 1, while in actual networks, its actual value is usually between 0.3 and 0.7. Here, the larger the value of θ, the more obvious the clustering feature. In order to transform the grouping method into a dynamic DTFG and optimize the grouping results, modularity is used as a reward to optimize the selection of the number of groups K.
[0112] In this embodiment, step S2 also includes:
[0113] S20, first generate enough initial solutions, let solutionsCount be the number of solutions currently generated. Place w at several random locations L 1 ,L 2 ,...,L n ∈[0,1], use the function popUp() to evict L 1 ,L 2 ,...,L n A constant number of nodes around use the pushIn() function to assign all expelled nodes to new random positions in the range [0,1] and let these nodes join the new committee. After generating the initial solution set, the adaptability() function of the genetic algorithm is used to filter the current solution set, remove unqualified solutions, and then randomly select parents for crossover and mutation, and add the generated offspring to achieve the purpose of evolution by crossover or mutation of the solution set. Next, evaluate whether the threshold securityLevel of the current set of solutions meets the predefined security threshold θ. If the threshold is met, the algorithm randomly selects a security scheme from the current set as the final reconfiguration scheme. Use the committeeSet() function to configure the committee for the current network, and then broadcast the committee's configuration c, the random seed s of this round, and the committee's UTXO to all nodes C of the committee.
[0114] By combining the K-means algorithm and the Cuckoo-GA algorithm, a local search mechanism can be introduced into the global search process of Cuckoo-GA to better optimize the solution space. As a means of local search, the K-means algorithm can help individuals find better clustering results in the solution space, thereby improving the overall optimization effect. This combination method can be applied to various optimization problems, especially those involving clustering and group behavior.
[0115] S21. The design of genetic algorithm in K-Shard involves three main operators: selection, crossover and mutation. Selection operator: Introduce feature selection method to design selection operator. Set the lower limit of safety threshold θ, function adaptability() is used to filter out subsets below the threshold, and evaluate the quality of the result subset through evaluation() function.
[0116] Input is the initial solution set, and output is the filtered solution set, where naturalSelection represents the number of low-quality solutions that have been filtered out, leaving only a small number of high-quality solutions. During the screening process, each solution is checked and each committee in each solution is traversed. The safety level of the committee is denoted by C secLevel , calculated as the average reputation value C of all nodes in the committee repave The average reputation value N of all nodes in the network repave The difference between sec C represents all committees in a single solution secLevel The committee with the lowest security level is represented by max(S sec ), which is the security level S of the solution secLevel . S secLevel A higher value indicates a less secure solution and should be filtered out first. After filtering out a certain number of suboptimal solutions, the remaining high-quality solutions are output. Crossover operator: More diverse solutions can be generated through crossover. The male and female committees to be crossed are selected by the random seed s of this epoch. During this process, the characteristics of the father and mother are exchanged and inherited to each offspring, which are then added to the solution set.
[0117] Mutation operator: From an evolutionary perspective, mutation is a way to pursue diversity in the solution set. The process of the mutation operator is to randomly select a node from the solution set to mutate and become a member of another committee. In this process, the maternal characteristics of the committee mutate and are inherited to each offspring, and the offspring are added to the solution set. K-Shard combines the advantages of both algorithms to improve search efficiency and effectiveness. The algorithm is formalized using mathematical equations to prove its ability to converge to the global optimal solution of the problem.
[0118]
[0119] in Indicates the degree of evolution of the solution set at iteration i. i+1 is the set of offspring genetically generated by evolution a at iteration i+1, Z i+1 is the elimination subset of evolution a at iteration i+1. i+1 hour Becomes zero is 1, where a and η represent the evolution factor and the adaptability factor respectively (0 < a < 1, 0 ≤ η < 1). η determines the influence of evolution on the solution set. When the initial solution set generated by the cuckoo rule is iterated repeatedly, the algorithm will converge to the optimal solution with a probability of 1. The cuckoo genetic algorithm provides a strong proof of convergence.
[0120] As can be seen from the above description, the reconfiguration phase allows the K-Shard reconfiguration committee members to respond to slow adaptive attacks or join / leave attacks that may be implemented at the end of an epoch. At the end of each epoch, the reference committee executes the Cuckoo-GA algorithm and generates a reconfiguration plan that only requires reconfiguring a small number of nodes, making it difficult for attackers to lock in targets for corruption and unable to successfully attack a single shard. After the epoch ends, the reference committee has the ability to reconfigure in a timely manner according to the predetermined reconfiguration plan. The process of proposing and implementing the reconstruction plan is divided into two different stages. This allows new nodes and cuckoo nodes to move simultaneously, effectively reducing the duration of the reconfiguration phase.
[0121] Among them, step S3 also includes:
[0122] To handle the high dynamic and large-dimensional characteristics of IoT device and data transaction flows, as well as the joint optimization objectives in terms of user grouping and system scalability, a double deep Q-learning (double DQN) method is adopted to optimize the long-term reward. Generally speaking, the DRL framework includes an offline DNN construction stage that can approximate the action-state value function Q(S,A) with corresponding states and actions, and an online deep Q-network stage for dynamic network updates and policy formulation. In particular, to address the challenging factor of long training time, in the designed framework, through the interaction between the IoT blockchain environment (IBCenv) and the double DQN agent, the double DQN model is first trained to learn the optimal policy offline regarding the following aspects: the number of shards and the selection of other blockchain parameters. Then, the MCN of the blockchain system can execute intelligent policies to reasonably execute IoT grouping with the optimized number of groups and adaptively adjust the block size and block interval online. In this case, the challenging problem of long execution time can be avoided.
[0123] Among them, step S4 also includes:
[0124] After all member nodes of the committee complete the epoch configuration, they wait for external users to submit transactions. Subsequently, the committee needs to run an internal consensus protocol to agree on a set of transactions. During consensus, nodes communicate through a smaller p2p overlay created within each committee. RapidChain's consensus method has the best 1 / 2 resilience and consists of four synchronous rounds: propose, echo, pending, accept. RepChain has five rounds: propose, echo, submit, accept, and respond. In the response phase, honest nodes can determine whether the leader is corrupt. Therefore, nodes can accept or refuse to send responses to the leader to improve efficiency. Combine the above two methods and improve them. In the Propose phase, the Leader of each committee will send a message to all nodes in the committee.<P,v,H(m)> , where P represents the proposal phase, H(m) is the hash summary of the proposed content, and v is the number of iterations. In the echo phase, the nodes chat about the received proposal content again to confirm that the content received by all honest nodes in the first round is the same. Therefore, if the leader sends more than one version of the message, the honest nodes will find out, and the Pending phase is appended to save the proposal information and replace the nodes in time. In the Accept phase, the node accepts the proposal when it receives f+1 consistent proposals, and then gossipes the proposal together with the proof S that the node accepts the proposal. In the final Confirm phase, all nodes must submit voteList to facilitate the subsequent calculation of the reputation value. After the consensus is successful, the committee needs to add the transaction set to the committee ledger.
[0125] Wherein, step S5 also includes:
[0126] After the epoch is over, the honesty of the node can be determined based on the consensus voting results, and then the reputation score of each node can be calculated. Since the reputation value can distinguish the comprehensive capabilities of the node (computing power, activity, etc.), the reputation mechanism can help the committee select nodes with stronger computing power and better performance to serve as leaders during the leader election. On the other hand, if the sum of the node reputation values between committees is roughly similar, the node distribution of each committee is balanced, and the ratio of honest nodes to malicious nodes, active nodes to inactive nodes in each committee is similar, it will be difficult for malicious nodes to control the entire committee. At this time, the security level of the committee is relatively high. The reputation score calculation formula is as follows:
[0127]
[0128] ω(i) is the value of transaction i, preventing small transactions from being honest and large transactions from being dishonest. ε(i) is used to mark the node's vote on transaction i. eBay simply applies the mark {-1, 0, 1} to correct, unknown, and incorrect votes. However, even if the node behaves maliciously, it can still make a lot of profit. Therefore, the innovative introduction of r p The proportionality factor Combined with the labeling of ε(i), the model punishes dishonest behavior more than it rewards honest behavior. It is the proportional coefficient of the node reputation value graph, which is used to punish or reward nodes with different behaviors to different degrees. The function design is as follows:
[0129]
[0130] The node value is mapped to a piecewise function, and then rewards or penalties are allocated according to the proportion of the mapped value. Assuming that the initial reputation value of the node is zero, it can be seen from the mapping function that the proportional coefficient of the initial reputation value starts from close to zero, so honest nodes are not prone to potential attacks on the system due to the rapid accumulation of reputation values, thereby improving the security level of the system. In contrast, nodes that do evil at the beginning will be punished more severely. However, the punishment is not infinite. If the reputation value of a node is very low, the mapping of the node is close to zero. At this time, if the node performs well, it will return faster to incentivize the node to maintain honest behavior.
[0131] In summary, the K-Shard IoT clustering blockchain sharding based on deep reinforcement learning provided by the present invention has the following beneficial effects: The present invention proposes a blockchain sharding strategy for IoT collaborative computing, reasonable IoT sharding, and improves the scalability of the blockchain. Specifically, we proposed K-Shard, which is the first sharding blockchain protocol that combines the cuckoo rule with a genetic algorithm, solving the problem of high reconfiguration delay. K-Shard enhances security against potential attacks by introducing an effective reputation management model. In addition, in order to address the challenge of high computational costs, we consider adopting a DNN compression method in the proposed scheme. By pruning redundant weights, the deployment of DNNs can save memory and computing time without affecting accuracy, thereby solving the problem of DNN deployment with limited hardware resources.
[0132] From the analysis of system performance: the algorithm K-Shard used in this invention can maintain low latency in an environment where nodes change frequently and dynamically, and can effectively manage a large number of IoT devices and data streams while ensuring data integrity and security. In addition, K-Shard enhances the robustness and scalability of the network through an optimized reputation system and node reconfiguration strategy, making it an ideal choice for adapting to the rapidly changing needs of the IoT.
[0133] The above descriptions are merely embodiments of the present invention and are not intended to limit the patent scope of the present invention. Any equivalent transformations made using the contents of the present invention's specification and drawings, or directly or indirectly applied in related technical fields, are also included in the patent protection scope of the present invention.
Claims
1. The IoT clustering optimization method based on sharded blockchain is characterized by: The following steps are involved: Step S1, k-means-based IoT device grouping: dynamically group IoT devices to reduce the proportion of cross-shard transaction CSTs, and use the K-means algorithm for clustering; Step S2, K-Shard algorithm design reconfiguration node: At the end of each cycle epoch, Cuckoo-GA algorithm is executed, which is a reconfiguration strategy combining cuckoo search and genetic algorithm; Step S3, double DQN workflow: The double DQN optimization framework is used to handle the high dynamic characteristics and large dimensionality of IoT devices and data transaction flows; Step S4, consensus strategy: After the epoch configuration is completed, each node waits for external users to submit transactions, and then runs the internal consensus protocol within the committee to ensure the consistency of the transaction set; Step S5, calculate reputation: After the epoch ends, the honesty of the node is determined based on the consensus voting results, and then the reputation score of each node is calculated to perform rewards and punishments.
2. The IoT clustering optimization method based on sharded blockchain according to claim 1 is characterized in that: The step S1 specifically includes the following steps: Step S10, propose a K-means-based IoT device grouping scheme; given a DTFG snapshot G = (V, E) for a given time period t, V represents a vertex set consisting of M IoT devices, and E represents a DTFG binary social matrix Y (t) =[y i ,j (t) ]; Assume that K is the number of target groups; In the classic K-means algorithm, the initial K center vertices are randomly selected and clustered according to the minimum distance from the vertex to the center vertex; Then, when the grouping is obtained, the center vertex is updated; These groupings and center updates are iterated until convergence; However, the traditional K-means algorithm is widely used in numerical-based clustering scenarios, which is incompatible with our graph application; Therefore, the sample vertex distance and center vertex update are redefined in the DTFG scenario; Use the Jaccard correlation coefficient to measure the correlation between each pair of vertices: Where N(i) and N(j) are the neighbor vertices of vertex i and j, N(i)∩N(j) is the intersection of the neighbor vertices between vertex i and j, and N(i)∪N(j) is the union of the neighbor vertices between vertex i and j; the ratio of intersection to union gives the similarity between two vertices; if the intersection is 0, the similarity between the two vertices is 0; Select the vertex with the largest sum of similarities with other vertices in the group as the new central vertex, as described below: in represents the new center vertex of the kth UG, v k is the vertex set of the kth UG; Step S11, after that, when all groups are obtained, the K central vertices should be updated; specifically, each UG should update the central vertex by selecting the vertex with the largest sum of similarities with all other vertices in the group, that is: The above grouping and updating process will continue to iterate until convergence and the central vertex no longer changes; then, the grouping process is completed and K UGs are created based on the clustering results; The community modularity θ is introduced, which is a parameter for evaluating the strength of grouping features; the definition is expressed as follows: where hi and hj are the degrees of vertices i and j respectively, all edges are connected to a vertex, Gi and Gj are the affiliated groups of vertices i and j, and e refers to the total number of edges in the entire graph; here, when vertices i and j belong to the same group, there is δ(G i ,G j )=1; the calculated value of θ is between 0 and 1, while in actual networks, its actual value is usually between 0.3 and 0.7; here, the larger the value of θ, the more obvious the clustering feature; modularity is used as a reward to optimize the choice of the number of groups K.
3. The IoT clustering optimization method based on sharded blockchain according to claim 1 is characterized in that: The step S2 also includes the following steps: Step S20, first generate enough initial solutions, let solutionsCount be the number of solutions currently generated; place w at several random positions L 1 ,L 2 ,...,L n ∈[0,1], use the function popUp() to evict L 1 ,L 2 ,...,L n A constant number of nodes around use the pushIn() function to assign all expelled nodes to new random positions in the range of [0,1] and let these nodes join the new committee; after generating the initial solution set, use the adaptability() function of the genetic algorithm to filter the current solution set, remove unqualified solutions, then randomly select parents for crossover and mutation, and add the generated offspring to achieve the purpose of evolution by crossover or mutation of the solution set; next, evaluate whether the threshold securityLevel of the current set of solutions meets the predefined security threshold θ; if the threshold is met, the algorithm will randomly select a security plan from the current set as the final reconfiguration plan; use the committeeSet() function to configure the committee for the current network, and then broadcast the committee's configuration c, the random seed s of this round, and the committee's UTXO to all nodes C of the committee.
4. The IoT clustering optimization method based on sharded blockchain according to claim 1 is characterized in that: The step S3 also includes the following steps: adopting a dual deep Q learning double DQN method to optimize long-term rewards; in the designed framework, through the interaction between the IoT blockchain environment IBCenv and the double DQN agent, first training the double DQN model to learn the optimal strategy for the following aspects in an offline manner: the number of shards and other blockchain parameter selections; then, the MCN of the blockchain system can execute an intelligent strategy to reasonably execute IoT grouping with an optimized number of groups, and adaptively adjust the block size and block interval online.
5. The IoT clustering optimization method based on sharded blockchain according to claim 1 is characterized in that: The step S4 also includes the following steps: After all member nodes of the committee complete the epoch configuration, they wait for external users to submit transactions; then the committee needs to run an internal consensus protocol to agree on a set of transactions; during the consensus period, nodes communicate through a smaller p2p overlay created within each committee; RapidChain's consensus method has the best 1 / 2 resilience and consists of four synchronous rounds: propose, echo, pending, accept; RepChain has five rounds: propose, echo, submit, accept, and respond; in the response phase, honest nodes can determine whether the leader is corrupt; in the propose phase, the leader of each committee will send a message to all nodes in the committee<P,v,H(m)> , where P represents the proposal phase, H(m) is the hash summary of the proposed content, and v is the number of iterations; in the echo phase, the nodes chat about the received proposal content again to make sure that the content received by all honest nodes in the first round is the same; if the leader sends more than one version of the message, the honest nodes will find out and append the Pending phase to save the proposal information and replace the nodes in time; in the Accept phase, the node accepts the proposal when it receives f+1 consistent proposals, and then gossipes the proposal together with the proof S that the node accepts the proposal; in the final Confirm phase, all nodes must submit voteList to facilitate the subsequent calculation of the reputation value; after the consensus is successful, the committee needs to add the transaction set to the committee ledger.
6. The IoT clustering optimization method based on sharded blockchain according to claim 1 is characterized in that: The step S5 also includes the following steps: After the epoch ends, the honesty of the node is determined based on the consensus voting results, and the reputation score of each node is calculated. The reputation score calculation formula is as follows: ω(i) is the value of transaction i, which prevents small transactions from being honest and large transactions from being dishonest; ε(i) is used to mark the node's vote on transaction i. eBay simply applies the mark {-1, 0, 1} to correct, unknown, and incorrect votes; r is introduced p The proportionality factor Combined with the label of ε(i), the model punishes dishonest behavior more than it rewards honest behavior; It is the proportional coefficient of the node reputation value graph, which is used to punish or reward nodes with different behaviors to different degrees; The function design is as follows: The value of the node is mapped to a piecewise function, and then rewards or penalties are allocated according to the proportion of the mapped value; assuming that the initial reputation value of the node is zero, it can be seen from the mapping function that the proportional coefficient of the initial reputation value starts from close to zero; if the reputation value of the node is very low, the mapping of the node is close to zero; at this time, if the node performs well, it will return faster to incentivize the node to maintain honest behavior.
