A blockchain sharding method, device, electronic equipment and storage medium
By dividing the blockchain into directory committee nodes and non-directory committee nodes, and utilizing the sharding model of Markov decision processes, the problem of insufficient transaction processing per second in blockchain sharding technology is solved, thereby improving system performance.
Patent Information
- Application Number
- CN202310544808.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-16
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2043-05-16
AI Technical Summary
Existing blockchain sharding technology struggles to increase the number of transactions processed per second, resulting in insufficient system performance.
By determining the time it takes for nodes in the blockchain to solve workload problems, nodes are divided into directory committee nodes and non-directory committee nodes. The non-directory committee nodes are then input into a pre-trained sharding model based on Markov decision processes for sharding, thereby increasing the number of transactions processed per second by the blockchain.
This increased the number of transactions per second that the blockchain system could process, thus improving system performance.
Smart Images

Figure CN118410040B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a blockchain sharding method, apparatus, electronic device, and storage medium. Background Technology
[0002] Blockchain scalability is currently a major bottleneck hindering the widespread adoption of distributed technologies. Sharding technology, as one of the mainstream methods for blockchain scaling, can achieve high-performance on-chain scaling without reducing the degree of decentralization of the blockchain, thereby solving the problems of insufficient blockchain scalability and low throughput.
[0003] However, sharding technology also has significant limitations, such as how to increase the number of transactions per second that a sharded blockchain system can process. Summary of the Invention
[0004] To address the aforementioned technical problems, embodiments of the present invention aim to provide a blockchain sharding method, apparatus, electronic device, and storage medium capable of sharding nodes in a blockchain to increase the number of transactions processed per second and improve system performance.
[0005] The technical solution of this invention is implemented as follows:
[0006] In a first aspect, embodiments of the present invention provide a blockchain sharding method, including:
[0007] Determine the time required for N nodes in a blockchain to solve the same Problem of Work (PoW), where N is a positive integer;
[0008] Based on the time it takes for N nodes to solve the same PoW, the N nodes are divided into directory committee nodes and non-directory committee nodes, where all directory committee nodes together form the directory committee.
[0009] Non-directory committee nodes are input into a pre-trained sharding model to obtain sharding results for non-directory committee nodes. The sharding model is a model trained based on Markov decision processes with the goal of increasing the number of transactions processed per second in the blockchain.
[0010] Optionally, the identity ID of any of the N nodes is represented as: ID = H(EpochRand || IP || PK || Nonce) < D;
[0011] Where EpochRand represents the seed of PoW, D represents the difficulty of the PoW algorithm, and H represents the hash operation.
[0012] Optionally, based on the time it takes for N nodes to solve the same PoW, the N nodes can be divided into directory committee nodes and non-directory committee nodes, including:
[0013] Based on the time taken by N nodes to solve the same PoW, the top C nodes with the shortest time to solve the same PoW are designated as directory committee nodes, and the remaining NC nodes are designated as non-directory committee nodes, where C is a positive integer and C < N.
[0014] Optionally, the sharding result includes K shards. K is a positive integer.
[0015] Optionally, the state space of the piecewise model at time t is: ;
[0016] The behavior space of the piecewise model at time t is: ;
[0017] The reward function of the slice model at time t is: , ;
[0018] in, The set of transmission rates between nodes. Represents a node and nodes The transmission speed of the link between them; This refers to the set of computing capabilities of a node. Represents a blockchain node Computing resources; For the consensus history of nodes, it represents the voting choices made by nodes when verifying blocks; when When this happens, it means the block has not been approved by the node. Verification; when When, it indicates that the block has passed through the node. The verification can be uploaded to the blockchain; the probability of a malicious node in the blockchain is denoted as... , It is calculated based on historical consensus.
[0019] The size of the block header; The average size of the transactions; Indicates the size of the transaction processed in each block; This indicates the number of transactions processed by each shard; express The total number of transactions processed by each partition; The time for block generation. This represents the number of transactions processed by the blockchain per second, i.e., the transaction throughput.
[0020] Optional methods for training the slice model include:
[0021] Step 1: Initialize two neural networks, one of which is a policy network with the same structure as the DDPG neural network. Value networks with the same structure as DQN neural networks The weight parameters of the two networks are respectively and ;
[0022] Step 2: Initialize the target network of the policy network and the target network of the value network. The target network of the sum value network The weight parameters of the two networks are respectively and ;
[0023] Step 3: Initialization Strategy exploration rate Experience replay pool It is used to store experience samples generated by the interaction between the agent and the blockchain environment, which are used to train the neural network;
[0024] Step 4: Learn Steps This is used to periodically update the parameters of the neural network;
[0025] Step 5: Observe the current situation from the blockchain environment state of time ;
[0026] Step 6: Set the status The input is fed into the policy network, which outputs the continuous behavior parameters corresponding to each possible discrete behavior. and ;
[0027] Step 7: Input the state and continuous behavior parameters into the value network, and output the optional behaviors. Value, based on Value selection optimal discrete behavior and its continuous behavior;
[0028] Step 8: According to The strategy obtains the behavior of blockchain sharding ;
[0029] Step 9: Obtain the behavior The input is given to the blockchain environment, which then performs a state transition to obtain the next state. and rewards ;
[0030] Step 10: Convert the state transition tuple Store in experience pool ;
[0031] Step 11: Randomly sample from the experience pool Each state transition tuple updates the neural network parameters.
[0032] Optional, also includes:
[0033] Approximation using neural networks The function, in which the neural network consists of two parts: a policy network and a value network, Parameterized policy networks will store system states As input, output and That is, for specific discrete actions The optimal continuous action; Parameterized value networks will store the system state. , and As input, output Policy networks and value networks are parameterized through depth. The network blockchain sharding algorithm is trained.
[0034] Secondly, embodiments of the present invention provide a blockchain sharding device, comprising: a determining module, a dividing module, and a sharding module;
[0035] The determination module is used to determine the time required for N nodes in the blockchain to solve the same PoW (Problem of Work) challenge, where N is a positive integer.
[0036] The partitioning module is used to divide N nodes into directory committee nodes and non-directory committee nodes based on the time it takes for N nodes to solve the same PoW. All directory committee nodes together form the directory committee.
[0037] The sharding module is used to input non-directory committee nodes into a pre-trained sharding model to obtain sharding results for non-directory committee nodes. The sharding model is a model trained based on Markov decision processes with the goal of increasing the number of transactions processed per second in the blockchain.
[0038] Thirdly, embodiments of the present invention provide an electronic device, including: a processor, the processor being configured to implement a blockchain sharding method having any of the features described in the first aspect when executing a computer program.
[0039] Fourthly, embodiments of the present invention also provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a blockchain sharding method having any of the features of the first aspect described above.
[0040] This invention provides a blockchain sharding method, apparatus, electronic device, and storage medium. By determining the time it takes for N nodes in the blockchain to solve the same Proof-of-Work (PoW), the N nodes are divided into directory committee nodes and non-directory committee nodes. The non-directory committee nodes are then input into a pre-trained sharding model to obtain the sharding results for the non-directory committee nodes. This allows for sharding of nodes in the blockchain, increasing the number of transactions processed per second and improving system performance. Attached Figure Description
[0041] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0042] Figure 1 A schematic flowchart of a blockchain sharding method provided in an embodiment of the present invention;
[0043] Figure 2 This is a schematic diagram of a blockchain sharding process provided in an embodiment of the present invention;
[0044] Figure 3 This is a schematic diagram of a piecewise clustering mechanism provided in an embodiment of the present invention;
[0045] Figure 4 A neural network structure diagram of P-DQN provided in an embodiment of the present invention;
[0046] Figure 5 This is a schematic diagram of the structure of a blockchain sharding device provided in an embodiment of the present invention;
[0047] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present invention. Detailed Implementation
[0048] To enable those skilled in the art to better understand the present invention, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the scope of protection of the present invention.
[0049] Figure 1 This is a flowchart illustrating a blockchain sharding method provided in an embodiment of the present invention. The method disclosed in this embodiment is applicable to blockchain sharding devices. Figure 1 As shown, the method may include the following steps:
[0050] S110. Determine the time required for N nodes in the blockchain to solve the same PoW problem, where N is a positive integer.
[0051] S120. Based on the time taken for N nodes to solve the same PoW, divide the N nodes into directory committee nodes and non-directory committee nodes, where all directory committee nodes together form the directory committee.
[0052] Figure 2 This is a schematic diagram of a blockchain sharding process provided in an embodiment of the present invention. Figure 2 As shown, in a blockchain sharding system, nodes are divided into different shards, and nodes within a shard process transactions in parallel, which can improve system performance. First, N nodes in the blockchain need to solve the same Proof of Work (PoW) problem to obtain their identity (ID). The time required for N nodes to solve the same PoW problem is determined. Then, a certain number of nodes that solve the PoW problem quickly are selected to form a Directory Committee (DC). After selecting the nodes for the Directory Committee, the blockchain nodes are sharded. Based on the node IDs, the nodes in the blockchain are divided into K shards, and transactions are processed in parallel. Nodes within a shard package the transactions into blocks, execute PBFT consensus, and after verification, send them to the Directory Committee. The Directory Committee performs final packaging, creating a final block. After successful verification, it is uploaded to the blockchain, and the final block information is returned to all nodes within the shard, allowing them to update their information.
[0053] Specifically, each node locally selects its own public key (PK) and IP address for later authentication. Nodes in the blockchain network obtain their own ID by solving a simple Proof-of-Work (PoW) problem.
[0054] In one embodiment, the identity ID of any node among N nodes is represented as: ID = H(EpochRand || IP || PK || Nonce) < D; where EpochRand represents the seed for PoW, which needs to be generated at the end of the previous epoch to ensure that PoW has not been pre-computed; D represents the difficulty of the PoW algorithm, which is a predefined parameter in the network that determines how much computing power a node needs to use to solve PoW; H represents the hash operation.
[0055] A sharded blockchain consists of a Directory Committee (DC) and K shards. To share shard information, a Directory Committee is first selected. The nodes in the DC consist of the top C nodes that solve the Proof-of-Work (PoW) problem fastest, with the remaining NC nodes acting as non-Directory Committee nodes. To maintain a similar number of nodes in the DC to the other K shards, the number of nodes in the DC is... K is a positive integer, C is a positive integer, and C < N. Then, the nodes are sharded, and the shard to which a node is assigned is determined by the last L bits of its ID. For example, if L = 3, the last 3 bits of the ID represent the shard number, and the number of shards is 2. L =2 3 =8. All nodes need to send their information, namely PK, EpochRand, nonce, and ID, to the DC. After collecting all the information, the nodes in the DC broadcast it throughout the network, so that the entire network can obtain the fragmentation information. After each node knows its own fragment number, nodes within the same fragment establish point-to-point connections. Figure 3 This is a schematic diagram of a piecewise clustering mechanism provided in an embodiment of the present invention.
[0056] S130. Input the non-directory committee nodes into the pre-trained sharding model to obtain the sharding results of the non-directory committee nodes. The sharding model is a model trained based on the Markov decision process with the goal of increasing the number of transactions processed per second in the blockchain.
[0057] Specifically, blockchain node shard selection is a sequential decision-making process. The blockchain shard selection problem is modeled as a Markov decision process; that is, based on the Markov decision process, the sharding model is trained with the goal of increasing the number of transactions processed per second by the blockchain. The state space, behavior space, and reward function of the sharding model are shown below.
[0058] State Space: The state space of a blockchain environment consists of four vectors: the transmission rate between nodes, the computing power of nodes, the consensus history of nodes, and the probability of a malicious node in the blockchain. Therefore, the state space at time t is defined as: ;
[0059] in, The set of transmission rates between nodes. Represents a node and nodes The transmission speed of the link between them; This refers to the set of computing capabilities of a node. Represents a blockchain node Computing resources; For the consensus history of nodes, it represents the voting choices made by nodes when verifying blocks; when When this happens, it means the block has not been approved by the node. Verification; when When, it indicates that the block has passed through the node. The verification can be uploaded to the blockchain; the probability of a malicious node in the blockchain is denoted as... , It is calculated based on consensus history.
[0060] Behavior Space: The behavior space of a blockchain environment consists of three vectors: the number of blockchain shards, the block size, and the block time. Therefore, the behavior space is defined as follows: .
[0061] Reward Function: The reward represents the gain obtained by taking an action in the current state. The optimization goal of this paper is to increase the number of transactions processed per second by the blockchain. Therefore, the reward function is defined as follows: ;
[0062] in, The size of the block header; The average size of the transactions; Indicates the size of the transaction processed in each block; This indicates the number of transactions processed by each shard; express The total number of transactions processed by each partition; The time for block generation. This represents the number of transactions processed by the blockchain per second, i.e., the transaction throughput.
[0063] To ensure that malicious nodes within a shard cannot threaten the security of the entire shard after the blockchain nodes are sharded, and to prevent blocks generated by malicious nodes from being uploaded to the blockchain, while also satisfying the blockchain's finality property, the delay should be completed within several consecutive block intervals (u). Constraints In summary: .
[0064] In one embodiment, the block size and block interval of the blockchain sharding problem behavior space can be regarded as continuous decision variables, constructing a hybrid behavior space Markov decision process to further reduce the discrete behavior space. Most existing deep reinforcement learning algorithms only consider discrete action spaces or continuous behavior spaces. For processing hybrid behavior spaces, previous methods discretize continuous behaviors to approximate the discrete behavior space, or relax discrete behaviors into continuous sets to obtain the continuous behavior space. For the hybrid behavior space problem, this invention uses the Parametrized Deep Q-network (P-DQN) framework for solving it. The P-DQN algorithm combines the DQN (Deep Q network) algorithm for handling discrete behaviors and the DDPG (Deep Deterministic Policy Gradient) algorithm for handling continuous behaviors, seamlessly integrating the two algorithmic frameworks.
[0065] This invention applies the deep reinforcement learning P-DQN algorithm to blockchain sharding systems, proposing a sharding-based parameterized deep Q-network (P-DQNBS) algorithm. The advantage of the P-DQNBS algorithm over the BDQBS algorithm is that it solves the problem of a mixed discrete-continuous behavior space, providing more accurate behavior for blockchain sharding networks.
[0066] Table 1 P-DQN Algorithm
[0067] Methods for training slice models include:
[0068] Step 1: Initialize two neural networks, one of which is a policy network with the same structure as the DDPG neural network. Value networks with the same structure as DQN neural networks The weight parameters of the two networks are respectively and ;
[0069] Step 2: Initialize the target network of the policy network The target network of the sum value network The weight parameters of the two networks are respectively and ;
[0070] Step 3: Initialization Strategy exploration rate Experience replay pool It is used to store experience samples generated by the interaction between the agent and the blockchain environment, which are used to train the neural network;
[0071] Step 4: Learn Steps This is used to periodically update the parameters of the neural network;
[0072] Step 5: Observe the current situation from the blockchain environment state of time ;
[0073] Step 6: Set the status The input is fed into the policy network, which outputs the continuous behavior parameters corresponding to each possible discrete behavior. and ;
[0074] Step 7: Input the state and continuous behavior parameters into the value network, and output the optional behaviors. Value, based on Value selection optimal discrete behavior and its continuous behavior;
[0075] Step 8: According to The strategy obtains the behavior of blockchain sharding ;
[0076] Step 9: Obtain the behavior The input is given to the blockchain environment, which then performs a state transition to obtain the next state. and rewards ;
[0077] Step 10: Convert the state transition tuple Store in experience pool ;
[0078] Step 11: Randomly sample from the experience pool Each state transition tuple updates the neural network parameters.
[0079] Figure 4 This is a neural network structure diagram of P-DQN provided in an embodiment of the present invention. To improve the scalability of the algorithm, the present invention also uses... Figure 4 The neural network shown approximates the Q-function, and consists of two parts: a policy network and a value network. Parameterized policy networks will store system states As input, output and That is, for specific discrete actions The optimal continuous action; Parameterized value networks will store the system state. , and As input, output Policy networks and value networks are parameterized through depth. The network blockchain sharding (P-DQNBS) algorithm is used for training.
[0080] Algorithm 1 shows the detailed steps of the P-DQNBS algorithm. At each time step... The algorithm first bases itself on the current state. For each discrete behavior Calculate optimal continuous behavior and (Step 5), and then select the optimal one using formula (1). : Formula (1)
[0081] And to obtain optimal behavior Then according to The strategy selects one action to execute. Formula (2)
[0082] Get the next state And rewards (step 9).
[0083] Formula (3)
[0084] Then state transformation Formed and stored in the experience pool (Step 10) Sample from the experience pool. The experience is used to train the policy network and value network separately (step 11). The policy network is updated by maximizing... The function is therefore the loss function formula is as follows (step 12).
[0085] Formula (4)
[0086] The update goal of the value network is Formula (5)
[0087] And by minimizing the TD error (steps 13-14).
[0088] Formula (6)
[0089] To improve the stability of the P-DQNBS algorithm, the present invention can periodically update the target network (step 15).
[0090] After the sharding model is trained, inputting non-directory committee nodes into the pre-trained sharding model will yield the sharding results for the non-directory committee nodes.
[0091] This invention provides a blockchain sharding method, comprising: determining the time taken for N nodes in the blockchain to solve the same Problem of Work (PoW), where N is a positive integer; dividing the N nodes into directory committee nodes and non-directory committee nodes based on the time taken to solve the same PoW, wherein all directory committee nodes together form a directory committee; and inputting the non-directory committee nodes into a pre-trained sharding model to obtain the sharding results for the non-directory committee nodes. The sharding model is a Markov decision process-based model trained with the goal of increasing the number of transactions processed per second in the blockchain. By determining the time taken for N nodes in the blockchain to solve the same PoW, dividing the N nodes into directory committee nodes and non-directory committee nodes, and then inputting the non-directory committee nodes into a pre-trained sharding model to obtain the sharding results for the non-directory committee nodes, the method can shard the nodes in the blockchain to increase the number of transactions processed per second and improve system performance.
[0092] Figure 5 This is a schematic diagram of a blockchain sharding device provided in an embodiment of the present invention, as shown below. Figure 5 As shown, the blockchain sharding device includes: a determination module 501, a division module 502, and a sharding module 503.
[0093] Module 501 is used to determine the time required for N nodes in the blockchain to solve the same PoW problem, where N is a positive integer.
[0094] The partitioning module 502 is used to divide N nodes into directory committee nodes and non-directory committee nodes based on the time it takes for N nodes to solve the same PoW. All directory committee nodes together form a directory committee.
[0095] Sharding module 503 is used to input non-directory committee nodes into a pre-trained sharding model to obtain sharding results for non-directory committee nodes. The sharding model is a model trained based on Markov decision process with the goal of increasing the number of transactions processed per second in the blockchain.
[0096] This invention also provides an electronic device, including: a processor, which is configured to implement a method having any of the features described in the above embodiments when executing a computer program.
[0097] Figure 6A schematic diagram of an electronic device 10, which can be used to implement embodiments of the present invention, is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processors, cellular phones, smartphones, wearable devices (e.g., helmets, glasses, watches, etc.), and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely illustrative and are not intended to limit the implementation of the invention described and / or claimed herein.
[0098] like Figure 6 As shown, the electronic device 10 includes at least one processor 11 and a memory, such as a read-only memory (ROM) 12 or a random access memory (RAM) 13, communicatively connected to the at least one processor 11. The memory stores computer programs executable by the at least one processor. The processor 11 can perform various appropriate actions and processes based on the computer program stored in the ROM 12 or loaded from storage unit 18 into the RAM 13. The RAM 13 can also store various programs and data required for the operation of the electronic device 10. The processor 11, ROM 12, and RAM 13 are interconnected via a bus 14. An input / output (I / O) interface 15 is also connected to the bus 14.
[0099] Multiple components in electronic device 10 are connected to I / O interface 15, including: input unit 16, such as keyboard, mouse, etc.; output unit 17, such as various types of displays, speakers, etc.; storage unit 18, such as disk, optical disk, etc.; and communication unit 19, such as network card, modem, wireless transceiver, etc. Communication unit 19 allows electronic device 10 to exchange information / data with other devices through computer networks such as the Internet and / or various telecommunications networks.
[0100] Processor 11 can be a variety of general-purpose and / or special-purpose processing components with processing and computing capabilities. Some examples of processor 11 include, but are not limited to, central processing unit (CPU), graphics processing unit (GPU), various special-purpose artificial intelligence (AI) computing chips, various processors running machine learning model algorithms, digital signal processors (DSPs), and any suitable processor, controller, microcontroller, etc. Processor 11 performs the various methods and processes described above, such as blockchain sharding methods.
[0101] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of hardware embodiments, software embodiments, or embodiments combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage and optical storage) containing computer-usable program code.
[0102] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0103] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0104] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0105] The above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention.
Claims
1. A blockchain sharding method, characterized in that, include: Determine the time required for N nodes in a blockchain to solve the same Problem of Work (PoW), where N is a positive integer; Based on the time it takes for N nodes to solve the same PoW, the N nodes are divided into directory committee nodes and non-directory committee nodes, where all the directory committee nodes together form a directory committee. The non-directory committee node is input into a pre-trained sharding model to obtain the sharding result of the non-directory committee node. The sharding model is a model trained based on Markov decision process with the goal of increasing the number of transactions processed per second in the blockchain. The methods for training the slice model include: Step 1: Initialize two neural networks, one of which is a policy network with the same structure as the DDPG neural network. Value networks with the same structure as DQN neural networks The weight parameters of the two networks are respectively and ; Step 2: Initialize the target network of the policy network The target network of the sum value network The weight parameters of the two networks are respectively and ; Step 3: Initialization Strategy exploration rate Experience replay pool It is used to store experience samples generated by the interaction between the agent and the blockchain environment, which are used to train the neural network; Step 4: Learn Steps This is used to periodically update the parameters of the neural network; Step 5: Observe the current situation from the blockchain environment state of time ; Step 6: Set the status The input is fed into the policy network, which outputs the continuous behavior parameters corresponding to each possible discrete behavior. and ; Step 7: Input the state and continuous behavior parameters into the value network, and output the optional behaviors. Value, based on Value selection optimal discrete behavior and its continuous behavior; Step 8: According to The strategy obtains the behavior of blockchain sharding ; Step 9: Obtain the behavior The input is given to the blockchain environment, which then performs a state transition to obtain the next state. and rewards ; Step 10: Convert the state transition tuple Store in experience pool ; Step 11: Randomly sample from the experience pool Each state transition tuple updates the neural network parameters; Also includes: Approximation using neural networks The function, in which the neural network consists of two parts: a policy network and a value network, Parameterized policy networks will store system states As input, output and That is, for specific discrete actions The optimal continuous action; Parameterized value networks will store the system state. , and As input, output Policy networks and value networks are parameterized through depth. The network blockchain sharding algorithm is trained.
2. The blockchain sharding method according to claim 1, characterized in that, The identity ID of any node among N nodes is represented as: ID = H(EpochRand || IP || PK || Nonce) < D; Where EpochRand represents the seed of PoW, D represents the difficulty of the PoW algorithm, and H represents the hash operation.
3. The blockchain sharding method according to claim 1, characterized in that, Based on the time it takes for N nodes to solve the same PoW, the N nodes are divided into directory committee nodes and non-directory committee nodes, including: Based on the time taken for N nodes to solve the same PoW, the top C nodes with the shortest time to solve the same PoW are designated as the directory committee nodes, and the remaining NC nodes are designated as the non-directory committee nodes, where C is a positive integer and C < N.
4. The blockchain sharding method according to claim 3, characterized in that, The partitioning result includes K partitions. K is a positive integer.
5. The blockchain sharding method according to claim 1, characterized in that, The state space of the piecewise model at time t is: ; The behavior space of the piecewise model at time t is: ; The reward function of the segmented model at time t is: , ; in, The set of transmission rates between nodes. Represents a node and nodes The transmission speed of the link between them; This refers to the set of computing capabilities of a node. Represents a blockchain node Computing resources; For the consensus history of nodes, it represents the voting choices made by nodes when verifying blocks; when When this happens, it means the block has not been approved by the node. Verification; when When, it indicates that the block has passed through the node. The verification can be uploaded to the blockchain; the probability of a malicious node in the blockchain is denoted as... , It is calculated based on historical consensus. The size of the block header; The average size of the transactions; Indicates the size of the transaction processed in each block; This indicates the number of transactions processed by each shard; express The total number of transactions processed by each partition; The time for block generation. This represents the number of transactions processed by the blockchain per second, i.e., the transaction throughput.
6. A blockchain sharding device, characterized in that, The blockchain sharding device is used to execute the blockchain sharding method of claim 1, and specifically includes: a determination module, a partitioning module, and a sharding module; The determining module is used to determine the time it takes for N nodes in the blockchain to solve the same PoW (Problem of Work) problem, where N is a positive integer. The partitioning module is used to divide N nodes into directory committee nodes and non-directory committee nodes based on the time it takes for N nodes to solve the same PoW, wherein all the directory committee nodes together form a directory committee. The sharding module is used to input the non-directory committee nodes into a pre-trained sharding model to obtain the sharding results of the non-directory committee nodes. The sharding model is a model trained based on Markov decision processes with the goal of increasing the number of transactions processed per second in the blockchain.
7. An electronic device, characterized in that, include: A processor configured to implement the blockchain sharding method as described in any one of claims 1-5 when executing a computer program.
8. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the blockchain sharding method as described in any one of claims 1-5.
