Blockchain data node sharding method and device

By acquiring the confidence data of blockchain data nodes and performing multiple pre-sharding operations, the sharding scheme is optimized to evenly distribute malicious nodes, thus solving the problem of insufficient shard security in existing technologies and achieving efficient and secure data consensus.

CN116527375BActive Publication Date: 2025-10-28IND BANK CO +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310568789.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-05-19
Publication Date
2025-10-28
Estimated Expiration
2043-05-19

AI Technical Summary

Technical Problem

Existing blockchain data node sharding methods cannot ensure the security of each shard, resulting in low consensus efficiency.

Method used

By acquiring the confidence data of each data node, multiple pre-sharding operations are performed, and the fitness parameters are determined based on the confidence data. The sharding scheme is then optimized to distribute malicious nodes evenly, thereby improving the security of the sharding area.

Benefits of technology

While improving consensus efficiency, it ensures the security of each region and avoids the problem of too many malicious nodes in individual regions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116527375B_ABST
    Figure CN116527375B_ABST
Patent Text Reader

Abstract

This application relates to a method and apparatus for sharding data nodes in a blockchain. The method includes: acquiring confidence data for each data node in the blockchain; performing multiple pre-sharding operations on the blockchain's data nodes, and determining a fitness parameter corresponding to each pre-sharding operation based on the confidence data of each data node. The fitness parameter characterizes the average distribution of malicious data nodes in each pre-sharded area; determining target layout data from the layout data of the data nodes in the multiple pre-sharding operations based on the fitness parameter corresponding to each pre-sharding operation; and sharding the blockchain's data nodes based on the target layout data. This method ensures that the number of malicious data nodes in each sharded area is similar, avoiding an excessive number of malicious data nodes in individual shards, thus improving consensus efficiency while enhancing the security of each shard.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of blockchain technology, and in particular to a method and apparatus for sharding data nodes in a blockchain. Background Technology

[0002] Currently, the Internet of Things (IoT) technology is being used more and more. Because the IoT environment contains a vast amount of valuable data, but the centralized nature of the IoT makes secure and effective data sharing impossible, blockchain technology can be used to decentralize the IoT.

[0003] In related technologies, to avoid the low efficiency of data sharing caused by the performance bottleneck of consensus algorithms, blockchain sharding technology can be used to divide the data nodes of the blockchain into multiple shards, and then perform consensus on IoT data based on each shard to improve consensus efficiency.

[0004] However, current blockchain data node sharding methods cannot guarantee the security of each shard when dividing data nodes. Summary of the Invention

[0005] Therefore, it is necessary to provide a blockchain data node sharding method and apparatus that can improve the security of each shard in the data node sharding process, addressing the aforementioned technical problems.

[0006] Firstly, this application provides a method for sharding data nodes in a blockchain, applicable to any data node in the blockchain. The method includes:

[0007] The confidence level data of each data node in the blockchain is obtained, and each confidence level data is used to characterize the degree of trustworthiness of the data node corresponding to the confidence level data when reaching consensus on IoT data.

[0008] The data nodes of the blockchain are pre-sharded multiple times, and the fitness parameter corresponding to each pre-sharding is determined based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area.

[0009] Based on the fitness parameters corresponding to each pre-sharding, the target layout data is determined from the layout data of the data nodes in the multiple pre-shardings;

[0010] Based on the target layout data, the data nodes of the blockchain are sharded.

[0011] In one embodiment, the multiple pre-sharding of the data nodes of the blockchain includes:

[0012] If the preshard to be executed is the first preshard, then the data nodes of the blockchain are presharded randomly;

[0013] If the pre-shard to be executed is not the first pre-shard, then the data nodes of the blockchain are pre-sharded according to the layout data of the data nodes corresponding to the previous pre-shard.

[0014] In one embodiment, the step of pre-sharding the blockchain data nodes based on the layout data of the data nodes corresponding to the previous pre-sharding includes:

[0015] Based on the layout data of the data nodes corresponding to the previous pre-sharding, determine the average confidence level of each region in the previous pre-sharding;

[0016] A first data node is randomly selected from the region with the highest average confidence level, and a second data node is randomly selected from the region with the lowest average confidence level. The confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes.

[0017] By swapping the shards where the first data node and the second data node are located, the data nodes of the blockchain are re-pre-sharded.

[0018] In one embodiment, the method further includes:

[0019] After each consensus is reached on the IoT data in the blockchain, the confidence data of each data node in the blockchain is updated according to the behavior of each node in the blockchain towards the IoT data.

[0020] In one embodiment, updating the confidence data of each data node in the blockchain based on the behavior of each node in the blockchain towards the IoT data includes:

[0021] Determine the behavior type of each data node in the blockchain when reaching consensus on the IoT data;

[0022] The confidence data of each data node is updated based on the behavior type of each data node when reaching consensus on the IoT data and the node type of each data node.

[0023] In one embodiment, determining the behavior type of each data node in the blockchain in response to the IoT data includes:

[0024] If the target data node crashes during consensus on the IoT data, or if the consensus information of the target data node on the IoT data is the first consensus information, then the behavior type of the target data node on the IoT data is determined to be abnormal behavior.

[0025] If the consensus information of the target data node regarding the IoT data is the second consensus information, then the behavior type of the target data node regarding the IoT data is determined to be normal behavior.

[0026] The target data node is any data node in the blockchain, and the amount of the first consensus information is less than the amount of the second consensus information.

[0027] Secondly, this application provides a sharding device for data nodes in a blockchain. The device includes:

[0028] The acquisition module is used to acquire the confidence data of each data node in the blockchain. Each confidence data is used to characterize the credibility of the data node corresponding to the confidence data when reaching consensus on IoT data.

[0029] The determination module is used to pre-shard the data nodes of the blockchain multiple times, and determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area.

[0030] The sharding module is used to determine the target layout data from the layout data of the data nodes in the multiple pre-sharding based on the fitness parameters corresponding to each pre-sharding; and to shard the data nodes of the blockchain based on the target layout data.

[0031] In one embodiment, the determining module is specifically used to: if the pre-shard to be executed is the first pre-shard, then randomly pre-shard the data nodes of the blockchain; if the pre-shard to be executed is not the first pre-shard, then pre-shard the data nodes of the blockchain according to the layout data of the data nodes corresponding to the previous pre-shard.

[0032] In one embodiment, the determining module is specifically configured to determine the average confidence level of each shard in the previous pre-sharding based on the layout data of the data nodes corresponding to the previous pre-sharding; randomly determine a first data node in the shard with the highest average confidence level, and randomly determine a second data node in the shard with the lowest average confidence level, wherein the confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes; and re-pre-shard the data nodes of the blockchain by swapping the shards where the first data node and the second data node are located.

[0033] In one embodiment, the sharding device for the data nodes of the blockchain further includes:

[0034] An update module is used to update the confidence data of each data node in the blockchain according to the behavior of each node in the blockchain towards the IoT data after each consensus is reached on the IoT data in the blockchain.

[0035] In one embodiment, the update module is specifically used to determine the behavior type of each data node in the blockchain when reaching consensus on the IoT data; and to update the confidence data of each data node according to the behavior type of each data node when reaching consensus on the IoT data and the node type of each data node.

[0036] In one embodiment, the update module is specifically configured to determine that the target data node's behavior type for the IoT data is abnormal behavior if the target data node crashes during consensus on the IoT data, or if the consensus information of the target data node for the IoT data is first consensus information; and to determine that the target data node's behavior type for the IoT data is normal behavior if the consensus information of the target data node for the IoT data is second consensus information.

[0037] The target data node is any data node in the blockchain, and the amount of the first consensus information is less than the amount of the second consensus information.

[0038] Thirdly, this application also provides a computer device. The computer device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the data node sharding method for the blockchain described in the first aspect.

[0039] Fourthly, this application also provides a computer-readable storage medium. The computer-readable storage medium stores a computer program thereon, which, when executed by a processor, implements the data node sharding method for the blockchain described in the first aspect. Fifthly, this application also provides a computer program product. The computer program product includes a computer program that, when executed by a processor, implements the data node sharding method for the blockchain described in the first aspect.

[0040] The aforementioned blockchain data node sharding method and apparatus first acquires the confidence score data of each data node in the blockchain. Each confidence score data represents the trustworthiness of the corresponding data node when reaching consensus on IoT data. Second, the blockchain data nodes are pre-sharded multiple times, and a fitness parameter corresponding to each pre-sharding is determined based on the confidence score data of each data node. This fitness parameter represents the average distribution of malicious data nodes across the pre-sharded regions. Third, based on the fitness parameter corresponding to each pre-sharding, target layout data is determined from the layout data of the data nodes in the multiple pre-sharding processes. Finally, the blockchain data nodes are sharded based on the target layout data. After pre-sharding the data nodes, the average distribution of malicious data nodes in each shard is determined based on the confidence data of each data node. Then, based on the average distribution of malicious data nodes in each shard, the optimal scheme is selected from the various pre-sharding schemes to shard the data nodes. This ensures that the number of malicious data nodes in each shard is similar, avoiding an excessive number of malicious data nodes in individual shards. This improves consensus efficiency while enhancing the security of each shard. Attached Figure Description

[0041] Figure 1 An application environment diagram of a blockchain data node sharding method provided in an embodiment of this application;

[0042] Figure 2 A flowchart illustrating a blockchain data node sharding method provided in an embodiment of this application;

[0043] Figure 3 A schematic diagram of a blockchain provided for an embodiment of this application;

[0044] Figure 4 A flowchart illustrating a method for pre-sharding a data node, provided in an embodiment of this application;

[0045] Figure 5 An iterative schematic diagram of pre-sharding provided in an embodiment of this application;

[0046] Figure 6A flowchart illustrating another blockchain data node sharding method provided in this application embodiment;

[0047] Figure 7 A schematic diagram illustrating the confidence level data of different blockchain regions provided in this application embodiment;

[0048] Figure 8 A schematic diagram illustrating the sharding success rate of a blockchain provided in an embodiment of this application;

[0049] Figure 9 A schematic diagram illustrating the system throughput of a blockchain with different numbers of shards, provided for embodiments of this application;

[0050] Figure 10 A structural block diagram of a blockchain data node sharding device provided in an embodiment of this application;

[0051] Figure 11 This is an internal structural diagram of a computer device provided in an embodiment of this application. Detailed Implementation

[0052] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.

[0053] The data node sharding method for blockchain provided in this application embodiment can be applied to, for example... Figure 1 The application environment shown. For example... Figure 1 The diagram illustrates the Internet of Things (IoT), which includes various IoT devices. These devices can communicate directly with each other. When each IoT device acts as a data node in a blockchain, they can share the generated IoT data through the blockchain.

[0054] IoT devices acting as data nodes can acquire confidence data from each data node. This confidence data is then used to determine the fitness parameters—representing the average distribution of malicious data nodes across different shards in each pre-sharding—during multiple pre-sharding operations on the blockchain. Subsequently, the blockchain's data nodes can be sharded based on these fitness parameters.

[0055] The IoT device may include intelligent vehicle device 101, robot device 102, drone 103, camera device 104, personal computer 105, network device 107, etc. This application embodiment does not limit the type of IoT device.

[0056] In one embodiment, such as Figure 2As shown, a method for sharding data nodes in a blockchain is provided. The method is illustrated using an example of its application to any data node in the blockchain, including: S201-S204:

[0057] S201. Obtain the confidence data of each data node in the blockchain.

[0058] It should be understood that the data node sharding involved in the embodiments of this application is one of the mainstream methods for blockchain scaling. It can achieve high-performance on-chain scaling without reducing the degree of decentralization of the blockchain, thereby solving the problems of insufficient blockchain scalability, low throughput and low consensus efficiency.

[0059] The data node sharding involved in the embodiments of this application can be network sharding. For example... Figure 3 As shown, data nodes in the entire network can be divided into different regions through a certain organizational method, and each region can conduct consensus on the IoT data in the entire blockchain in parallel.

[0060] Each confidence score is used to characterize the credibility of the data node corresponding to that confidence score when reaching a consensus on IoT data.

[0061] This application does not limit how the confidence data of each data node is determined. In some embodiments, after each consensus is reached on the IoT data in the blockchain, the confidence data of each data node in the blockchain can be updated according to the behavior of each node in the blockchain toward the IoT data.

[0062] It should be understood that the aforementioned behaviors related to IoT data can include various behavior types. In common consensus algorithms of blockchain technologies such as Practical Byzantine Fault Tolerance (PBFT), it is generally assumed that the number of data nodes exhibiting normal behavior is greater than the number of data nodes exhibiting abnormal behavior. Based on this, the behavior types of data nodes can be categorized.

[0063] For example, if the target data node crashes during consensus on IoT data, or if the consensus information of the target data node regarding IoT data is the first consensus information, then the behavior type of the target data node regarding IoT data is determined to be abnormal behavior. If the consensus information of the target data node regarding IoT data is the second consensus information, then the behavior type of the target data node regarding IoT data is determined to be normal behavior, and the number of first consensus information is less than the number of second consensus information.

[0064] The target data node is any data node in the blockchain.

[0065] In some embodiments, data nodes exhibiting normal behavior can be directly rewarded with confidence scores. Data nodes exhibiting abnormal behavior can be penalized with confidence scores. In other embodiments, the aforementioned confidence scores can be applied in different ways depending on the type of data node.

[0066] It should be understood that this application does not restrict the node type. For example, the node type may include master node type and ordinary node type. The master node type and ordinary node type can be distinguished based on the different tasks they play in consensus. The data node of the master node type plays a more important role in consensus, and correspondingly, the confidence penalty for the data node of the master node type is more severe.

[0067] For example, after each consensus is reached on IoT data in the blockchain, confidence rewards or penalties can be applied to ordinary node type data nodes using publicity (1), and confidence rewards or penalties can be applied to master node type data nodes using publicity (2), in order to update the confidence data of each data node.

[0068]

[0069]

[0070] Where r is the confidence level of the data node; n is the number of consecutive abnormal behaviors of the data node; p is the penalty factor for consecutive abnormal behaviors, which is generally taken as a natural constant; and total is the cumulative number of abnormal behaviors of the data node.

[0071] v i Let i be the reward or penalty value for the i-th data node that completes consensus. Where N is the number of data nodes participating in consensus within the same shard, and v represents the number of data nodes during normal behavior. i For extra rewards, otherwise v i The node that crashes will be penalized with a random value in the (0, 1) area.

[0072] S202. Perform multiple pre-shardings on the blockchain's data nodes, and determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area.

[0073] In this step, after the data node obtains the confidence data of each data node in the blockchain, it can perform multiple pre-shardings on the blockchain data nodes and determine the fitness parameters corresponding to each pre-sharding based on the confidence data of each data node.

[0074] Among them, the aforementioned malicious data nodes can be the data nodes exhibiting the aforementioned abnormal behavior.

[0075] It should be understood that, in some embodiments of this application, regarding how to determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node, the data node may first calculate the average value of the confidence data of the data nodes in each shard and the average value of the confidence data of all data nodes, then calculate the absolute value of the difference between the average value of the confidence data of the data nodes in each shard and the average value of the confidence data of all data nodes, and finally use the sum of the absolute values ​​of the differences between the average value of the confidence data of the data nodes in each shard and the average value of the confidence data of all data nodes as the fitness parameter.

[0076] For example, the fitness parameters mentioned above can be determined by the fitness function, and the corresponding calculation method is shown in formula (3):

[0077]

[0078] Where k is the number of regions, and N is the total number of data nodes in the blockchain. i Let r be the number of data nodes in the i-th region, and r be the confidence level data of the data nodes.

[0079] It should be understood that this application embodiment does not limit the number of shards in each pre-sharding, as long as it meets the normal operation requirements of PBFT. Since the minimum consensus scale in PBFT requires 4 data nodes, the number of data nodes in each shard should be greater than 4. Correspondingly, the number of shards cannot exceed N / 4, where N is the total number of data nodes in the blockchain. Furthermore, since each shard runs PBFT consensus independently after sharding, the maximum number of malicious data nodes that can be tolerated in each shard is (N / 4). i -1) / 3, and the sum of the largest number of malicious data nodes that all shards can tolerate must not be less than the total number of malicious data nodes that could be tolerated before sharding. That is, Where Nδ represents the total number of malicious data nodes that the N data nodes can tolerate. This is achieved through... By scaling, we can obtain Will Substitute It can be determined that k≤N(1-3δ). Based on this, the number of regions divided in each pre-segmentation can be determined by formula (4).

[0080] k≤min {N(1-3δ), N / 4} (4)

[0081] The following explains the process of pre-sharding data nodes in a blockchain.

[0082] It should be understood that the embodiments of this application do not limit how data nodes are pre-sharded multiple times. In some embodiments, the idea of ​​multiple rounds of temperature decrease in the annealing algorithm and multiple iterations during each decrease can be used to perform multiple iterative calculations on the fitness parameters corresponding to different pre-shards. The iterative process of multiple pre-sharding is stopped when the temperature reaches the termination temperature, thereby obtaining the sharding result corresponding to the minimum fitness parameter.

[0083] Furthermore, based on the characteristics of blockchain sharding, when constructing new pre-shards, a genetic algorithm with chromosome crossover can be used to purposefully optimize the new pre-shards, thereby determining the iterative path corresponding to multiple pre-shardings and avoiding the situation of getting stuck at a local optimal solution.

[0084] For example, if the preshard to be executed is the first preshard, the data nodes of the blockchain are presharded randomly. If the preshard to be executed is not the first preshard, the data nodes of the blockchain are presharded according to the layout data of the data nodes corresponding to the previous preshard.

[0085] For example, for non-initial pre-sharding, the average confidence level of each shard in the previous pre-sharding can be determined first based on the layout data of the data nodes corresponding to the previous pre-sharding. Then, a first data node is randomly selected from the shard with the highest average confidence level, and a second data node is randomly selected from the shard with the lowest average confidence level. The confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes. Finally, the blockchain data nodes can be re-pre-sharded by swapping the shards where the first and second data nodes are located.

[0086] By continuously exchanging the first and second data nodes during the pre-sharding iteration process, the average confidence of each region is made to converge with the average confidence of all data nodes. This allows the fitness parameter to be continuously reduced across multiple pre-shards, thereby improving sharding efficiency.

[0087] S203. Based on the fitness parameters corresponding to each pre-sharding, determine the target layout data from the layout data of the data nodes in multiple pre-shardings.

[0088] In this step, after the data node performs multiple pre-shardings on the blockchain's data nodes and determines the fitness parameters corresponding to each pre-sharding, the target layout data can be determined from the layout data of the data nodes in the multiple pre-shardings based on the fitness parameters corresponding to each pre-sharding.

[0089] It should be understood that the embodiments of this application do not limit how to determine the target layout data from the layout data of data nodes in multiple pre-sharding. In some embodiments, since the fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharding region, in order to make the distribution of malicious data nodes in each pre-sharding region more uniform, the smallest fitness parameter can be determined from multiple fitness parameters, and the layout data corresponding to the smallest fitness parameter can be determined as the target layout data.

[0090] The aforementioned layout data may include information such as the number of shards and the data nodes contained in each shard.

[0091] S204. Based on the target layout data, shard the data nodes of the blockchain.

[0092] In this step, once the target layout data is determined, the data nodes of the blockchain can be sharded based on the target layout data.

[0093] It should be understood that the aforementioned target layout data corresponds to the minimum fitness parameter. By sharding the blockchain's data nodes according to the number of shards in the target layout data and the data of the data nodes contained in each shard, malicious data nodes can be evenly distributed across the pre-sharded shards, improving the security of each shard.

[0094] The blockchain data node sharding method provided in this application first obtains the confidence level data of each data node in the blockchain. Each confidence level data is used to characterize the trustworthiness of the corresponding data node when reaching consensus on IoT data. Second, the blockchain data nodes are pre-sharded multiple times, and a fitness parameter corresponding to each pre-sharding is determined based on the confidence level data of each data node. This fitness parameter characterizes the average distribution of malicious data nodes in each pre-sharded region. Third, based on the fitness parameter corresponding to each pre-sharding, target layout data is determined from the layout data of the data nodes in the multiple pre-shardings. Finally, the blockchain data nodes are sharded based on the target layout data. After pre-sharding the data nodes, the average distribution of malicious data nodes in each shard is determined based on the confidence data of each data node. Then, based on the average distribution of malicious data nodes in each shard, the optimal scheme is selected from the various pre-sharding schemes to shard the data nodes. This ensures that the number of malicious data nodes in each shard is similar, avoiding an excessive number of malicious data nodes in individual shards. This improves consensus efficiency while enhancing the security of each shard.

[0095] The following explains how to pre-shard data nodes in a blockchain. Figure 4This is a flowchart illustrating a method for pre-sharding data nodes provided in an embodiment of this application. Figure 4 As shown, the method includes S401-S409:

[0096] S401. Determine that the pre-partition to be executed is the initial pre-partition.

[0097] If yes, then execute S402; otherwise, execute S403.

[0098] S402. Randomly pre-shard the data nodes of the blockchain.

[0099] S403. Based on the layout data of the data nodes corresponding to the previous pre-sharding, determine the average confidence level of each area in the previous pre-sharding.

[0100] S404. Randomly determine the first data node in the area with the highest average confidence level, and randomly determine the second data node in the area with the lowest average confidence level.

[0101] Among them, the confidence level of the first data node is higher than the average confidence level of all data nodes, while the confidence level of the second data node is lower than the average confidence level of all data nodes.

[0102] S405. By exchanging the shards where the first data node and the second data node are located, the data nodes of the blockchain are pre-sharded again.

[0103] For example, such as Figure 5 As shown, the average confidence level of all data nodes is 4.5. In region S2, which had the highest average confidence level in the previous pre-sharding, a first data node with a confidence level exceeding 4.5 is randomly selected; this first data node has a confidence level of 8. Furthermore, in region S1, which had the lowest average confidence level in the previous pre-sharding, a second data node with a confidence level less than 4.5 is randomly selected; this second data node has a confidence level of 3. Subsequently, in the next pre-sharding, the regions containing the first and second data nodes are swapped.

[0104] S406. Based on the confidence data of each data node, determine the fitness parameters corresponding to this pre-sharding.

[0105] Among them, the fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded region;

[0106] S407. Determine whether multiple pre-sharding of data nodes has been completed.

[0107] If yes, then execute S409; otherwise, execute S408.

[0108] S408, Proceed to the next pre-fragmentation.

[0109] S401 is executed after S408.

[0110] S409. Based on the fitness parameters corresponding to each pre-sharding, determine the target layout data from the layout data of the data nodes in multiple pre-shardings.

[0111] S410. Based on the target layout data, shard the data nodes of the blockchain.

[0112] The data node pre-sharding method provided in this application embodiment determines the next pre-sharding method by randomly selecting a first data node from the region with the highest average confidence and a second data node from the region with the lowest average confidence. This ensures that the regions with the highest and lowest average confidence are converging towards the average confidence of all data nodes, resulting in a certain reduction in the fitness parameter after each pre-sharding iteration, thereby accelerating the sharding speed.

[0113] In one embodiment, another method for sharding data nodes in a blockchain is also provided, such as... Figure 6 As shown, the method includes S501-S506:

[0114] S501. After each consensus is reached on IoT data in the blockchain, determine the behavior type of each data node in the blockchain when reaching consensus on IoT data.

[0115] S502. Update the confidence data of each data node based on the behavior type of each data node when reaching consensus on IoT data and the node type of each data node.

[0116] S503. Obtain the confidence level data of each data node in the blockchain. Each confidence level data is used to characterize the credibility of the data node corresponding to that confidence level data when reaching consensus on IoT data.

[0117] S504. Perform multiple pre-shardings on the blockchain's data nodes, and determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area.

[0118] S505. Based on the fitness parameters corresponding to each pre-sharding, determine the target layout data from the layout data of the data nodes in multiple pre-shardings.

[0119] S506. Based on the target layout data, shard the data nodes of the blockchain.

[0120] The blockchain data node sharding method provided in this application embodiment is as follows: Figure 7As shown, after sharding the data nodes using the aforementioned blockchain data node sharding method and performing multiple consensus processes, the average confidence level of each shard is almost equal to the average confidence level among all data node shards. Figure 8 As shown, when the number of data nodes in each region is equal, the sharding success rate is close to 100%. If the number of data nodes in each region is unequal, the sharding success rate will decrease. Figure 9 The figure shows a comparison of system throughput under different numbers of regions.

[0121] The blockchain data node sharding method provided in this application first obtains the confidence level data of each data node in the blockchain. Each confidence level data is used to characterize the trustworthiness of the corresponding data node when reaching consensus on IoT data. Second, the blockchain data nodes are pre-sharded multiple times, and a fitness parameter corresponding to each pre-sharding is determined based on the confidence level data of each data node. This fitness parameter characterizes the average distribution of malicious data nodes in each pre-sharded region. Third, based on the fitness parameter corresponding to each pre-sharding, target layout data is determined from the layout data of the data nodes in the multiple pre-shardings. Finally, the blockchain data nodes are sharded based on the target layout data. After pre-sharding the data nodes, the average distribution of malicious data nodes in each shard is determined based on the confidence data of each data node. Then, based on the average distribution of malicious data nodes in each shard, the optimal scheme is selected from the various pre-sharding schemes to shard the data nodes. This ensures that the number of malicious data nodes in each shard is similar, avoiding an excessive number of malicious data nodes in individual shards. This improves consensus efficiency while enhancing the security of each shard.

[0122] It should be understood that although the steps in the flowcharts of the above embodiments are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the flowcharts of the above embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages of other steps.

[0123] Based on the same inventive concept, this application also provides a blockchain data node sharding apparatus for implementing the blockchain data node sharding method described above. The solution provided by this apparatus is similar to the implementation described in the above method; therefore, the specific limitations in one or more blockchain data node sharding apparatus embodiments provided below can be found in the limitations of the blockchain data node sharding method described above, and will not be repeated here.

[0124] In one embodiment, such as Figure 10 As shown, a sharding device 600 for blockchain data nodes is provided, comprising: an acquisition module 601, a determination module 602, a sharding module 603, and an update module 604, wherein:

[0125] The acquisition module 601 is used to acquire the confidence data of each data node in the blockchain. Each confidence data is used to characterize the degree of trustworthiness of the data node corresponding to the confidence data when reaching consensus on IoT data.

[0126] The determination module 602 is used to pre-shard the data nodes of the blockchain multiple times, and determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area.

[0127] The sharding module 603 is used to determine the target layout data from the layout data of data nodes in multiple pre-shardings based on the fitness parameters corresponding to each pre-sharding; and to shard the data nodes of the blockchain based on the target layout data.

[0128] In one embodiment, the determining module 602 is specifically used to pre-shard the blockchain data nodes randomly if the pre-shard to be executed is the first pre-shard; and to pre-shard the blockchain data nodes according to the layout data of the data nodes corresponding to the previous pre-shard if the pre-shard to be executed is not the first pre-shard.

[0129] In one embodiment, the determining module 602 is specifically used to determine the average confidence level of each shard in the previous pre-sharding based on the layout data of the data nodes corresponding to the previous pre-sharding; randomly determine a first data node in the shard with the highest average confidence level, and randomly determine a second data node in the shard with the lowest average confidence level, wherein the confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes; and re-pre-shard the blockchain data nodes by swapping the shards where the first data node and the second data node are located.

[0130] In one embodiment, the sharding device for the blockchain's data nodes further includes:

[0131] The update module 604 is used to update the confidence data of each data node in the blockchain according to the behavior of each node in the blockchain towards the IoT data after each consensus is reached on the IoT data in the blockchain.

[0132] In one embodiment, the update module 604 is specifically used to determine the behavior type of each data node in the blockchain when reaching consensus on IoT data; and to update the confidence data of each data node according to the behavior type of each data node when reaching consensus on IoT data and the node type of each data node.

[0133] In one embodiment, the update module 604 is specifically used to determine the target data node's behavior type for IoT data as abnormal behavior if the target data node crashes during consensus on IoT data, or if the consensus information of the target data node for IoT data is the first consensus information; and to determine the target data node's behavior type for IoT data as normal behavior if the consensus information of the target data node for IoT data is the second consensus information.

[0134] The target data node is any data node in the blockchain, and the amount of first consensus information is less than the amount of second consensus information.

[0135] The modules in the sharding device of the aforementioned blockchain data nodes can be implemented entirely or partially through software, hardware, or a combination thereof. These modules can be embedded in or independent of the processor in a computer device in hardware form, or stored in the memory of a computer device in software form, so that the processor can call and execute the operations corresponding to each module.

[0136] In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as follows: Figure 11As shown, the computer device includes a processor, memory, input / output interfaces, a communication interface, a display unit, and an input device. The processor, memory, and input / output interfaces are connected via a system bus, and the communication interface, display unit, and input device are also connected to the system bus via the input / output interfaces. The processor provides computing and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs stored in the non-volatile storage media. The input / output interfaces are used for exchanging information between the processor and external devices. The communication interface is used for wired or wireless communication with external terminals; wireless communication can be achieved through Wi-Fi, mobile cellular networks, NFC (Near Field Communication), or other technologies. When executed by the processor, the computer program implements a data node sharding method for a blockchain.

[0137] Those skilled in the art will understand that Figure 11 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.

[0138] In one embodiment, a computer device is provided, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the sharding method for data nodes of the blockchain described above.

[0139] In one embodiment, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the sharding method for data nodes in the blockchain described above.

[0140] In one embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements the sharding method for data nodes of the blockchain described above.

[0141] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data shall comply with the relevant laws, regulations and standards of the relevant countries and regions.

[0142] 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. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments of the above methods. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM). The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.

[0143] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0144] The above embodiments are merely illustrative of several implementation methods of this application, and their descriptions are relatively specific and detailed. However, they should not be construed as limiting the scope of this application. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the protection scope of this application. Therefore, the protection scope of this application should be determined by the appended claims.

Claims

1. A method for sharding data nodes in a blockchain, characterized in that, The method, applied to any data node of the blockchain, includes: The confidence level data of each data node in the blockchain is obtained, and each confidence level data is used to characterize the degree of trustworthiness of the data node corresponding to the confidence level data when reaching consensus on IoT data. The data nodes of the blockchain are pre-sharded multiple times, and the fitness parameter corresponding to each pre-sharding is determined based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area. Based on the fitness parameters corresponding to each pre-sharding, the target layout data is determined from the layout data of the data nodes in the multiple pre-shardings; Based on the target layout data, the data nodes of the blockchain are sharded; The step of performing multiple pre-sharding operations on the data nodes of the blockchain includes: If the preshard to be executed is the first preshard, then the data nodes of the blockchain are presharded randomly; If the preshard to be executed is not the first preshard, then based on the layout data of the data nodes corresponding to the previous preshard, the average confidence level of each region of the previous preshard is determined; a first data node is randomly selected from the region with the highest average confidence level, and a second data node is randomly selected from the region with the lowest average confidence level. The confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes; by swapping the regions where the first data node and the second data node are located, the data nodes of the blockchain are re-presharded.

2. The method according to claim 1, characterized in that, The method further includes: After each consensus is reached on the IoT data in the blockchain, the confidence data of each data node in the blockchain is updated according to the behavior of each node in the blockchain toward the IoT data.

3. The method according to claim 2, characterized in that, The step of updating the confidence data of each data node in the blockchain based on the behavior of each node in the blockchain towards the IoT data includes: Determine the behavior type of each data node in the blockchain when reaching consensus on the IoT data; The confidence data of each data node is updated based on the behavior type of each data node when reaching consensus on the IoT data and the node type of each data node.

4. The method according to claim 3, characterized in that, The step of determining the behavior type of each data node in the blockchain in response to the IoT data includes: If the target data node crashes during consensus on the IoT data, or if the consensus information of the target data node on the IoT data is the first consensus information, then the behavior type of the target data node on the IoT data is determined to be abnormal behavior. If the consensus information of the target data node regarding the IoT data is the second consensus information, then the behavior type of the target data node regarding the IoT data is determined to be normal behavior. The target data node is any data node in the blockchain, and the amount of the first consensus information is less than the amount of the second consensus information.

5. A sharding device for blockchain data nodes, characterized in that, The device includes: The acquisition module is used to acquire the confidence data of each data node in the blockchain. Each confidence data is used to characterize the credibility of the data node corresponding to the confidence data when reaching consensus on IoT data. The determination module is used to pre-shard the data nodes of the blockchain multiple times, and determine the fitness parameter corresponding to each pre-sharding based on the confidence data of each data node. The fitness parameter is used to characterize the average distribution of malicious data nodes in each pre-sharded area. The sharding module is used to determine the target layout data from the layout data of the data nodes in the multiple pre-sharding based on the fitness parameters corresponding to each pre-sharding; and to shard the data nodes of the blockchain based on the target layout data. The determining module is further configured to: if the pre-sharding to be executed is the first pre-sharding, randomly pre-shard the data nodes of the blockchain; if the pre-sharding to be executed is not the first pre-sharding, determine the average confidence level of each region of the previous pre-sharding based on the layout data of the data nodes corresponding to the previous pre-sharding; randomly determine a first data node in the region with the highest average confidence level, and randomly determine a second data node in the region with the lowest average confidence level, wherein the confidence level of the first data node is higher than the average confidence level of all data nodes, and the confidence level of the second data node is lower than the average confidence level of all data nodes; and re-pre-shard the data nodes of the blockchain by swapping the regions where the first data node and the second data node are located.

6. The apparatus according to claim 5, characterized in that, The device further includes: The update module is used to update the confidence data of each data node in the blockchain according to the behavior of each node in the blockchain towards the IoT data after each consensus is reached on the IoT data.

7. The apparatus according to claim 6, characterized in that, The update module is further configured to determine the behavior type of each data node in the blockchain when reaching consensus on IoT data; and update the confidence data of each data node according to the behavior type of each data node when reaching consensus on IoT data and the node type of each data node.

8. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 4.

9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Reputation value dynamic fragmentation two-layer consensus method based on blockchain data sharing

    CN112417056A

  • Internet of Things data storage-oriented block chain fragment optimization method

    CN115913662A