Blockchain Dynamic Sharding Method Based on Hidden Markov and Related Devices

Through the Hidden Markov model, bottom-up dynamic sharding is performed in the blockchain network, and the cross-shash transaction problem caused by traditional blockchain sharding technology ignoring the interaction relationship between nodes is achieved, and system performance is improved and adaptive dynamic update of shard structure is achieved.

CN116319335BActive Publication Date: 2025-07-01BEIJING UNIV OF POSTS & TELECOMM +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310063216.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-01-18
Publication Date
2025-07-01
Estimated Expiration
2043-01-18

AI Technical Summary

Technical Problem

Traditional blockchain sharding technology adopts a ‘top-down’ method to form sharding, ignoring the interactive relationship between nodes, resulting in a high proportion of cross-shash transactions, affecting system performance.

Method used

The blockchain dynamic sharding method based on Hidden Markov is adopted, and by determining the blockchain network and dynamic transaction flow perception map, dynamically sharding is performed from bottom to top, dynamically update the sharding structure, and adapting to the dynamic changes of the blockchain transaction network.

Benefits of technology

It effectively reduces the system load and time overhead of node cross-shash transaction processing in blockchain network, improves system performance, and realizes adaptive dynamic update of shards.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116319335B_ABST
    Figure CN116319335B_ABST
Patent Text Reader

Abstract

The present application provides a blockchain dynamic sharding method and related devices based on Hidden Markov, including: determining a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices; determining a dynamic transaction flow perception graph according to the blockchain network; performing bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception graph to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure. The present application replaces the "top-down" sharding mechanism with a "bottom-up" sharding mechanism through a dynamic sharding mechanism, combines the dynamically evolving blockchain transaction network, realizes adaptive dynamic update of sharding, avoids a large number of cross-shard transactions generated due to ignoring the dynamic set characteristics between nodes during the sharding process, reduces the system load and time overhead for processing cross-shard transactions of nodes in the blockchain network, and improves the system performance compared with the traditional blockchain sharding mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of blockchain sharding, and particularly to a blockchain dynamic sharding method and related devices based on Hidden Markov Model (HMM). Background Art

[0002] With the rapid development of Internet of Things (IoT) and blockchain technologies, research on improving the scalability of IoT blockchain systems has become a trend. Sharding technology is considered the most promising solution, which improves the scalability of the blockchain by introducing the idea of divide and conquer when facing all transactions submitted to the blockchain system.

[0003] However, in terms of shard formation, traditional shard formation methods usually adopt a "top-down" approach, that is, from a global perspective, a single trusted node or consensus committee randomly assigns all nodes according to their network location, ignoring the interaction relationship between nodes, resulting in a relatively high proportion of cross-shard transactions and affecting the system performance. Summary of the Invention

[0004] In view of this, the purpose of this application is to propose a blockchain dynamic sharding method and related devices based on HMM.

[0005] Based on the above purpose, this application provides a blockchain dynamic sharding method based on HMM, which is characterized by including:

[0006] Determine a blockchain network; wherein, the blockchain network includes: IoT and IoT devices;

[0007] Determine a dynamic transaction flow perception graph according to the blockchain network;

[0008] Perform bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception graph to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a shard structure.

[0009] Optionally, the determining a dynamic transaction flow perception graph according to the blockchain network includes:

[0010] Determine the nodes in the blockchain, the transaction behaviors between the nodes, and the transaction time of the transaction behaviors, and determine a blockchain transaction network according to the nodes, the transaction behaviors between the nodes, and the transaction time;

[0011] Determine the dynamic transaction flow perception graph according to the blockchain transaction network through an HMM.

[0012] Optionally, the determining the dynamic transaction flow perception graph according to the blockchain transaction network through an HMM includes:

[0013] Determine a network transaction snapshot set according to the blockchain transaction network;

[0014] Determine the dynamic transaction flow perception graph according to the network transaction snapshot set through a hidden Markov model.

[0015] Optionally, the determining a network transaction snapshot set according to the blockchain transaction network includes:

[0016] Determine the transaction behavior relationship at any moment of the blockchain network, and determine the network transaction snapshot at any moment according to the transaction behavior relationship at any moment;

[0017] Determine the network transaction snapshot set according to the network transaction snapshot at any moment.

[0018] Optionally, the sharding model is a hidden Markov model;

[0019] The bottom-up dynamic sharding of the blockchain network through a sharding model according to the dynamic transaction flow perception graph to determine a dynamic sharding result includes:

[0020] Determine the observable state sequence at any moment of the blockchain network according to the dynamic transaction flow perception graph;

[0021] Determine the relationship matrix between nodes and communities and the central node at any moment according to the dynamic transaction flow perception graph;

[0022] Calculate the cosine similarity between any node and the central node according to the central node, and determine the state transition probability matrix according to the cosine similarity;

[0023] Determine the state observation probability matrix according to the dynamic transaction flow perception graph;

[0024] Determine the sharding result through the Viterbi algorithm according to the state transition probability matrix, the state observation probability matrix, and the observable state set.

[0025] Optionally, the determining the observable state sequence at any moment of the blockchain network according to the dynamic transaction flow perception graph includes:

[0026] Determine the community relationship at any moment through a Markov chain according to the dynamic transaction flow perception graph;

[0027] Determine the observable state sequence according to the community relationship at any moment.

[0028] Optionally, the method further includes:

[0029] According to the dynamic sharding result, determine the sharding interval of the sharding through the modularity calculation formula shown below;

[0030]

[0031] Wherein, is the total number of edges in the transaction snapshot GS (t) in the total number of edges, is the number of edges within the community, is the community C i the sum of the node degrees within;

[0032] Determine the sharding structure according to the sharding interval; wherein, the sharding structure includes a main shard and sub-shards.

[0033] Optionally, the method includes:

[0034] Determine the change type in the blockchain network, and dynamically update the sharding structure according to the change type;

[0035] In response to determining that the change type is adding a new node, determine the membership degree of the new node to any community, and dynamically update the sharding structure according to the membership degree;

[0036] In response to determining that the change type is generating a new transaction, determine the edge of the new transaction, and update the sharding structure according to the edge of the new transaction;

[0037] In response to determining that the change type is node reduction, determine the type of the reduced node, and update the sharding structure according to the type of the reduced node.

[0038] Based on the same inventive concept, an embodiment of the present application further provides a blockchain dynamic sharding device based on a hidden Markov, including:

[0039] A first determination module configured to determine a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices;

[0040] A second determination module configured to determine a dynamic transaction flow perception graph according to the blockchain network;

[0041] A sharding module configured to perform bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception graph, and determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine the sharding structure.

[0042] Based on the same inventive concept, an embodiment of the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the program, it implements the method for dynamically sharding a blockchain based on Hidden Markov as described in any one of the above.

[0043] As can be seen from the above, the method for dynamically sharding a blockchain based on Hidden Markov and related devices provided by the present application include: determining a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices; determining a dynamic transaction flow perception map according to the blockchain network; dynamically sharding the blockchain network from bottom to top through a sharding model according to the dynamic transaction flow perception map to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure. The present application uses a "bottom-up" sharding mechanism through a dynamic sharding mechanism to replace the "top-down" sharding mechanism, and combines a dynamically evolving blockchain transaction network to achieve adaptive dynamic update of sharding, avoiding a large number of cross-sharding transactions caused by ignoring the dynamic set characteristics between nodes during the sharding process, reducing the system load and time overhead for processing cross-sharding transactions of nodes in the blockchain network. Compared with the traditional blockchain sharding mechanism, the present application effectively improves the performance of the system. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions in the present application or related technologies, the following will briefly introduce the drawings required for use in the description of the embodiments or related technologies. Obviously, the drawings in the following description are only embodiments of the present application. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.

[0045] Figure 1 It is a schematic flowchart of the method for dynamically sharding a blockchain based on Hidden Markov according to an embodiment of the present application;

[0046] Figure 2 It is a schematic structural diagram of an Internet of Things collaborative perception system based on dynamic sharding of a blockchain according to an embodiment of the present application;

[0047] Figure 3 It is a schematic diagram of a transaction perception flow map according to an embodiment of the present application;

[0048] Figure 4 It is a schematic flowchart of an embodiment of the dynamic change of a blockchain network according to an embodiment of the present application;

[0049] Figure 5 It is a schematic structural diagram of a module for dynamically sharding a blockchain based on Hidden Markov according to an embodiment of the present application;

[0050] Figure 6Schematic structural diagram of the electronic device according to an embodiment of the present application. Detailed implementation manners

[0051] To make the objectives, technical solutions, and advantages of the present application more clear and understandable, the following further elaborates on the present application in detail with reference to specific embodiments and the accompanying drawings.

[0052] It should be noted that unless otherwise defined, the technical terms or scientific terms used in the embodiments of the present application should have the ordinary meanings understood by those of ordinary skill in the art to which the present application pertains. The terms "first", "second", and similar terms used in the embodiments of the present application do not denote any order, quantity, or importance, but are merely used to distinguish different components. The terms "including" or "comprising" and similar terms mean that the elements or items appearing before the term cover the elements or items listed after the term and their equivalents, without excluding other elements or items. The terms "connected" or "coupled" and similar terms are not limited to physical or mechanical connections, but may include electrical connections, whether direct or indirect. The terms "upper", "lower", "left", "right", etc. are only used to represent relative positional relationships, and when the absolute position of the object being described changes, the relative positional relationship may also change accordingly.

[0053] As described in the background art section, with the rapid development of the Internet of Things and blockchain technologies, research on improving the scalability of Internet of Things blockchain systems has become a trend. Sharding technology is considered the most promising solution, which improves the scalability of the blockchain by introducing the idea of divide and conquer when facing all transactions submitted to the blockchain system.

[0054] However, in terms of shard formation, traditional shard formation methods usually adopt a "top-down" approach, that is, from a global perspective, a single trusted node or consensus committee shards and assigns all nodes according to their network locations or randomly, ignoring the interaction relationships between nodes, resulting in a relatively high proportion of cross-shard transactions and affecting the performance of the system.

[0055] In view of this, an embodiment of the present application provides a blockchain dynamic sharding method, device, and electronic device based on Hidden Markov. The present application replaces the "top-down" sharding mechanism with a "bottom-up" sharding mechanism through a dynamic sharding mechanism, and combines a dynamically evolving blockchain transaction network to achieve adaptive dynamic update of sharding, avoiding a large number of cross-shard transactions caused by ignoring the dynamic set characteristics between nodes during the sharding process, reducing the system load and time overhead of node cross-shard transaction processing in the blockchain network. Compared with the traditional blockchain sharding mechanism, the present application effectively improves the performance of the system. Further, this solution abandons the single-chain architecture used in traditional blockchain systems and constructs a hierarchical edge-cloud-end collaborative architecture by integrating edge computing technology. From the horizontal perspective of the edge-cloud-end collaborative architecture, the edge layer can collaborate with other edge network nodes across edge networks. From the vertical perspective of the edge-cloud-end collaborative architecture, devices at different levels can complete different data perception and computing tasks due to differences in capabilities, and can achieve data and computing offloading during cross-layer processing to meet the needs of multiple parties, enabling the blockchain collaborative perception network for the Internet of Things to accommodate more lightweight devices.

[0056] As Figure 1 shown, the blockchain dynamic sharding method based on Hidden Markov includes:

[0057] Step 102, determine a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices;

[0058] Step 104, determine a dynamic transaction flow perception map according to the blockchain network;

[0059] Step 106, perform bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception map to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure.

[0060] In step 102, the blockchain network is determined according to the Internet of Things collaborative perception system based on blockchain dynamic sharding as Figure 2 shown, as Figure 2 shown Figure 2The Internet of Things in it includes a smart home network, a smart transportation network, a smart campus network, a smart office network, a smart factory network, and a smart medical network. Each type of network includes multiple terminal devices and multiple users who use the multiple terminal devices. Further, transactions will occur between users and terminal devices. For example, in the smart transportation network, when a user wants to enter the highway, they first have to pass through the highway entrance. Among them, at the highway entrance / exit, there are respectively terminal devices for license plate recognition and microwave antennas for dedicated short-range communication with in-vehicle electronic tags installed on the vehicle windshield, whether it is a manual window channel or an ETC (Electronic Toll Collection) channel.

[0061] Further, in Figure 2 , the connection between users and terminals and the transactions between terminal devices are represented by lines. Among them, in the Internet of Things including a smart home network, a smart transportation network, a smart campus network, a smart office network, a smart factory network, and a smart medical network as shown in Figure 2 , the devices in any type of network are called Internet of Things devices. For example, an air conditioner in a smart home scenario, a printer in a smart office scenario, and a certain detection device in a smart medical scenario can all be called Internet of Things devices.

[0062] In some alternative embodiments, the blockchain-based dynamic sharding Internet of Things collaborative perception system includes: a trusted institution, an InterPlanetary File System (IPFS) server, an edge server, a main shard, sub-shards, and Internet of Things entities and peer nodes; in the Internet of Things network, users participate in performing different collaborative perception tasks and use different sensors to collect various types of data for different applications (such as smart cities, supply chains, autonomous driving, and environmental monitoring, etc.). At the same time, data sharing occurs between Internet of Things users for the same collaborative perception task or different tasks in different application fields. For example, a handheld terminal in logistics may need the images captured by the monitoring cameras of smartphones on the production line to achieve supply chain traceability.

[0063] Specifically: Trusted Authority (TA): TA mainly has two functions: (1) User registration: Before participating in collaborative perception, the user uses a key generation tool to generate a public-private key pair (pk, sk), and sends the public key pk to TA to request TA to issue a certificate for the binding of their identity information and the public key. This certificate will serve as a trusted guarantee for the binding between TA's identity information and the public key. For this function, TA is regarded as a real-name registration system, and users must provide real documents or information that can prove their personal identity, including ID number, name, gender, date of birth, place of birth, and blood type, etc. Then, TA creates an identity ID for each user to identify this user. During the entire registration process, different identities will also be assigned to different users, and these identities represent their social roles in reality. All registration information will be stored in the identity chain; (2) Internet of Things entity registration: In addition to user registration, TA is also responsible for creating an account for each Internet of Things entity and associating the account with sensors or smart terminals in the Internet of Things. For this function, TA is regarded as an anonymous system, and the account is generated by the assigned key pair, and all registration information will be stored in the identity chain. The InterPlanetary File System (IPFS) server is mainly used to store and share specific data in a distributed system, and only stores the indexes related to the data in the blockchain, thus greatly reducing the storage overhead.

[0064] Furthermore, in the Internet of Things collaborative perception coverage scenario, there are differences in the functions between devices. Devices with powerful functions (such as routers and gateways) can act as edge servers to perform complex computing and storage tasks; the main shard consists of some high-performance devices (routers or gateways) in the sub-shards, and these devices have strong computing and storage capabilities in the current shard. The main shard retains the global ledger as a full node, is responsible for final consensus on cross-shard transactions and the index blocks uploaded by sub-shards, and broadcasts the consensus result (or block) to all other nodes in the entire system; furthermore, each scenario can contain multiple sub-shards, and each sub-shard contains multiple blockchain nodes, jointly maintaining a local blockchain network. Taking the home scenario as an example, this area consists of household appliances with sensors and a large number of wearable smart devices, and realizes communication through connection to a router or a home gateway via an available network.

[0065] In some alternative embodiments, the Internet of Things entity and the peer node can be understood as follows: The Internet of Things blockchain supports the Internet of Things entities (such as Internet of Things servers, gateways, devices, etc.) to cooperate with each other in a "decentralized" mode. One or more blockchain peer nodes can be deployed on an Internet of Things entity. The Internet of Things entity is connected to the blockchain node through a "decentralized" application, and then cooperates with each other on the blockchain.

[0066] In some alternative embodiments, determining a dynamic transaction flow perception graph according to the blockchain network specifically includes: determining nodes in the blockchain, transaction behaviors between the nodes, and transaction times of the transaction behaviors; determining a blockchain transaction network according to the nodes, the transaction behaviors between the nodes, and the transaction times; determining transaction behavior relationships at any moment in the blockchain network, and determining a network transaction snapshot at any moment according to the transaction behavior relationships at any moment; determining a network transaction snapshot set according to the network transaction snapshot at any moment. Determining the dynamic transaction flow perception graph according to the network transaction snapshot set through a hidden Markov model.

[0067] Specifically, according to Figure 2 As shown in the Internet of Things collaborative perception system based on blockchain dynamic sharding, in the blockchain network, according to the information in the blockchain network, determine the nodes in the blockchain, the transaction behaviors between the nodes, and the transaction times of the transaction behaviors, and determine the blockchain transaction network G, G=(V, E, T) according to the nodes in the blockchain, the transaction behaviors between the nodes, and the transaction times of the transaction behaviors; where, the nodes in the blockchain are represented by v, the transaction behaviors between the nodes are represented by e, and the transaction times of the transaction behaviors are represented by t, then the node set V is {v1, v2, v3,..., v n}, the transaction behavior set E between the nodes is {e1, e2, e3,..., e n}, and the transaction time set T is {t1, t2, t3,..., t N}.

[0068] Furthermore, determine a network transaction snapshot set according to the blockchain transaction network; determine the dynamic transaction flow perception graph as shown in Figure 3 through a hidden Markov model according to the network transaction snapshot set, and then determine a hidden state set and an observable state set according to the dynamic transaction flow perception graph. Among them, the hidden state set at any moment is represented as N c is the number of states. As the network changes, the at each moment in the network can be defined as the hidden state sequence of the hidden Markov model. The observable state set at any moment is represented as Q k =(v k , e k , d k ), 1≤k≤M O , that is, the node information at time t, v k is the node, e k is the edge set of the node v k , dk For node v k the node degree, M O is the number of observable nodes. As the network changes, the observable state sequence of the hidden Markov model can be defined at each moment in the network

[0069] In some alternative embodiments, the present application utilizes the unique properties of the blockchain (such as anonymity and immutability) to eliminate security threats from untrusted third parties. At the same time, based on the concept of smart contracts in the blockchain, as long as the contract trigger conditions are met, the smart contracts deployed in the blockchain will be automatically executed to help the sensing task initiator and the service provider reach an agreement.

[0070] In some alternative embodiments, the set of network transaction snapshots corresponding to the blockchain dynamic transaction network is divided into network transaction snapshots at different moments by using a time interval. To fully capture the transaction changes in the network, the time interval can be dynamically adjusted as the network changes. Since the transaction network structures at adjacent moments affect each other, combining the snapshot GS at time t + 1 (t+1) is only related to the snapshot GS at the previous moment t (t) this characteristic, the community relationship in the blockchain transaction network can be represented by a first-order Markov chain on the time axis. Further, since the hidden state set (dynamic community structure) in the blockchain transaction network cannot be directly observed, by introducing HMM, we describe the dynamic community structure in the blockchain transaction network as a state chain in HMM according to the moment evolution order; and describe the node association information (including nodes, edges, and node degrees) included in the blockchain transaction network as an observation chain.

[0071] In some alternative embodiments, the blockchain network is dynamically sharded from bottom to top through a sharding model. In determining the dynamic sharding result, first, a terminal in the blockchain network is regarded as a node, the connection between terminals is regarded as a transaction between nodes, and the time of the transaction between terminals is recorded. Among them, as Figure 3 shown in the dynamic transaction flow perception graph, the vertices represent the participating Internet of Things devices, and the edges represent the transaction flows between the devices.

[0072] In some alternative embodiments, for the initial snapshot GS (1) the state probability distribution of the participating nodes can be considered random, that is, the mapping relationship between the participating nodes and the community is random. Therefore, it can be assumed that the state probability at the initial moment is π = P init .

[0073] In some alternative embodiments, a sharding model is determined through a hidden Markov model, so as to process the set of network transaction snapshots GS T ={GS(1) , GS (2) ,..., GS (t) ,..., GS (T)} is sliced, including: (1) According to the dynamic transaction flow perception graph, determine the observable state sequence of the blockchain network at any moment; According to the dynamic transaction flow perception graph, determine the relationship matrix between nodes and communities and the central node at any moment; According to the central node, calculate the cosine similarity between any node and the central node, and determine the state transition probability matrix according to the cosine similarity; According to the dynamic transaction flow perception graph, determine the state observation probability matrix; According to the state transition probability matrix, the state observation probability matrix and the set of observable states, determine the slicing result through the Viterbi algorithm; (2)

[0074] In some alternative embodiments, the Hidden Markov Model (HMM) is a statistical model that describes a Markov process with hidden unknown parameters. The difficulty lies in determining the hidden parameters of the process from the observable parameters. Then these parameters are used for further analysis. In the Hidden Markov Model, the state of a person, object, or weather cannot be directly observed, but can be observed through an observation vector sequence. Each observation vector is represented by various states through certain probability density distributions, and each observation vector is generated by a state sequence with a corresponding probability density distribution. For example, if we want to determine the environmental humidity but do not have a testing instrument, we can infer the weather state through the state of seaweed. The states of seaweed are four, namely Dry (dry), Dryish (slightly dry), Damp (humid), and Soggy (wet). Among them, the state of seaweed is observable, so seaweed is the observation state, and the environmental humidity information that cannot be seen is the hidden state.

[0075] Furthermore, according to the dynamic transaction flow perception graph, determining the observable state sequence of the blockchain network at any moment specifically includes: According to the dynamic transaction flow perception graph, determine the community relationship at any moment through a Markov chain; According to the community relationship at any moment, determine the observable state sequence. Specifically: at time t (2 ≤ t ≤ T), for snapshots GS at different times (t) Construct the relationship matrix NC between nodes and communities i,j (t) = [nc i,j , where:

[0076]

[0077] In some alternative embodiments, furthermore, by calculating the node degree (which can be observed from the blockchain network), obtain the snapshot GS (t)The central node of each community (i.e., the cluster center), and calculate based on the network transaction snapshot and the cluster center at any moment. For example, at moment t, then determine the state transition probability matrix, where the state transition probability matrix is as follows. First, determine the cosine similarity between the cluster center and the network transaction snapshot at time t through the formula shown below:

[0078]

[0079] Where is the cosine similarity at time t, t can represent any moment, i = 1, 2, 3,..., N, c i is device i;

[0080] Then, further, based on the cosine similarity, obtain the state transition probability a i of each node x i,j ∈V in the blockchain network at time t through the formula shown below, and construct the matrix A = [a i,j :

[0081]

[0082] Where is the cosine similarity, c j is device j.

[0083] In some alternative embodiments, in order to calculate the observation probability, we introduce the membership function (MembershipFunction) Mem(x i , C), and judge the probability that the node x i in the adjacency matrix R of the blockchain network belongs to a certain community through the membership function. The following takes the community C as an example to calculate the membership function:

[0084] Where R is the adjacency matrix, i and j are the two nodes generating transactions, Sum(R) is the sum of several elements of the adjacency matrix, r ik is the element in the i-th row and k-th column, r kj is the element in the k-th row and j-th column;

[0085] Furthermore, based on the membership function, obtain the state observation probability of each node x i ∈V in the blockchain network at the current moment, and construct the matrix B = [b i (j)]:

[0086]

[0087] Where Mem(x j , Ci ) is the probability that node x in the adjacency matrix j belongs to community C i , where C k is community k, and Mem(x j , C k ) is the probability that node x in the adjacency matrix j belongs to community C k .

[0088] In some alternative embodiments, an observable state set and an initial state probability distribution are obtained. According to the state transition probability matrix, the state observation probability matrix, the initial state probability distribution, and the observable state set, the optimal community structure of the blockchain network at time t is determined by the Viterbi algorithm, and the blockchain nodes are allocated using this structure to form shards. Among them, the Viterbi algorithm is a dynamic programming algorithm for finding the "Viterbi path" - the hidden state sequence that is most likely to generate the observed event sequence, especially applicable in the context of Markov information sources and hidden Markov models, and is also known as "Viterbi analysis".

[0089] In some alternative embodiments, to determine the initial state probability distribution, the state probability at the initial moment needs to be determined first. Specifically: First, the model state is initialized, that is, it is assumed that the transaction snapshot at time t = 1 is GS (1) The set of participating nodes is {x1, x2,..., x N}, and to obtain the initial community structure the static community discovery algorithm can be used for the snapshot GS (1) . In addition, for the initial snapshot GS (1) , the state probability distribution of the participating nodes can be considered random, that is, the mapping relationship between the participating nodes and the communities is random. Therefore, the state probability at the initial moment can be determined as π = P init . Further, the initial state probability distribution Π is determined according to the state probability at the initial moment, Π = [π i N , where π i = Pr[q (1) = C i , and ∑ 1≤i≤N π i = 1.

[0090] ​In some alternative embodiments, as the blockchain transaction network operates, intra-shard transactions will strengthen the connection between nodes within the community, making the sharding structure clearer; on the contrary, inter-shard transactions will blur the sharding structure. Therefore, in order to consider the state changes in the network at a finer granularity, we allow the sharding adjustment interval to vary dynamically, thus achieving adaptive incremental updates of sharding. Different from traditional sharding mechanisms that use epochs as the sharding interval, we introduce the modularity Q calculation formula shown below. According to the sharding interval, the sharding structure is determined; wherein, the sharding structure includes a main shard and sub-shards;

[0091]

[0092] Wherein, is the total number of edges in the transaction snapshot GS (t) in the total number of edges, is the number of edges within the community, is the community C i the sum of the node degrees within; the modularity Q is a parameter for evaluating the sharding quality, serving as a benchmark (i.e., Q ≤ 0.6), to dynamically adjust the number of shards and optimize the sharding structure.

[0093] It should be noted that the modularity Q is used to measure the tightness of sharding, and its value generally ranges between 0 and 1. The larger the Q value, that is, the closer it is to 0, the better the sharding is divided and the tighter the sharding is.

[0094] In some alternative embodiments, different from traditional complex networks, due to the characteristics of the blockchain, the blockchain is not static, and there are always dynamic changes in the blockchain network. Among them, the dynamic changes in the blockchain network mainly include the addition of new nodes, the generation of new transactions, and the departure of nodes, and calculations are performed separately according to the three situations. By calculating the modularity of the t-time snapshot and determining that the value is within a preset modularity interval, the blockchain sharding can be finely adjusted dynamically (mainly including shard merging, shard splitting, and node adjustment), and each adjustment is incrementally updated on the basis of the previous sharding structure, and the calculation cost is much lower than the calculation cost of complete sharding reconstruction.

[0095] Optionally, as Figure 4 shown, when the dynamic change is the addition of a new node, first determine whether the newly added node u generates transactions with other nodes. If u does not generate transactions, a community containing only u will be created, and the structures of other communities will not change. When u generates transactions, the membership degrees of u with respect to each community can be calculated to assign the node u to the corresponding community.

[0096] Optionally, as Figure 4As shown, when the dynamic change is the generation of a new transaction, there is a new edge e=(u, v) connecting two existing nodes (i.e., the newly generated transaction). When it is determined that a new edge is generated, it is further determined whether the newly generated transaction is an intra-shard transaction (completely within the community) or an inter-shard transaction. If e is an intra-shard transaction, it helps to strengthen the sharding structure, so the current network structure remains unchanged; if e is u an inter-shard transaction with v C, then it is necessary to connect two communities u C and v C. By calculating the similarity between the nodes and the central nodes of shards u C and v C, as well as the membership degree of the nodes to shards u C and v C, the nodes are adjusted accordingly.

[0097] Optionally, as Figure 4 shown, when the dynamic change is a node leaving, that is, the community node u leaves the community at time t, then all the edges associated with it will be removed from the graph. Further, the node leaving can be divided into two cases: (1) a single-degree node leaves, and when a single-degree node leaves, the community remains unchanged and the sharding structure does not need to be changed; (2) a high-degree node leaves, then the current community structure may be disconnected or even split. By calculating the similarity and membership degree, the remaining part of the community structure can be identified, and the community split or merger can be completed, and finally the adjustment of the sharding structure can be realized.

[0098] As can be seen from the above, the blockchain dynamic sharding method and related devices provided by the present application include: determining a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices; according to the blockchain network, determining a dynamic transaction flow perception graph; according to the dynamic transaction flow perception graph, performing bottom-up dynamic sharding on the blockchain network through a sharding model to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine the sharding structure. The present application uses a "bottom-up" sharding mechanism through a dynamic sharding mechanism to replace the "top-down" sharding mechanism, and combines a dynamically evolving blockchain transaction network to achieve adaptive dynamic update of sharding, avoiding a large number of cross-shard transactions generated due to ignoring the dynamic set characteristics between nodes during the sharding process, reducing the system load and time overhead of node cross-shard transaction processing in the blockchain network, and improving the performance of the system compared with the traditional blockchain sharding mechanism.

[0099] It should be noted that the method of the embodiment of the present application can be executed by a single device, such as a computer or a server. The method of this embodiment can also be applied to a distributed scenario and completed by multiple devices cooperating with each other. In such a distributed scenario, one of the multiple devices can only execute one or more steps of the method of the embodiment of the present application, and these multiple devices will interact with each other to complete the described method.

[0100] It should be noted that some embodiments of the present application have been described above. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims can be performed in a different order than in the above embodiments and still achieve the desired result. Additionally, the processes depicted in the drawings do not necessarily require the particular order or sequential order shown to achieve the desired result. In certain embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0101] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application also provides a blockchain dynamic sharding device based on Hidden Markov.

[0102] Referring to Figure 5 , the blockchain dynamic sharding device based on Hidden Markov includes:

[0103] A first determination module 502, configured to determine a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices;

[0104] A second determination module 504, configured to determine a dynamic transaction flow perception map according to the blockchain network;

[0105] A sharding module 506, configured to perform bottom-up dynamic sharding on the blockchain network according to the dynamic transaction flow perception map through a sharding model, and determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure.

[0106] In some embodiments, the second determination module 504 includes:

[0107] Determine the nodes in the blockchain, the transaction behaviors between the nodes, and the transaction time of the transaction behaviors, and determine a blockchain transaction network according to the nodes, the transaction behaviors between the nodes, and the transaction time;

[0108] Determine the dynamic transaction flow perception map according to the blockchain transaction network through a Hidden Markov model.

[0109] In some embodiments, the second determination module 504 includes:

[0110] Determine a network transaction snapshot set according to the blockchain transaction network;

[0111] Determine the dynamic transaction flow perception graph according to the network transaction snapshot set through a hidden Markov model.

[0112] In some embodiments, the second determination module 504 further includes:

[0113] Determine the transaction behavior relationship at any moment in the blockchain network, and determine the network transaction snapshot at any moment according to the transaction behavior relationship at any moment;

[0114] Determine the network transaction snapshot set according to the network transaction snapshot at any moment.

[0115] In some embodiments, the sharding model in the sharding module 506 is a hidden Markov model;

[0116] The self-bottom-up dynamic sharding of the blockchain network through the sharding model according to the dynamic transaction flow perception graph to determine the dynamic sharding result includes:

[0117] Determine the observable state sequence at any moment in the blockchain network according to the dynamic transaction flow perception graph;

[0118] Determine the relationship matrix between nodes and communities and the central node at any moment according to the dynamic transaction flow perception graph;

[0119] Calculate the cosine similarity between any node and the central node according to the central node, and determine the state transition probability matrix according to the cosine similarity;

[0120] Determine the state observation probability matrix according to the dynamic transaction flow perception graph;

[0121] Determine the sharding result through the Viterbi algorithm according to the state transition probability matrix, the state observation probability matrix, and the observable state set.

[0122] In some embodiments, the sharding module 506 includes:

[0123] Determine the community relationship at any moment through a Markov chain according to the dynamic transaction flow perception graph;

[0124] Determine the observable state sequence according to the community relationship at any moment.

[0125] In some embodiments, the sharding module 506 further includes:

[0126] Determine the sharding interval of the sharding according to the following modularity calculation formula according to the dynamic sharding result;

[0127]

[0128] Among them, is the transaction snapshot GS (t) in the total number of edges, is the number of edges within the community, is the community C i the sum of the node degrees within;

[0129] Determine the sharding structure according to the sharding interval; wherein, the sharding structure includes a main shard and sub-shards.

[0130] In some embodiments, the sharding module 506 further includes:

[0131] Determine the type of change in the blockchain network, and dynamically update the sharding structure according to the type of change;

[0132] In response to determining that the type of change is the addition of a new node, determine the membership degree of the new node to any community, and dynamically update the sharding structure according to the membership degree;

[0133] In response to determining that the type of change is the generation of a new transaction, determine the edges of the new transaction, and update the sharding structure according to the edges of the new transaction;

[0134] In response to determining that the type of change is node reduction, determine the type of the reduced node, and update the sharding structure according to the type of the reduced node.

[0135] For the convenience of description, when describing the above device, it is divided into various modules according to functions and described separately. Of course, when implementing the present application, the functions of each module can be implemented in the same or multiple software and / or hardware.

[0136] The device of the above embodiment is used to implement the corresponding blockchain dynamic sharding method based on Hidden Markov in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0137] Based on the same inventive concept, corresponding to the method of any of the above embodiments, the present application further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and the processor implements the blockchain dynamic sharding method based on Hidden Markov described in any of the above embodiments when executing the program.

[0138] Figure 6Fig. shows a more specific schematic diagram of the hardware structure of the electronic device provided in this embodiment. The device may include: a processor 1010, a memory 1020, an input / output interface 1030, a communication interface 1040, and a bus 1050. Among them, the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040 are communicatively connected to each other inside the device through the bus 1050.

[0139] The processor 1010 may be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, etc., and is used to execute relevant programs to implement the technical solutions provided in the embodiments of this specification.

[0140] The memory 1020 may be implemented in the form of a ROM (Read Only Memory), a RAM (Random Access Memory), a static storage device, a dynamic storage device, etc. The memory 1020 may store an operating system and other application programs. When implementing the technical solutions provided in the embodiments of this specification through software or firmware, the relevant program codes are stored in the memory 1020 and are called and executed by the processor 1010.

[0141] The input / output interface 1030 is used to connect to an input / output module to implement information input and output. The input / output module may be configured as a component in the device (not shown in the figure) or externally connected to the device to provide corresponding functions. Among them, the input device may include a keyboard, a mouse, a touch screen, a microphone, various sensors, etc., and the output device may include a display, a speaker, a vibrator, an indicator light, etc.

[0142] The communication interface 1040 is used to connect to a communication module (not shown in the figure) to implement communication interaction between this device and other devices. Among them, the communication module may implement communication in a wired manner (such as USB, network cable, etc.) or in a wireless manner (such as mobile network, WIFI, Bluetooth, etc.).

[0143] The bus 1050 includes a path for transmitting information between various components of the device (such as the processor 1010, the memory 1020, the input / output interface 1030, and the communication interface 1040).

[0144] It should be noted that although the above device only shows the processor 1010, the memory 1020, the input / output interface 1030, the communication interface 1040, and the bus 1050, in the specific implementation process, the device may also include other components necessary for normal operation. In addition, those skilled in the art can understand that the above device may also only include the components necessary to implement the solution of the embodiments of the present specification, and does not necessarily include all the components shown in the figure.

[0145] The electronic device of the above embodiment is used to implement the corresponding Hidden Markov-based blockchain dynamic sharding method in any of the foregoing embodiments, and has the beneficial effects of the corresponding method embodiments, which will not be elaborated here.

[0146] Those of ordinary skill in the art should understand that: the discussion of any of the above embodiments is only exemplary, and is not intended to imply that the scope of the present application (including the claims) is limited to these examples; under the concept of the present application, the technical features in the above embodiments or different embodiments can also be combined, the steps can be implemented in any order, and there are many other variations in different aspects of the embodiments of the present application as described above, and they are not provided in detail for the sake of brevity.

[0147] In addition, for simplicity of description and discussion, and in order not to make the embodiments of the present application difficult to understand, the well-known power / ground connections to integrated circuit (IC) chips and other components may or may not be shown in the provided drawings. Moreover, the device may be shown in block diagram form to avoid making the embodiments of the present application difficult to understand, and this also takes into account the fact that the details of the implementation of these block diagram devices are highly dependent on the platform on which the embodiments of the present application will be implemented (that is, these details should be fully within the understanding of those skilled in the art). In the case where specific details (such as circuits) are set forth to describe the exemplary embodiments of the present application, it will be apparent to those skilled in the art that the embodiments of the present application can be implemented without these specific details or with variations of these specific details. Therefore, these descriptions should be considered illustrative rather than restrictive.

[0148] Although the present application has been described in conjunction with specific embodiments of the present application, many substitutions, modifications, and variations of these embodiments will be apparent to those of ordinary skill in the art based on the foregoing description. For example, other memory architectures (such as dynamic RAM (DRAM)) may be used in the discussed embodiments.

[0149] Embodiments of the present application are intended to cover all such substitutions, modifications, and variations that fall within the broad scope of the appended claims. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present application shall be included within the protection scope of the present application.

Claims

1. A blockchain dynamic sharding method based on Hidden Markov, characterized in that, Including: Determine a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices; Determine a dynamic transaction flow perception map according to the blockchain network; According to the dynamic transaction flow perception map, perform bottom-up dynamic sharding on the blockchain network through a sharding model to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure, and the sharding model is a hidden Markov model; The step of performing bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception map to determine a dynamic sharding result includes: Determine an observable state sequence of the blockchain network at any moment according to the dynamic transaction flow perception map; including: Determine the community relationship at any moment through a Markov chain according to the dynamic transaction flow perception map; Determine the observable state sequence according to the community relationship at any moment; Determine the relationship matrix between nodes and communities and central nodes at any moment according to the dynamic transaction flow perception map; Calculate the cosine similarity between any node and the central node according to the central node, and determine a state transition probability matrix according to the cosine similarity; Determine a state observation probability matrix according to the dynamic transaction flow perception map; Determine the sharding result through the Viterbi algorithm according to the state transition probability matrix, the state observation probability matrix, and the set of observable states; Determine the sharding interval of the sharding according to the following modularity calculation formula according to the dynamic sharding result; Among them, is the trading snapshot GS (t) in the total number of edges, e C i is the number of edges within the community, is the community C i the sum of the node degrees within; Determine the sharding structure according to the sharding interval; wherein, the sharding structure includes a main shard and sub-shards.

2. The method according to claim 1, wherein The step of determining a dynamic transaction flow perception map according to the blockchain network includes: Determine the nodes in the blockchain, the transaction behaviors between the nodes, and the transaction time of the transaction behaviors. According to the nodes, the transaction behaviors between the nodes, and the transaction time, determine a blockchain transaction network; Determine the dynamic transaction flow perception map through a hidden Markov model according to the blockchain transaction network.

3. The method according to claim 2, wherein The step of determining the dynamic transaction flow perception map through a hidden Markov model according to the blockchain transaction network includes: Determine a network transaction snapshot set according to the blockchain transaction network; Determine the dynamic transaction flow perception map through a hidden Markov model according to the network transaction snapshot set.

4. The method according to claim 3, wherein The step of determining a network transaction snapshot set according to the blockchain transaction network includes: Determine the transaction behavior relationship at any moment of the blockchain network, and determine the network transaction snapshot at any moment according to the transaction behavior relationship at any moment; Determine the network transaction snapshot set according to the network transaction snapshot at any moment.

5. The method according to claim 1, wherein The method includes: Determine the change type in the blockchain network, and dynamically update the sharding structure according to the change type; In response to determining that the change type is adding a new node, determine the membership degree of the new node to any community, and dynamically update the sharding structure according to the membership degree; In response to determining that the change type is the generation of a new transaction, determine the edges of the new transaction, and update the sharding structure according to the edges of the new transaction; In response to determining that the change type is node reduction, determine the type of the reduced node, and update the sharding structure according to the type of the reduced node.

6. A blockchain dynamic sharding device based on Hidden Markov, characterized in that, Comprising: A first determination module configured to determine a blockchain network; wherein, the blockchain network includes: the Internet of Things and Internet of Things devices; A second determination module configured to determine a dynamic transaction flow perception map according to the blockchain network; A sharding module configured to perform bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception map to determine a dynamic sharding result; wherein, the dynamic sharding result is used to determine a sharding structure, and the sharding model is a hidden Markov model; The performing bottom-up dynamic sharding on the blockchain network through a sharding model according to the dynamic transaction flow perception map to determine a dynamic sharding result includes: Determining an observable state sequence of the blockchain network at any moment according to the dynamic transaction flow perception map; including: Determining the community relationship at any moment through a Markov chain according to the dynamic transaction flow perception map; Determining the observable state sequence according to the community relationship at any moment; Determining a relationship matrix between nodes and communities and central nodes at any moment according to the dynamic transaction flow perception map; Calculating the cosine similarity between any node and the central node according to the central node, and determining a state transition probability matrix according to the cosine similarity; Determining a state observation probability matrix according to the dynamic transaction flow perception map; Determining the sharding result through the Viterbi algorithm according to the state transition probability matrix, the state observation probability matrix, and the set of observable states; Determining the sharding interval of the sharding according to the following modularity calculation formula according to the dynamic sharding result; Among them, is the trading snapshot GS (t) in the total number of edges, e C i is the number of edges within the community, is the community C i the sum of the node degrees within; Determining the sharding structure according to the sharding interval; wherein, the sharding structure includes a main shard and sub-shards.

7. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable by the processor, wherein the processor implements the method according to any one of claims 1 to 5 when executing the computer program.