Blockchain sharding method, system and electronic device

By statistically analyzing the number of transactions between business nodes in the blockchain and dynamically adjusting the sharding cycle, the problems of resource waste and inefficiency caused by random sharding are solved, achieving more reasonable sharding and more efficient consensus.

CN114490020BActive Publication Date: 2025-11-11TSINGHUA UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111475185.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-03
Publication Date
2025-11-11
Estimated Expiration
2041-12-03

AI Technical Summary

Technical Problem

In existing blockchain sharding methods, random sharding leads to high resource consumption and low consensus efficiency. The sharding is unreasonable and cannot adapt to changes in transaction volume between business nodes.

Method used

By counting the number of transactions between various business nodes in the blockchain during the current sharding cycle, the sharding of the next sharding cycle is dynamically adjusted based on the number of transactions. The sharding is updated using global consensus nodes and regulatory nodes to ensure that the sharding matches the transaction situation between business nodes.

Benefits of technology

It achieves the rationality of blockchain sharding, reduces network resource consumption, improves consensus efficiency, and adapts to changes in transaction volume between business nodes.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490020B_ABST
    Figure CN114490020B_ABST
Patent Text Reader

Abstract

The application provides a blockchain sharding method, system and electronic equipment, wherein the method comprises: in a current sharding period, counting the number of transactions between each two business nodes of the blockchain, wherein each business node of the blockchain is divided into multiple shards in the current sharding period; based on the number of transactions, determining each shard of the blockchain in the next sharding period of the current sharding period; and broadcasting the determined result in the blockchain, so that the business node updates the shard where the business node is located in the next sharding period based on the determined result. The application solves the defects in the prior art that the random sharding of the blockchain causes large resource consumption of the whole blockchain network and low consensus efficiency, and realizes dynamic adjustment of the blockchain sharding according to the transaction volume between business nodes, so that the sharding of the blockchain is more reasonable and the resource consumption of the whole blockchain network is reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of blockchain technology, and in particular to a blockchain sharding method, system, and electronic device. Background Technology

[0002] Blockchain, as a decentralized, distributed, peer-to-peer trusted network, is the core supporting technology of the digital cryptocurrency system. Blockchain technology possesses properties such as high transparency, decentralization, trustlessness, collective maintenance (immutability), and anonymity. By employing data encryption, timestamps, distributed consensus, and economic incentives, it enables peer-to-peer transactions, coordination, and collaboration based on decentralized trust in a distributed system where nodes do not need to trust each other. This provides a solution to the problems of high costs, low efficiency, and insecure data storage commonly found in centralized institutions.

[0003] Sharding is a traditional scaling technique based on dividing a database into fragments. It divides the database into multiple shards and places these shards on different servers. Within the underlying public blockchain system, transactions on the network are divided into different shards, which are composed of different nodes on the network. Therefore, only a small portion of the input transactions need to be processed, and a large amount of verification work can be completed through parallel processing with other nodes on the network. Sharding the network allows more transactions to be processed and verified simultaneously, thus making it possible for the blockchain to handle increasingly more transactions as the network grows.

[0004] Current sharding methods primarily address blockchain security issues, and therefore are mostly based on random methods. However, while random sharding solves the security problem, it also leads to complete randomness in the sharding of business nodes within the blockchain. This can result in unreasonable sharding, which can easily lead to a waste of communication and computing resources. Summary of the Invention

[0005] This invention provides a blockchain sharding method, system, and electronic device to address the shortcomings of existing technologies that use random sharding methods, resulting in high overall resource consumption and low consensus efficiency in the blockchain network. The invention enables dynamic adjustment of blockchain sharding based on transaction volume between business nodes, making blockchain sharding more reasonable and reducing overall resource consumption of the blockchain network.

[0006] This invention also provides a blockchain sharding method, comprising:

[0007] Within the current sharding period, the number of transactions between every two business nodes in each business node of the blockchain is counted, wherein each business node of the blockchain is divided into multiple shards in the current sharding period.

[0008] Based on the number of transactions, determine each shard of the blockchain in the next sharding period of the current sharding period;

[0009] The determined result is broadcast in the blockchain so that the business node updates the shard it belongs to based on the determined result in the next sharding cycle.

[0010] According to the blockchain sharding method of the present invention, the step of counting the number of transactions between every two business nodes in each business node of the blockchain during the current sharding period includes:

[0011] Collect the number of transactions between every two business nodes in each shard consensus phase during the current sharding period;

[0012] The number of transactions between every two business nodes in each of the shard consensus phases is summarized to obtain the number of transactions between every two business nodes in each business node of the blockchain during the current sharding period.

[0013] According to the blockchain sharding method of the present invention, determining each shard of the blockchain in the next sharding period based on the number of transactions includes:

[0014] Each of the aforementioned business nodes is mapped to a point distributed in a multi-dimensional space, and the coordinates of the point mapped to the business node contain at least the number of transactions between the business node and each of the other business nodes.

[0015] Based on preset selection rules, select one clustering result corresponding to each candidate value of the number of fragments from the clustering results corresponding to each candidate value of the number of fragments.

[0016] Based on the results of the selected clustering, the individual shards of the blockchain are determined for the next sharding period in the current sharding period.

[0017] According to the blockchain sharding method of the present invention, the plurality of candidate values ​​for the number of shards in the next sharding period include: a first candidate value for the number of shards in the next sharding period obtained by a predetermined candidate rule, and a plurality of second candidate values ​​for the number of shards constructed based on the first reference value for the number of shards;

[0018] The predetermined candidate rules include:

[0019] When the sharding requirements of the next sharding cycle change relative to the sharding of the current sharding cycle, a first sharding quantity candidate value for the next sharding cycle is obtained based on the total number of business nodes in the blockchain and the number of business nodes pre-included in each shard in the next sharding cycle.

[0020] If the sharding requirements for the next sharding cycle remain unchanged compared to the sharding requirements of the current sharding cycle, the number of shards in the current sharding cycle will be used as the first candidate value for the number of shards in the next sharding cycle.

[0021] According to the blockchain sharding method of the present invention, the sharding requirement for the next sharding cycle changes relative to the sharding of the current sharding cycle, including:

[0022] In the next sharding cycle, any parameter in the preset parameter set changes relative to the sharding of the current sharding cycle;

[0023] The preset parameter set includes at least one of the following parameters: the number of service nodes pre-included in each shard, the preset step size for constructing the candidate value of the second shard number, and the adjustment parameter for expanding the number of candidate values ​​of the second shard number.

[0024] According to the blockchain sharding method of the present invention, the plurality of candidate values ​​for the number of second shards constructed based on the first shard number reference value includes:

[0025] When the sharding requirement of the next sharding cycle changes relative to the sharding of the current sharding cycle, multiple second sharding number candidate values ​​are constructed based on the first sharding number candidate value of the next sharding cycle, the preset step size, and the adjustment parameters, with the first sharding number candidate value as the center and distributed with equal arithmetic values ​​on both sides.

[0026] When the sharding requirement for the next sharding cycle remains unchanged relative to the sharding requirement for the current sharding cycle, multiple candidate values ​​for the second sharding quantity are constructed based on the sharding quantity of the current sharding cycle and the adjustment parameters, with the sharding quantity of the current sharding cycle as the center and distributed at equal arithmetic values ​​on both sides.

[0027] According to the blockchain sharding method of the present invention, the step of selecting one cluster result corresponding to each candidate shard number from the cluster results corresponding to each candidate shard number based on a preset selection rule includes:

[0028] For each clustering, the distance between each point mapped by the business node in the clustering result and the corresponding cluster center is calculated.

[0029] Summing each of the distances yields a sum of distances based on the results of each clustering.

[0030] The clustering result with the smallest distance sum is determined as the respective shards of the blockchain in the next sharding period of the current sharding period.

[0031] The present invention also provides a blockchain sharding system, including a global consensus node in the blockchain;

[0032] The global consensus node is used to count the number of transactions between any two business nodes in the blockchain during the current sharding period, wherein each business node in the blockchain is divided into multiple shards during the current sharding period; based on the number of transactions, it determines each shard of the blockchain in the next sharding period; and broadcasts the determined results in the blockchain so that the business nodes update the shard they belong to in the next sharding period based on the determined results.

[0033] The blockchain sharding system according to the present invention further includes: a supervisory node in the blockchain;

[0034] The supervisory node is used to perform initial sharding of each business node of the blockchain according to preset sharding rules, and to assign the shard to be joined in the next sharding cycle for new business nodes that apply to join the blockchain in the current sharding cycle according to preset supervisory rules.

[0035] The preset regulatory rule is a preset sharding rule, or it may be to add the new business node to the shard to which the business node that made the first transaction with the new business node belongs in the next sharding cycle.

[0036] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the steps of any of the blockchain sharding methods described above.

[0037] This invention provides a blockchain sharding method, system, and electronic device. By counting the number of transactions between every two business nodes in the blockchain during the current sharding period, and then determining the shards of the blockchain for the next sharding period based on these transaction counts, the determined results are broadcast in the blockchain. This allows the business nodes to update their shards in the next sharding period based on the determined results. This achieves the adjustment of blockchain sharding for the next sharding period based on the number of transactions between business nodes, making the blockchain sharding more aligned with the transaction situation between business nodes. This results in more rational blockchain sharding, reduces overall blockchain network resource consumption, and improves consensus efficiency. Attached Figure Description

[0038] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0039] Figure 1 This is a flowchart illustrating a blockchain sharding method provided by the present invention;

[0040] Figure 2 This is a schematic diagram of the structure of a blockchain sharding system provided by the present invention;

[0041] Figure 3 This is a schematic diagram of the structure of the electronic device provided by the present invention. Detailed Implementation

[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.

[0043] It should be noted that, for ease of understanding, before describing the blockchain sharding method, system, and electronic device described in this invention, the technical terms and names involved in this invention will be explained first:

[0044] Blockchain technology is characterized by high transparency, decentralization, trustlessness, collective maintenance (immutability), and anonymity. By employing data encryption, timestamps, distributed consensus, and economic incentives, it enables peer-to-peer transactions, coordination, and collaboration based on decentralized credit in distributed systems where nodes do not need to trust each other. This provides a solution to the problems of high cost, low efficiency, and insecure data storage that are common in centralized institutions.

[0045] Sharding: A traditional scaling technique based on dividing a database into fragments. It divides the database into multiple fragments and places these fragments on different servers. Within the underlying public blockchain system, transactions on the network are divided into different fragments, composed of different nodes on the network. Therefore, only a small portion of the input transactions need to be processed, and a large amount of verification work can be completed through parallel processing with other nodes on the network. Sharding the network allows more transactions to be processed and verified simultaneously, thus making it possible for the blockchain to handle increasingly more transactions as the network grows.

[0046] Node: In a blockchain, a node typically refers to a computer that has downloaded the relevant cryptocurrency software to participate in a peer-to-peer network. The structure of a cryptocurrency blockchain is a peer-to-peer (P2P) network architecture. P2P means that participating computers are equal to each other. In a P2P network, every computer participating in the network can receive the node's name. All nodes in the network are responsible for providing network services; this interconnectivity allows for interoperability.

[0047] It's important to note that, on the one hand, current sharding methods primarily address blockchain security issues, thus relying heavily on randomization. While random sharding solves security problems, this very randomness means that frequently transacting nodes might be randomly assigned to two different shards. This leads to frequent global consensus processes between these nodes, wasting communication and computational resources. Therefore, random sharding is prone to inefficient sharding. On the other hand, with the continuous improvement of regulatory mechanisms and the application of blockchain in various scenarios, blockchain security no longer needs to rely entirely on random sharding. Furthermore, random sharding is not suitable for all blockchain application scenarios.

[0048] For example, in the context of distributed power trading, blockchain applications face challenges due to the characteristics of distributed power trading in the energy internet. More energy, especially new energy, tends to be consumed locally. Therefore, a completely random sharding method would place greater demands on communication and computing resources on a multi-level blockchain trading platform. Furthermore, due to the business characteristics of power trading and the involvement of regulators, the need for security based on randomness in consensus is gradually decreasing. In this application scenario, what is needed is faster consensus formation and rapid execution of spot transactions.

[0049] The following is combined with Figure 1 This invention describes a blockchain sharding method, which is executed by business nodes in the blockchain used to achieve global consensus, or a combination of software and / or hardware therein, such as... Figure 1 As shown, the method includes the following steps:

[0050] 101. Within the current sharding period, count the number of transactions between every two business nodes in each business node of the blockchain, wherein each business node of the blockchain is divided into multiple shards in the current sharding period.

[0051] 102. Based on the number of transactions, determine each shard of the blockchain in the next sharding period of the current sharding period;

[0052] It should be noted that at the initial stage of blockchain operation, the blockchain must first be initially sharded. Then, based on the initial sharding, the number of transactions between every two business nodes in each business node of the blockchain within the first sharding period is counted. Then, based on the number of transactions, the shards of the blockchain in the next sharding period are determined. This operation is repeated to achieve dynamic adjustment of the sharding of each business node of the blockchain based on the number of transactions between business nodes, with the set sharding period as the period.

[0053] 103. Broadcast the determined result in the blockchain so that the business node updates the shard in the next sharding cycle based on the determined result.

[0054] It should be noted that within each sharding cycle, data transmission occurs between business nodes according to business needs, resulting in a number of peer-to-peer transactions between business nodes. By statistically analyzing the number of transactions between every two business nodes, and then determining the shards of the blockchain for the next sharding cycle based on these transaction counts, the determined results are broadcast in the blockchain. This allows the business nodes to update their shards in the next sharding cycle based on the determined results. This process adjusts the blockchain shards for the next sharding cycle based on the number of transactions between business nodes, overcoming the potential for unreasonable sharding caused by random sharding, reducing the overall resource consumption of the blockchain network, and improving consensus efficiency.

[0055] In practical applications, the blockchain sharding method provided in this embodiment can be applied to various blockchain-based transaction scenarios, such as distributed power trading in the energy internet. Accordingly, the blockchain can be used for power trading management, and the business nodes can be power grid companies, distributed generation users, and power consumers. Generation users and power consumers can directly trade electricity, and power generation users, power consumers, and the power grid company can also directly trade electricity. Then, user data recorded by smart meters on each business node and published to the blockchain is used to settle transactions completed within a cycle. In power trading, the nodes of generation and consumption users, along with the nodes deployed by the power grid company in various locations, can function as business nodes for global consensus.

[0056] Specifically, in a blockchain, there are multiple business nodes divided according to shards. Within each shard, some business nodes, in addition to handling the transaction services they need, also act as consensus group nodes to undertake the block generation work in their respective shards, as well as management work such as confirming cross-shard transactions with other shards. At the same time, there are also global consensus nodes in the consensus group nodes within each shard that have the functions of performing global consensus and providing sharding suggestions to all business nodes in the next sharding cycle.

[0057] Based on this, when a sharding cycle begins, all business nodes of the blockchain... By obtaining sharding information from the determined results broadcast by global consensus nodes in the blockchain, the shard to which the user belongs in the current sharding period can be determined, and subsequent transaction services can be carried out based on the obtained sharding information.

[0058] For example, business nodes Segmented In the process, the "sharding information" it receives is the address of the consensus group to which its shard belongs. The consensus group Each node, i.e., the consensus group node, is responsible for sharding during this sharding cycle. The block generation process within the shard and the confirmation of cross-shard transactions with other shards. Furthermore, if... If a business node discovers it is not in a shard consensus group, it submits its required transaction service to a node in the consensus group. The consensus group node will distinguish whether the transaction service is an intra-shard transaction or a cross-shard transaction and conduct consensus with the appropriate consensus node; if the business node... Selected as a shard In the fragmented consensus group, then As a consensus group node, you will receive consensus group information from all other shards. , ..., And assume corresponding responsibilities, such as: collecting transactions sent to themselves and reaching consensus with other block generation nodes on the authenticity of each transaction.

[0059] In a preferred embodiment of the present invention, the number of transactions between every two business nodes in each shard consensus stage within the current sharding period is collected; then the number of transactions between every two business nodes in each shard consensus stage is summarized to obtain the number of transactions between every two business nodes in each business node of the blockchain within the current sharding period.

[0060] Understandably, business nodes acting as consensus group nodes will count and record the number of peer-to-peer transactions among all business nodes within their shard during the current sharding period. During sharding consensus, the consensus group nodes will verify this count. Similarly, global consensus nodes will count and record the number of peer-to-peer transactions among all business nodes globally during global consensus, and will also verify this count. Since global consensus includes multiple sharding consensuses, within each sharding period, the global consensus nodes need to aggregate the transaction counts of each business node as counted by the consensus group nodes to obtain the transaction counts between each business node and other business nodes in the blockchain. By combining the hierarchical consensus mechanism of sharding and global consensus with the rationality of sharding, the frequency of global consensus can be reduced, further decreasing the consumption of communication and computing resources and improving processing speed.

[0061] Specifically, the number of transactions between each business node and other business nodes in the blockchain, obtained by the global consensus node, can be represented by a matrix with the number of transactions between each business node as its elements, such as:

[0062] ;

[0063] in, This indicates the business nodes within the current sharding period. Towards The number of transactions.

[0064] Taking the distributed power trading scenario of the energy internet as an example, then Indicates within the current sharding cycle Sold to The number of electricity transactions.

[0065] More specifically, within the current sharding cycle, It may also be sold to Electricity, therefore, business nodes and The number of transactions between them should be and The sum of the two nodes represents the number of transactions between them, and a larger sum indicates more frequent transactions between the two nodes. Therefore, taking the reciprocal of the sum normalizes the number of transactions between the two nodes, transforming it into different values ​​distributed between 0 and 1. See Formula 1 below for details:

[0066] Formula 1;

[0067] It is evident that the smaller the value obtained from Formula 1, the closer the transactions between the two nodes are. Furthermore, when each business node is mapped into a multidimensional space based on the number of transactions between the current business node and other business nodes, the closer the two nodes are in the multidimensional space, the more frequent the transactions between the two nodes are.

[0068] Based on this, in another embodiment of the present invention, each of the business nodes is mapped to a point distributed in a multi-dimensional space, and the coordinates of the point mapped by the business node include at least the number of transactions between the business node and each of the other business nodes.

[0069] Based on the distance between points distributed in the multidimensional space, the points distributed in the multidimensional space are clustered according to a number of preset candidate values ​​for the number of shards in the next sharding cycle.

[0070] Based on preset selection rules, select one clustering result corresponding to each candidate value of the number of fragments from the clustering results corresponding to each candidate value of the number of fragments.

[0071] Based on the results of the selected clustering, the individual shards of the blockchain are determined for the next sharding period in the current sharding period.

[0072] It should be noted that in the above embodiments of the present invention, the number of transactions between business nodes in each sharding period is mapped to a clustering problem in order to achieve automatic updates of business node sharding in each sharding period.

[0073] Furthermore, in order to ensure that the sharding recommendations implemented in the next sharding cycle reduce the overall resource consumption of the blockchain network and improve the formation and execution speed of transactions between nodes with frequent transactions, the global consensus node will cluster each business node based on multiple preset candidate values ​​for the number of shards in the next sharding cycle, and then select the best one from the clustering results.

[0074] Specifically, based on the number of transactions between the current business node and other business nodes, each business node is mapped to a point distributed in a multidimensional space. This can be achieved by mapping each business node to a point in a Cartesian coordinate system established in N-dimensional space; where N is the total number of business nodes in the blockchain.

[0075] In another embodiment of the present invention, a method for obtaining multiple candidate values ​​for the number of shards in the next sharding cycle is specifically described, namely, a first candidate value for the number of shards in the next sharding cycle obtained by a predetermined candidate rule, and multiple second candidate values ​​for the number of shards constructed based on the first reference value for the number of shards.

[0076] It is understandable that a regulatory node exists within the blockchain for monitoring and management. This type of node does not transact with other business nodes, nor does it belong to any shard; rather, it is a distinct type of node. For example, regulatory nodes have functions such as initial sharding of the blockchain and assigning shards to new business nodes applying to join the blockchain. Furthermore, regulatory nodes have accumulated prior experience based on the application scenarios of the blockchain, and therefore can utilize this prior experience to perform initial sharding. For instance, taking the distributed electricity trading scenario as an example, a regulatory node that uniformly supervises all electricity suppliers and consumers in a certain community can, based on its experience in managing distributed electricity trading scenarios, shard the community by single building, by every two buildings, by unit, and so on. Meanwhile, during the operation of a blockchain, not only do new business nodes apply to join the blockchain, but business nodes also leave the blockchain. Therefore, the number of business nodes in the blockchain changes in real time. Based on this, the regulatory node, combined with its accumulated prior experience, may make a judgment that the current sharding is not suitable for the more efficient operation of the blockchain. At this time, the regulatory node will declare the relevant changes to the sharding requirements in the blockchain, and these changes to the sharding requirements will affect the sharding decisions made by the global consensus nodes.

[0077] Based on this, in the above embodiments of the present invention, the predetermined candidate rule for obtaining the candidate value of the first shard quantity in the next sharding cycle is further limited to include:

[0078] When the sharding requirements of the next sharding cycle change relative to the sharding of the current sharding cycle, a first sharding quantity candidate value for the next sharding cycle is obtained based on the total number of business nodes in the blockchain and the number of business nodes pre-included in each shard in the next sharding cycle.

[0079] If the sharding requirements for the next sharding cycle remain unchanged compared to the sharding requirements of the current sharding cycle, the number of shards in the current sharding cycle will be used as the first candidate value for the number of shards in the next sharding cycle.

[0080] It should be noted that when a regulatory node declares a change in sharding requirements in the blockchain, the most direct consequence is a change in the number of shards the blockchain will be divided into. Therefore, when the sharding requirements for the next sharding cycle change relative to the sharding requirements for the current sharding cycle, it is necessary to utilize the total number N of business nodes in the blockchain and the number θ of business nodes included in each shard in the next sharding cycle. The first candidate value for the number of shards in the next sharding cycle is obtained; and when the sharding requirement in the next sharding cycle remains unchanged compared to the sharding in the current sharding cycle, that is, the number of shards in the blockchain is not required to change at the regulated node in the next sharding cycle, then the number of shards in the current sharding cycle can be used. This serves as a candidate value for the first number of shards in the next sharding cycle.

[0081] Furthermore, although the sharding requirements of the regulatory node in the next sharding cycle may change relative to the sharding in the current sharding cycle, ultimately leading to a change in the number of shards in the next sharding cycle, the change in sharding requirements declared by the regulatory node is not a change in the number of shards. In other words, the regulatory node does not have the ability to determine the number of shards in the next sharding cycle, but can only judge whether the number of business nodes contained in each shard is appropriate based on information such as the number of transactions in the current sharding cycle.

[0082] Therefore, in another embodiment of the present invention, the situation in which the fragment representing the next fragmentation cycle changes relative to the fragment of the current cycle is specifically described:

[0083] In the next sharding cycle, any parameter in the preset parameter set changes relative to the sharding of the current sharding cycle;

[0084] The preset parameter set includes at least one of the following parameters: the number of service nodes pre-included in each shard, the preset step size for constructing the candidate value of the second shard number, and the adjustment parameter for expanding the number of candidate values ​​of the second shard number.

[0085] It should be noted that when a regulatory node determines that preset parameters have changed, it will broadcast this information to all global consensus nodes in the blockchain, declaring in which future sharding cycle the parameters will begin to be used. This broadcast can occur at any time, and the broadcast result is confirmed through a handshake between the two parties. The updated parameters will be recorded in the new block for consensus and used in the claimed cycle.

[0086] Furthermore, after obtaining the first candidate value for the number of shards, it is necessary to construct multiple second candidate values ​​for the number of shards based on the first candidate value for the number of shards. Therefore, in another embodiment of the present invention, when the sharding requirement of the next sharding cycle changes relative to the sharding of the current sharding cycle, multiple second candidate values ​​for the number of shards are constructed based on the first candidate value for the number of shards in the next sharding cycle, the preset step size, and the adjustment parameters, with the first candidate value for the number of shards as the center and distributed with equal arithmetic values ​​on both sides.

[0087] When the sharding requirement for the next sharding cycle remains unchanged relative to the sharding requirement for the current sharding cycle, multiple candidate values ​​for the second sharding quantity are constructed based on the sharding quantity of the current sharding cycle and the adjustment parameters, with the sharding quantity of the current sharding cycle as the center and distributed at equal arithmetic values ​​on both sides.

[0088] It should be noted that, with This represents adjusting parameters, to The step size is used when the fragmentation requirement for the next fragmentation cycle changes relative to the fragmentation requirement for the current fragmentation cycle. This allows us to obtain candidate values ​​based on the first number of fragments. k The number of candidate values ​​for the second segment is centered on the center and distributed with equal arithmetic values ​​to both sides.

[0089] When the sharding requirements for the next sharding cycle remain unchanged compared to the sharding requirements of the current sharding cycle, then... This allows us to obtain multiple candidate values ​​for the number of second fragments, centered on the number of fragments in the current fragmentation period, and distributed with equal arithmetic values ​​on both sides.

[0090] It is understandable that, based on the distances between points distributed in the multidimensional space, clustering these points according to multiple preset candidate values ​​for the number of shards in the next sharding cycle can be implemented using a clustering algorithm such as K-means. When clustering the points distributed in the multidimensional space based on the distances between them, the result is not only a clustering number of... or The clustering results can also provide the cluster centers for each cluster.

[0091] Specifically, the closer each cluster is to its cluster center, the closer the distance between the points in the cluster, which means there are more transactions between nodes. Therefore, in another embodiment of the present invention, for each clustering, the distance between each point mapped by the business node and the corresponding cluster center is calculated; the distances are summed to obtain the distance sum based on the result of each clustering; and then the clustering result with the smallest distance sum is determined as each shard of the blockchain in the next sharding period of the current sharding period.

[0092] It should be noted that determining the clustering result with the smallest distance sum as each shard of the blockchain in the next sharding period of the current sharding period is equivalent to clustering multiple candidate values ​​for the number of shards in the next sharding period based on preset values, and then selecting the sharding scheme that maximizes the number of transactions between business nodes in each shard to update the shard where the business node is located.

[0093] The blockchain sharding method described in this invention provides a technical approach that is deeply coupled with business operations and relies entirely on the execution of transaction business for sharding. By mapping the number of transactions between business nodes within a predetermined sharding period to a clustering problem, business nodes in the blockchain are sharded. This allows for adjustments to the sharding in each sharding period to adapt to changes in business operations, ensuring the secure and effective execution of sharding consensus while reducing the resources consumed by global consensus.

[0094] The following is combined with Figure 2 The present invention describes a blockchain sharding system, and the blockchain sharding system described below can be referred to in correspondence with the blockchain sharding method described above.

[0095] This invention provides a blockchain sharding system, including global consensus nodes in the blockchain;

[0096] The global consensus node is used to count the number of transactions between any two business nodes in the blockchain during the current sharding period, wherein each business node in the blockchain is divided into multiple shards during the current sharding period; based on the number of transactions, it determines each shard of the blockchain in the next sharding period; and broadcasts the determined results in the blockchain so that the business nodes update the shard they belong to in the next sharding period based on the determined results.

[0097] It is understood that a blockchain includes numerous business nodes, some of which not only execute their own business requirements but also have the function of achieving global consensus. These are the global consensus nodes included in the blockchain sharding system described in this invention. The global consensus nodes count the number of transactions between every two business nodes in the blockchain during the current sharding period. Based on these transaction counts, they determine the shards of the blockchain for the next sharding period. Finally, they broadcast the determined results to the blockchain, enabling the business nodes to update their shards in the next sharding period based on these results. This allows for adjustments to the blockchain shards in each sharding period based on the number of transactions between business nodes, making the sharding more rational in the next sharding period. This reduces the overall resource consumption of the blockchain network and improves consensus efficiency.

[0098] In a preferred embodiment of the present invention, the blockchain sharding system of the present invention further includes a supervisory node in the blockchain;

[0099] The supervisory node is used to perform initial sharding of each business node of the blockchain according to preset sharding rules, and to assign the shard to be joined in the next sharding cycle for new business nodes that apply to join the blockchain in the current sharding cycle according to preset supervisory rules.

[0100] The preset regulatory rule is a preset sharding rule, or it may be to add the new business node to the shard to which the business node that made the first transaction with the new business node belongs in the next sharding cycle.

[0101] It should be noted that in a blockchain, a regulatory node is a node that does not belong to any shard and has functions such as supervision and management. In the above embodiments of the present invention, the regulatory node performs initial sharding on each business node on the blockchain, and when a new business node applies to join the blockchain, it assigns the shard to the new blockchain in the next sharding cycle. Based on the initial sharding of the regulatory node, the global consensus node determines the shards within each business node of the blockchain in each sharding cycle according to the sharding requirements sent by the regulatory node.

[0102] Specifically, such as Figure 2 The diagram illustrates the structure of a blockchain sharding system according to an embodiment of the present invention, which demonstrates the relationships between various business nodes, global consensus nodes, and regulatory nodes.

[0103] Understandably, when a business node , For the total number of nodes, when joining the blockchain network, it must be approved by a custodian node. After an application to join the blockchain is approved through coordination among regulatory nodes, at least M core business nodes will be notified. .in, This represents the total number of nodes in the consensus group. This represents the maximum number of Byzantine nodes the network can handle.

[0104] Specifically, regulatory nodes Can be assigned Enter a certain fragment in the next fragmentation cycle. The assignment process can be based on the prior experience of the supervisory node; or it can be formed through the newly added node. The first exchange corresponds to another trading party Determine the shard to which the newly added node belongs.

[0105] Figure 3 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 3 As shown, the electronic device may include a processor 310, a communications interface 320, a memory 330, and a communication bus 340, wherein the processor 310, communications interface 320, and memory 330 communicate with each other via the communication bus 340. The processor 310 can invoke logical instructions in the memory 330 to execute a blockchain sharding method. This method includes: within the current sharding period, counting the number of transactions between every two business nodes in the blockchain, wherein each business node in the blockchain is divided into multiple shards in the current sharding period; determining each shard of the blockchain in the next sharding period based on the number of transactions; and broadcasting the determined results in the blockchain so that the business nodes update the shard they belong to in the next sharding period based on the determined results.

[0106] Furthermore, the logical instructions in the aforementioned memory 330 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, essentially, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0107] On the other hand, the present invention also provides a computer program product, the computer program product including a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer is able to execute the blockchain sharding method provided by the above methods. The method includes: in the current sharding period, counting the number of transactions between every two business nodes in each business node of the blockchain, wherein each business node of the blockchain is divided into multiple shards in the current sharding period; determining each shard of the blockchain in the next sharding period based on the number of transactions; and broadcasting the determined result in the blockchain so that the business node updates the shard to which the business node belongs in the next sharding period based on the determined result.

[0108] In another aspect, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the blockchain sharding method provided by the above methods. The method includes: within a current sharding period, counting the number of transactions between every two business nodes in each business node of the blockchain, wherein each business node of the blockchain is divided into multiple shards in the current sharding period; determining each shard of the blockchain in the next sharding period based on the number of transactions; and broadcasting the determined result in the blockchain so that the business node updates the shard to which it belongs in the next sharding period based on the determined result.

[0109] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.

[0111] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A blockchain sharding method, characterized in that, include: Within the current sharding period, the number of transactions between every two business nodes in each business node of the blockchain is counted, wherein each business node of the blockchain is divided into multiple shards in the current sharding period. Based on the number of transactions, determine each shard of the blockchain in the next sharding period of the current sharding period; The determined result is broadcast in the blockchain so that the business node updates its shard based on the determined result in the next sharding cycle; wherein, the number of transactions between any two business nodes in the blockchain is counted, including: Collect the number of transactions between every two business nodes in each shard consensus phase during the current sharding period; The number of transactions between every two business nodes in each of the shard consensus phases is aggregated to obtain the number of transactions between every two business nodes in each business node of the blockchain within the current sharding period; wherein, determining each shard of the blockchain in the next sharding period based on each of the transaction numbers includes: Each of the aforementioned business nodes is mapped to a point distributed in a multi-dimensional space, and the coordinates of the point mapped to the business node contain at least the number of transactions between the business node and each of the other business nodes. Based on the distance between points distributed in the multidimensional space, the points distributed in the multidimensional space are clustered according to a number of preset candidate values ​​for the number of shards in the next sharding cycle. Based on preset selection rules, select one clustering result corresponding to each candidate value of the number of fragments from the clustering results corresponding to each candidate value of the number of fragments. Based on the results of the selected clustering, the individual shards of the blockchain are determined in the next sharding period of the current sharding period; The plurality of candidate values ​​for the number of shards in the next sharding cycle includes: a first candidate value for the number of shards in the next sharding cycle obtained according to a predetermined candidate rule, and a plurality of second candidate values ​​for the number of shards constructed based on the first reference value for the number of shards; The predetermined candidate rules include: The candidate value for the first number of shards in the next sharding cycle is determined based on whether the sharding requirements in the next sharding cycle have changed relative to the sharding in the current sharding cycle.

2. The blockchain sharding method according to claim 1, characterized in that, The predetermined candidate rules include: When the sharding requirements of the next sharding cycle change relative to the sharding of the current sharding cycle, a first sharding quantity candidate value for the next sharding cycle is obtained based on the total number of business nodes in the blockchain and the number of business nodes pre-included in each shard in the next sharding cycle. If the sharding requirements for the next sharding cycle remain unchanged compared to the sharding requirements of the current sharding cycle, the number of shards in the current sharding cycle will be used as the first candidate value for the number of shards in the next sharding cycle.

3. The blockchain sharding method according to claim 2, characterized in that, The sharding requirements for the next sharding cycle change relative to the sharding requirements of the current sharding cycle, including: In the next sharding cycle, any parameter in the preset parameter set changes relative to the sharding of the current sharding cycle; The preset parameter set includes at least one of the following parameters: the number of service nodes pre-included in each shard, the preset step size for constructing the candidate value of the second shard number, and the adjustment parameter for expanding the number of candidate values ​​of the second shard number.

4. The blockchain sharding method according to claim 3, characterized in that, The plurality of candidate values ​​for the number of second fragments constructed based on the first fragment number reference value include: When the sharding requirement of the next sharding cycle changes relative to the sharding of the current sharding cycle, multiple second sharding number candidate values ​​are constructed based on the first sharding number candidate value of the next sharding cycle, the preset step size, and the adjustment parameters, with the first sharding number candidate value as the center and distributed with equal arithmetic values ​​on both sides. When the sharding requirement for the next sharding cycle remains unchanged relative to the sharding requirement for the current sharding cycle, multiple candidate values ​​for the second sharding quantity are constructed based on the sharding quantity of the current sharding cycle and the adjustment parameters, with the sharding quantity of the current sharding cycle as the center and distributed at equal arithmetic values ​​on both sides.

5. The blockchain sharding method according to claim 3, characterized in that, The step of selecting one clustering result corresponding to a candidate number of fragments from the clustering results corresponding to each candidate number of fragments based on a preset selection rule includes: For each clustering, the distance between each point mapped by the business node in the clustering result and the corresponding cluster center is calculated. Summing each of the distances yields a sum of distances based on the results of each clustering. The clustering result with the smallest distance sum is determined as the respective shards of the blockchain in the next sharding period of the current sharding period.

6. A blockchain sharding system, characterized in that, This includes global consensus nodes in the blockchain; The global consensus node is used to count the number of transactions between any two business nodes in the blockchain during the current sharding period, wherein each business node in the blockchain is divided into multiple shards during the current sharding period; based on the number of transactions, it determines each shard of the blockchain in the next sharding period; and broadcasts the determined results in the blockchain so that the business nodes update the shard they belong to in the next sharding period based on the determined results. The method of counting the number of transactions between any two business nodes in the blockchain includes: Collect the number of transactions between every two business nodes in each shard consensus phase during the current sharding period; The number of transactions between every two business nodes in each of the shard consensus phases is summarized to obtain the number of transactions between every two business nodes in each business node of the blockchain during the current sharding period. Wherein, determining each shard of the blockchain in the next sharding period based on the number of each transaction includes: Each of the aforementioned business nodes is mapped to a point distributed in a multi-dimensional space, and the coordinates of the point mapped to the business node contain at least the number of transactions between the business node and each of the other business nodes. Based on the distance between points distributed in the multidimensional space, the points distributed in the multidimensional space are clustered according to a number of preset candidate values ​​for the number of shards in the next sharding cycle. Based on preset selection rules, select one clustering result corresponding to each candidate value of the number of fragments from the clustering results corresponding to each candidate value of the number of fragments. Based on the results of the selected clustering, the individual shards of the blockchain are determined in the next sharding period of the current sharding period; The plurality of candidate values ​​for the number of shards in the next sharding cycle includes: a first candidate value for the number of shards in the next sharding cycle obtained according to a predetermined candidate rule, and a plurality of second candidate values ​​for the number of shards constructed based on the first reference value for the number of shards; The predetermined candidate rules include: The candidate value for the first number of shards in the next sharding cycle is determined based on whether the sharding requirements in the next sharding cycle have changed relative to the sharding in the current sharding cycle.

7. The blockchain sharding system according to claim 6, characterized in that, Also includes: The regulatory node in the blockchain; The supervisory node is used to perform initial sharding of each business node of the blockchain according to preset sharding rules, and to assign the shard to be joined in the next sharding cycle for new business nodes that apply to join the blockchain in the current sharding cycle according to preset supervisory rules. The preset regulatory rule is a preset sharding rule, or it may be to add the new business node to the shard to which the business node that made the first transaction with the new business node belongs in the next sharding cycle.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the steps of the blockchain sharding method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Fabric-based layered and fragmented transaction information processing method and application

    CN110400140A

  • Blockchain fragmentation method based on machine learning

    CN110619020A