Sharded blockchain system performance optimization method based on PSO-GA

By combining particle swarm optimization algorithm and genetic algorithm in the sharded blockchain system to optimize system parameters, the problem of degradation in the performance of traditional blockchain systems is solved, and a higher system throughput TPS is achieved.

CN116644131BActive Publication Date: 2025-05-23FUZHOU UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202310367134.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2025-05-23
Estimated Expiration
2043-04-07

AI Technical Summary

Technical Problem

Traditional blockchain systems have problems such as low transaction throughput, high transaction latency and low scalability. Especially when supporting a large number of users and large-scale IoT networks, the system performance has significantly decreased.

Method used

The performance optimization method of sharded blockchain system based on PSO-GA is adopted, and the parameters of sharded blockchain system are optimized through the combination of particle swarm optimization algorithm and genetic algorithm to improve system throughput.

Benefits of technology

In a shorter algorithm execution time, the system throughput TPS is significantly improved, solving the problem of degradation in traditional blockchain systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116644131B_ABST
    Figure CN116644131B_ABST
Patent Text Reader

Abstract

The present invention provides a performance optimization method for a sharded blockchain system based on PSO-GA, comprising the following steps: step one: problem modeling; transactions come from various application scenarios in an Internet of Things network, and the data therein are shared or processed in different scenarios; transaction data generated in different scenarios share a database through a blockchain system; the blockchain network receives transactions from the Internet of Things network and records the transactions in a blockchain account book; step two: the proposed PSO-GA method; combining a particle swarm algorithm and a genetic algorithm to optimize the parameters of a sharded blockchain system; the application of this technical solution can achieve a higher system throughput TPS with a shorter algorithm execution time.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a performance optimization method for a sharded blockchain system based on PSO-GA. Background Art

[0002] Blockchain can provide transparency and integrity services for data systems, thereby realizing valuable applications in various industries, such as identity management, supply chain, gaming systems, etc. Blockchain technology has attracted the attention of many industries due to its decentralization, anonymity, and immutability. As one of the key technologies of distributed ledgers, it provides a new direction for solving privacy protection issues in digital currency, finance, and the Internet of Things. With the development of the Internet, the continuous increase in data has brought tremendous pressure to all types of data management and network services, triggering concerns about network security, data privacy, and performance degradation.

[0003] However, there are some outstanding problems with traditional blockchain systems: low transaction throughput, high transaction latency, low scalability, etc. Blockchain faces severe problems when used to support a large number of users who are generating very large amounts of data, such as large-scale IoT networks. Due to the complexity of system block verification, large user groups lead to slow transaction processing, and scalability issues arise as the size of the ledger increases and the size of the blockchain increases, making it more difficult to manage the blockchain in a decentralized manner.

[0004] At present, sharded blockchain is a good solution to the above problems. Sharding technology can improve the throughput of blockchain. Since Luu et al. [4] proposed Elastico in 2016 to combine sharding in the database with blockchain, many scholars have started to study sharded blockchain. Papers on sharded blockchain have emerged in an endless stream, and many sharded blockchain systems have also emerged. At present, there is a dynamic optimization method to improve the system throughput of sharded blockchain. The method combines sharding with deep reinforcement learning. Specific research on the performance optimization of sharded blockchain systems includes the Deep Q Network algorithm, which can solve the problem of small action dimensions, but it is difficult to solve when the action is enlarged. Summary of the invention

[0005] In view of this, the purpose of the present invention is to provide a sharded blockchain system performance optimization method based on PSO-GA, which can achieve higher system throughput TPS with shorter algorithm execution time.

[0006] To achieve the above purpose, the present invention adopts the following technical scheme: a sharded blockchain system performance optimization method based on PSO-GA, comprising the following steps: Step 1: problem modeling; transactions come from various application scenarios in the Internet of Things network, and the data therein are shared or processed in different scenarios; transaction data generated in different scenarios are shared in the database through the blockchain system; the blockchain network receives transactions from the Internet of Things network and records the transactions in the blockchain ledger to ensure reliable data storage and management, so that shared data and their logical relationships are stored immutably;

[0007] Step 2: The proposed PSO-GA method; combining particle swarm optimization and genetic algorithm to optimize the parameters of the sharded blockchain system; the particle swarm optimization algorithm further uses swarm intelligence to establish a simplified model through the study of bird flock predation behavior. The model corresponds the optimization problem search space to the flight space of the bird flock, and the individuals are used to represent the feasible solution of the problem. The individuals are abstracted into particles without mass and volume, and the process of the bird flock searching for food corresponds to the process of solving the optimization problem;

[0008] Each particle in the particle swarm algorithm represents a candidate solution to the optimization problem. Given their initial position and initial velocity, the optimal solution to the problem is found through continuous iteration. Each particle moves in the entire problem space at a certain speed and direction and updates its movement. The speed is affected by many factors. The fitness function is introduced to evaluate the quality of each particle's solution. The function determines the quality of the solution generated by the particle within the space. In each iteration, the particle updates its position and flight speed in the solution space by tracking two "extreme values".

[0009] In a preferred embodiment, the step 1 includes establishing a PBFT consensus model; the PBFT consensus model has five phases: a request phase, a pre-preparation phase, a preparation phase, a submission phase, and a reply phase;

[0010] All blockchain verification nodes are assigned to different shards, and the sharding results are as random and decentralized as possible. After the shards are divided, the transaction shards evenly distribute each transaction to the shards and process them through a two-step consensus process, which includes intra-shard consensus and final consensus. All consensus processes are implemented through the PBFT algorithm.

[0011] Before sharding, all nodes participating in the network will form their own ID by solving a PoW problem. The node ID is calculated by a combination of random seeds, public keys, IP addresses, etc. After the ID is calculated, the shard number is determined by the last l bits of the ID. The value of l depends on the number of shards in the sharded blockchain network. Nodes with the same shard number are divided into the same shard.

[0012] 1) Intra-shard consensus: After sharding, each shard receives its own transaction pool; each shard processes transactions independently, creates local blocks and executes the PBFT consensus process within the shard; after the local blocks are trusted by the intra-shard consensus process, they will be sent to the final consensus shard group for final consensus; during this process, all shards are processing transactions in parallel;

[0013] 2) Final consensus: In the final consensus stage, the consensus group receives blocks from different shards from each shard; the master node in the final consensus group merges all blocks in ascending order of shard numbers to generate the final block, and then uses the PBFT consensus algorithm again to achieve the purpose of final consensus;

[0014] The sharded blockchain system supporting the Internet of Things consists of a two-layer structure, namely a network consisting of IoT devices and a sharded blockchain consensus group consisting of N verification devices. Assuming that the sharded blockchain system has K shards, It means that the consensus group composed of verification devices is divided into two layers, the on-chip consensus layer and the final consensus layer. The on-chip consensus layer has K groups, so there are K+1 groups in total in the system. The final consensus layer has nodes, and the number of nodes in each shard in the on-chip consensus layer is Assume that the message verification process includes two operations: signature verification and message authentication code operation, which use θ and α CPU cycles respectively.

[0015] In a preferred embodiment, step 1 includes establishing a delay model; delay refers to the time required for a transaction to enter the blockchain system and eventually be processed and become irreversible; transactions entering the network are automatically assigned to shards through the last l bits of the sender and verified through intra-shard consensus and final consensus processes; the transaction process consists of two steps: 1) block interval; 2) total consensus delay =, the total delay of the transaction It is derived from the following formula:

[0016]

[0017] Where T I is the block interval, For Sharding Total consensus delay of Determined by the on-chip consensus delay and the final consensus delay, it is derived from the following formula:

[0018]

[0019] in and They represent the intra-shard consensus and final consensus delays respectively; the intra-shard consensus delay and final consensus delay include message propagation and message verification delays, which are derived from the following formula:

[0020]

[0021] T final =T dprop +T dval (3)

[0022] in and represents the propagation delay and verification delay of the intra-shard consensus process in the k-shard blockchain, T dpro and T dval It represents the propagation delay and verification delay in the final consensus process;

[0023] At the beginning of the initial consensus of each shard, the master node creates M blocks and broadcasts copies to other nodes. The master node performs a message authentication code verification operation on each request and performs signature verification on each block request;

[0024] At the end of the commit phase, the master and replica nodes reply their intra-shard consistency to the final consensus group to obtain final consistency; at this time, the master and replica nodes create C message authentication codes for each request; so the master node in the intra-shard consensus model consumes resources to perform a total of M signature checks and M(1+C)+4(N k -1) message authentication code operations, the replica node considers processing M signatures and CM+4(N k -1) message authentication code operation;

[0025] It is assumed that the processing time of the primary node and the processing time of the replica node in the kth shard are:

[0026]

[0027]

[0028] where c k It refers to the computing resources of the master node and the replica node in shard k. In the same shard, the processing time of the master node is longer than that of the replica node. In addition, the consensus in the shard is processed in parallel, and the delay is determined by the shard with the largest delay. In addition, the verification process of the master and the replica is executed in parallel. It is believed that:

[0029]

[0030] The consensus process is carried out in parallel on all shards. The propagation delay of each step in the intra-shard consensus is expressed by the following formula:

[0031]

[0032]

[0033]

[0034] Where B is the block size, It represents the data transmission rate between node p and node q in shard k. Assuming the timeout limit of the maximum waiting time ζ, the message propagation between nodes in the consensus process is set with a timeout, which cannot exceed the maximum waiting time, that is, there are the following constraints:

[0035]

[0036] Because the invention assumes that the transmission rate is evenly distributed in the same time slot, and and Equal, that is, the internal propagation delay of the consensus step request within each shard is calculated as follows:

[0037]

[0038] Similarly, the final consensus latency refers to the time it takes for the blocks that are agreed upon within the k shards to be delivered to the final consensus group to reach the final consensus. The final consensus group verifies kM signatures and verifies the kM message authentication codes of the blocks received from each shard. The final consensus group nodes perform PBFT consistency again and then return the merged block to all other nodes. Then, the processing time of the master node and replica node in the final consensus group is considered to be expressed as:

[0039]

[0040]

[0041] where c f It represents the computing resources of the master node and the replica node in the final consensus. From the above formula, it can be concluded that the processing time of the master node in the final consensus group is longer than that of the replica node, so the verification delay in the final consensus group can be obtained:

[0042] T dval =max{T dprimary , T dreplica} (10)

[0043] The propagation delay of each step in the final consensus is expressed as follows:

[0044]

[0045]

[0046]

[0047]

[0048]

[0049] in It represents the data transmission rate between nodes p and q in the final consensus group. Similar to the intra-chip consensus propagation, T dpreprepare , T dprepare , T dcom With T dreq are equal, so the final propagation delay in the consensus group is as follows:

[0050]

[0051] The transaction consensus delay invention assumes that it is completed within multiple consecutive block intervals u, so the delay is subject to the following constraints:

[0052]

[0053]

[0054] in It is obtained from formulas (2) and (3) above.

[0055] In a preferred embodiment, the step 1 includes security analysis; security constraints vary depending on the type of consensus; the PBFT-based algorithm uses the individual voting rights of each replica to reduce individual centralization; the PBFT consensus scheme satisfies the relationship (3f+1)≤n, and there are up to f malicious nodes among n nodes;

[0056] Assume there are K shards, the probability of a malicious node in the blockchain is denoted as p, and the total number of nodes and the number of faulty nodes in shard i are N respectively. i and f i , then each shard should satisfy constraint 3f i +1≤N i To meet the security boundary of PBFT, the number of malicious nodes in the final consensus group is f dc When the final consensus group meets constraint 3f dc +1≤C;

[0057] Each shard group and the final consensus group need to satisfy 3Np+1≤N i and 3Np+1≤C conditions to meet the safety limit; and It turns out that C≤N i , so we get the following security constraints:

[0058]

[0059] Blockchain TPS refers to the number of transactions that a blockchain system can process per second; the block generator is a period T for each block. I Generate a local block with a maximum size of B; if the average transaction size is b, the block header size is B H , the number of shards is K, then the maximum TPS of the blockchain system is calculated by the following formula:

[0060]

[0061] In the system parameters Under given conditions, it is expected that by adjusting the number of shards K and the block interval T I , and block size B are optimized to maximize the blockchain system throughput T; the above joint optimization problem is formally defined as:

[0062]

[0063] Constraint C1 indicates the maximum waiting time for each consensus step to be completed; constraint C2 indicates the relationship between the total consensus delay and the block interval; constraint C3 indicates the range of the number of shards K that meets security conditions.

[0064] In a preferred embodiment, in step 2, the particle updates its speed and position according to equations (17) and (18);

[0065]

[0066] x ij (t+1)=x ij (t)+v ij (t+1) (18)

[0067] Where: t represents the current number of iterations; c 1 and c 2 represents the learning factor, also known as the acceleration constant; r 1 and r 2 is a uniform random number in the range of [0,1], in order to increase the randomness of particle flight; v ij and x ij They represent the speed and position of the jth optimization target of the ith particle, respectively. Usually, it is necessary to define the maximum speed v max To limit the speed of the particle, it is a constant; p ij (t) and p gj (t) are the optimal position searched so far by particle i and the optimal position searched by the entire particle swarm after t iterations; w is the inertia weight, which determines the influence of the previous iteration speed on the current speed.

[0068] In a preferred embodiment, the step 2 includes encoding the problem; the encoding scheme is carried out according to the principles of soundness and integrity; soundness means that the encoded particles must correspond to the potential solutions of the problem in the problem space; integrity means that all feasible solutions of the problem can be represented by particles in the encoding space; the system optimization problem is encoded in the form of parameter type-specific parameters; each particle represents a system performance optimization solution for a sharded blockchain, and the position of particle i at time t It is expressed by formula (19);

[0069]

[0070] in, Represents the allocation position of the dth optimization parameter at time t, such as the number of shards, block size, and block interval.

[0071] In a preferred embodiment, the step 2 includes initializing particles; establishing an initial population; first, half of the particles are generated in the following manner: according to the security constraint formula (14), particles are randomly generated under the conditions; the remaining particles are randomly generated from the set of optimizable sharded blockchain system parameters.

[0072] In a preferred embodiment, the step 2 includes a fitness function; the fitness function of a particle is used to evaluate the quality of different particles, and particles with larger fitness function values ​​are better. The search direction of the fitness function is generally consistent with the direction in which the fitness value increases; the fitness function fitness is:

[0073]

[0074] in is the sharded blockchain system throughput of the i-th particle; the particle with a larger system throughput has a larger fitness value; the problem is converted into solving the problem of solving the maximum fitness value of the particle.

[0075] In a preferred embodiment, the step 2 includes updating the velocity and position of the particle. As shown in formula (17), the particle swarm algorithm mainly consists of three parts: the first part represents the velocity of the particle in the previous state, which is used to ensure the global convergence performance of the method; the second and third parts enable the algorithm to have local convergence ability; the mutation and crossover operations of the genetic algorithm GA are introduced to update the corresponding parts in formula (17); the update method of particle i at time t+1 is as follows:

[0076]

[0077] Among them, M u represents the mutation operation, C g and C p It represents the crossover operation;

[0078] Mutation operation: particles satisfy r 1 When the condition is less than w, the particle undergoes mutation operation, where r 1 is a random number between 0 and 1; individuals are selected from the particle population for mutation, and the mutation method adopts basic bit mutation. The range of gene mutation should be random mutation within the constraint;

[0079] Crossover operation: The last two parts of formula (17) combine the crossover operation idea of ​​genetic algorithm GA, and the particles satisfy r 2 <c 1 , r 3 <c 2 When the condition is met, a crossover operation occurs, where r 2 , r 3 A random number between 0 and 1 that satisfies c 1 When the particle and the individual optimally cross operation occurs; satisfying c 2 When , the particle and the global optimum undergo a crossover operation; the genetic crossover operation uses uniform crossover to generate a random bit string as a crossover mask;

[0080] Calculate the fitness function value fitness of the particles obtained through crossover and mutation of the genetic algorithm. If the fitness value is greater than the fitness of the original particle, update the original particle to join the population, and update the individual optimum and the global optimum at the same time; otherwise, do not update the population.

[0081] In a preferred embodiment, the step 2 includes an algorithm flow, and the specific steps are as follows:

[0082] Step 1): Initialize the numerical settings of the population number, number of iterations, inertia weight, and learning factor parameters in PSO-GA;

[0083] Step 2): Generate the initial particle population according to the particle initialization rule in the particle initialization section;

[0084] Step 3): Calculate the fitness function value of each particle under different conditions according to formulas (17), (18) and (20), set the fitness value of each particle in the first generation as the individual optimal value, and select the particle with the largest fitness function value as the global optimal value;

[0085] Step 4): According to the genetic algorithm rules in the speed and position update of the node particles, select particles for mutation and crossover operations, and calculate the fitness value of the particles after the genetic operation; compare the individual optimal and global optimal values ​​with the updated particle fitness values ​​to determine whether the population needs to be updated. If the current particle fitness value is greater than the individual optimal and global optimal value, update it;

[0086] Step 5): Determine whether the number of times meets the algorithm end condition, such as the maximum number of iterations. If the condition is met, the algorithm ends; otherwise, jump back to step 3).

[0087] Compared with the prior art, the present invention has the following beneficial effects: In the invention, a sharded blockchain system model is first proposed and the performance optimization problem is formalized. Then, a sharded blockchain system performance optimization method PSO-GA combining PSO and GA is designed. This method avoids the problem of traditional particle swarm algorithm falling into local optimality and approaches the optimal solution through particle genetic mutation iteration. The effectiveness and feasibility of the method are verified by simulation experiments under different network conditions. Experimental results show that the PSO-GA method proposed in the present invention can achieve higher system throughput TPS with shorter algorithm execution time. BRIEF DESCRIPTION OF THE DRAWINGS

[0088] Figure 1 A schematic diagram of a sharded blockchain system according to a preferred embodiment of the present invention;

[0089] Figure 2 This is a flow chart of the PBFT consensus algorithm of the preferred embodiment of the present invention (I);

[0090] Figure 3 This is a flow chart of the PBFT consensus algorithm of the preferred embodiment of the present invention (II);

[0091] Figure 4 The flowchart of the PSO-GA algorithm of the preferred embodiment of the present invention is as follows;

[0092] Figure 5 Schematic diagram of execution time of different methods in different network scenarios according to the preferred embodiments of the present invention. DETAILED DESCRIPTION

[0093] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0094] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used in the present invention have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0095] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.

[0096] The performance optimization method of the sharded blockchain system based on PSO-GA specifically includes the following steps:

[0097] 1. Problem Modeling

[0098] exist Figure 1 In the blockchain, transactions come from various application scenarios in the IoT network, such as smart homes, smart factories, monitoring systems, smart cars, and smart healthcare, where data may be shared or processed in different scenarios. Transaction data generated in different scenarios, such as family information, car GPS, medical information, etc., can be shared through the blockchain system. The blockchain network receives transactions from the IoT network and records the transactions in the blockchain ledger to ensure reliable data storage and management, so that shared data and their logical relationships are stored immutably.

[0099] 1. PBFT consensus model

[0100] PBFT is a commonly used distributed consensus algorithm, which is widely used in many blockchain systems, such as Hyperledger, EOS and Zilliqa. It is used for internal consensus and final consensus of sharded blockchain. Figure 2 As shown in the figure, the PBFT algorithm has five phases: request phase, pre-preparation phase, preparation phase, submission phase, and reply phase. The three phases in the middle of the consensus process are the core part of PBFT.

[0101] All blockchain verification nodes are assigned to different shards, and the sharding results are as random and decentralized as possible. This invention will not be described in detail here. After the shards are divided, the transaction shards evenly distribute each transaction to the shards and process them through a two-step consensus process. The two steps include intra-shard consensus and final consensus. All consensus processes are implemented through the PBFT algorithm. The consensus process is as follows Figure 3 shown.

[0102] Before sharding, all nodes participating in the network will form their own ID by solving a simple PoW problem. The problem is to calculate the node ID by combining random seeds, public keys, IP addresses, etc. After the ID is calculated, the shard number is determined by the last l bits of the ID. The value of l depends on the number of shards in the sharded blockchain network. For example, l is 3, which means that the last 3 bits represent the number of shards, and there are at most 2 3 Nodes with the same shard number are divided into the same shard.

[0103] 1) Intra-shard consensus: After the shards are divided, each shard receives its own transaction pool. Each shard processes transactions independently, creates local blocks, and executes the PBFT consensus process within the shard. After the local blocks are trusted by the intra-shard consensus process, they will be sent to the final consensus shard group for final consensus. During this process, all shards are processing transactions in parallel.

[0104] 2) Final consensus: In the final consensus phase, the consensus group receives blocks from different shards from each shard. The master node in the final consensus group merges all blocks in ascending order of shard numbers to generate the final block, and then uses the PBFT consensus algorithm again to achieve the purpose of final consensus.

[0105] The invention considers a sharded blockchain system supporting the Internet of Things, which consists of a two-layer structure, namely a network composed of IoT devices and a sharded blockchain consensus group composed of N verification devices. Assume that the sharded blockchain system has K shards, In addition, the invention divides the consensus group composed of verification devices into two layers, the on-chip consensus layer and the final consensus layer. The on-chip consensus layer has K groups, so there are K+1 groups in total in the system. Therefore, it can be calculated that the final consensus layer has nodes, and the number of nodes in each shard in the on-chip consensus layer is The invention also assumes that the message authentication process includes two operations: signature verification and message authentication code operation (for generating and verifying the message authentication code), which use θ and α CPU cycles respectively.

[0106] 2. Delay model (final block time)

[0107] Latency refers to the time it takes for a transaction to enter a blockchain system and eventually be processed and become irreversible. Transactions entering the network are automatically assigned to shards based on the sender’s last l bits and are verified through intra-shard consensus and final consensus processes. The transaction process consists of two steps: 1) block interval; 2) total consensus latency

[23] , the total latency of a transaction It can be obtained by the following formula:

[0108]

[0109] Where T I is the block interval, For Sharding Total consensus delay of . Determined by the on-chip consensus delay and the final consensus delay, it can be derived from the following formula:

[0110]

[0111] in and They represent the intra-shard consensus and final consensus delays respectively. The intra-shard consensus delay and final consensus delay include message propagation and message verification delays, which can be derived from the following formula:

[0112]

[0113] T final =T dprop +T dval (3)

[0114] in and represents the propagation delay and verification delay of the intra-shard consensus process in the k-shard blockchain, T dpro and T dval It represents the propagation delay and verification delay in the final consensus process.

[0115] At the beginning of the initial consensus of each shard, the master node creates M (batch size) blocks and broadcasts copies to other nodes. The master node performs a message authentication code verification operation on each request and performs signature verification on each block request.

[0116] At the end of the commit phase, the master and replica nodes reply their intra-shard consistency to the final consensus group to obtain final consistency. At this point, the master and replica nodes create C message authentication codes for each request. Therefore, the computational consumption of the master node in the intra-shard consensus model can be considered to perform a total of M signature checks and M(1+C)+4(N k -1) message authentication code operations, the replica node can be considered to process M signatures and CM+4(N k -1) message authentication code operation.

[0117] It can be considered that the processing time of the primary node and the processing time of the replica node in the kth shard are:

[0118]

[0119]

[0120] where c k It refers to the computing resources of the master node and the replica node in shard k. Here we only consider the case where the computing resources are evenly distributed. It can be seen that in the same shard, the processing time of the master node is longer than that of the replica node. In addition, the consensus in the shard is processed in parallel, and the delay is determined by the shard with the largest delay. In addition, the verification process of the master and the replica is executed in parallel. It can be considered that:

[0121]

[0122] The consensus process is carried out in parallel on all shards. The propagation delay of each step in the intra-shard consensus can be expressed by the following formula:

[0123]

[0124]

[0125]

[0126] Where B is the block size, It represents the data transmission rate between node p and node q in shard k. Here, the invention assumes that the transmission rate is the same within the same time slot. In order to limit the unresponsive waiting time of message exchange, a timeout limit of the maximum waiting time is assumed. A timeout is set in the message propagation between nodes in the consensus process, which cannot exceed the maximum waiting time, that is, there are the following constraints:

[0127]

[0128] Because the invention assumes that the transmission rate is evenly distributed in the same time slot, and and Equal, that is, the internal propagation delay of the consensus step request within each shard is calculated as follows:

[0129]

[0130] Similarly, the final consensus latency refers to the time it takes for the blocks that are agreed upon within the k shards to be delivered to the final consensus group to reach the final consensus. The final consensus group verifies kM signatures and verifies kM message authentication codes of the blocks received from each shard. The final consensus group node (with C members) performs PBFT consensus again and then returns the merged block to all other nodes. Then, the processing time of the master node and replica node in the final consensus group can be considered to be expressed as:

[0131]

[0132]

[0133] where c f It represents the computing resources of the master node and the replica node in the final consensus. From the above formula, it can be concluded that the processing time of the master node in the final consensus group is longer than that of the replica node, so the verification delay in the final consensus group can be obtained:

[0134] T dval =max{T dprimary , T dreplica} (10)

[0135] The propagation delay of each step in the final consensus can be expressed as follows:

[0136]

[0137]

[0138]

[0139]

[0140]

[0141] in It represents the data transmission rate between nodes p and q in the final consensus group. Similar to the on-chip consensus propagation, T dpreprepare , T dprepare , T dcom With T dreq are equal, so the final propagation delay in the consensus group is as follows:

[0142]

[0143] The transaction consensus delay invention assumes that it is completed within multiple consecutive block intervals u, so the delay is subject to the following constraints:

[0144]

[0145]

[0146] in It is obtained from formulas (2) and (3) above.

[0147] 3. Security Analysis

[0148] Security constraints vary depending on the type of consensus. PBFT-based algorithms use the individual voting rights of each replica to reduce individual centralization. The PBFT consensus scheme can have up to f malicious nodes among n nodes under the relationship (3f+1)≤n to ensure the security of the consensus process.

[0149] In addition, the invention also considers the security issues in the IoT sharded blockchain system. Assuming there are K shards, the probability of malicious nodes in the blockchain is denoted as p, and assuming that the total number of nodes and the number of faulty nodes in shard i are N respectively. i and f i , then each shard should satisfy constraint 3f i +1≤N i To meet the security boundary of PBFT, the number of malicious nodes in the final consensus group is f dc When the final consensus group meets constraint 3f dc+1≤C.

[0150] When there are Np malicious nodes in the network, the worst case will occur when all malicious nodes are completely divided into the final consensus group. To avoid this situation, each shard group and the final consensus group need to satisfy 3Np+1≤N i And 3Np+1≤C conditions to meet the safety margin. and It can be concluded that C≤N i , so we can get the following security constraints:

[0151]

[0152] Blockchain TPS refers to the number of transactions that a blockchain system can process per second. The block generator generates a block interval period T I Generate a local block with a maximum size of B (bytes). If the average transaction size is b, the block header size is B H , the number of shards is K, then the maximum TPS of the blockchain system can be calculated from the following formula:

[0153]

[0154] In the invention, in the system parameters Under given conditions, the invention expects to achieve the following results by adjusting the number of shards K and the block interval T I , and block size B are optimized to maximize the blockchain system throughput T. The above joint optimization problem can be formally defined as:

[0155]

[0156] Constraint C1 indicates the maximum waiting time for each consensus step to be completed; constraint C2 indicates the relationship between the total consensus delay and the block interval; constraint C3 indicates the range of the number of shards K that meets security conditions.

[0157] 2. Proposed PSO-GA Method

[0158] Particle swarm optimization and genetic algorithm are combined to optimize the parameters of the sharded blockchain system. The particle swarm optimization algorithm (PSO) was proposed by Kennedy et al.

[20] in 1995, inspired by the behavior of bird flocks. The particle swarm optimization algorithm further uses swarm intelligence to establish a simplified model based on the study of bird flock predation behavior. The model corresponds the optimization problem search space to the flight space of bird flocks, and individuals are used to represent the feasible solution of the problem. Individuals are abstracted into particles without mass and volume. The process of bird flocks searching for food corresponds to the process of solving optimization problems, thereby solving complex problems.

[0159] Each particle in the particle swarm algorithm represents a candidate solution to the optimization problem. Given their initial position and initial velocity, the optimal solution to the problem is found through continuous iteration. Each particle can move in the entire problem space at a certain speed and direction and update its movement. The speed is affected by many factors. The fitness function is introduced to evaluate the quality of each particle solution. The function judges the quality of the solution generated by the particle within the space. In each iteration, the particle updates its position and flight speed in the solution space by tracking two "extreme values". The particle updates its speed and position according to equations (17) and (18).

[0160]

[0161] x ij (t+1)=x ij (t)+v ij (t+1) (18)

[0162] Where: t represents the current number of iterations; c 1 and c 2 represents the learning factor, also known as the acceleration constant; r 1 and r 2 is a uniform random number in the range of [0,1], in order to increase the randomness of particle flight; v ij and x ij They represent the speed and position of the jth optimization target of the ith particle, respectively. Usually, it is necessary to define the maximum speed v max To limit the speed of particles, usually a constant; p ij (t) and p gj (t) are the optimal position searched so far by particle i and the optimal position searched by the entire particle swarm after t iterations; w is the inertia weight, which can determine the influence of the previous iteration speed on the current speed and is crucial to the convergence of the entire PSO.

[0163] 1. Question coding

[0164] In order to improve the overall performance of the algorithm, a good encoding method is essential. The encoding scheme of the present invention is mainly based on the principles of soundness and integrity. Soundness means that the encoded particles must correspond to the potential solutions of the problem in the problem space; integrity means that all feasible solutions to the problem can be represented by particles in the encoding space. It is very difficult to find an encoding scheme that satisfies all these principles at the same time. Inspired by the literature

[21] , the parameter type-specific parameter method is used to encode the system optimization problem. Each particle represents a system performance optimization solution for a sharded blockchain. The position of particle i at time t It is expressed by formula (19).

[0165]

[0166] in, Represents the allocation position of the dth optimization parameter at time t, such as the number of shards, block size, block interval, etc.

[0167] 2. Particle initialization

[0168] Traditional particle initialization generates particles randomly, which results in low particle quality. For PSO, the location of the initial particle population determines the scope of the search space and plays a key role in the complexity and performance of the method. Therefore, establishing a high-quality initial population can greatly save the algorithm's computing time.

[0169] First, half of the particles can be generated as follows: According to the security constraint formula (14) obtained in Section 3.3, particles are randomly generated under the conditions that meet the conditions, so that the quality of the particles obtained is improved to a certain extent. The remaining particles are randomly generated from the set of parameters of the optimizable sharded blockchain system.

[0170] 3. Fitness function

[0171] The fitness function of a particle is used to evaluate the quality of different particles. In the present invention, particles with larger fitness function values ​​are better. The search direction of the fitness function is generally consistent with the direction in which the fitness value increases. The fitness function fitness defined in the present invention is:

[0172]

[0173] in is the shard blockchain system throughput of the i-th particle. In this way, the particle with a larger system throughput has a larger fitness value. The problem is converted into solving the problem of solving the maximum fitness value of the particle.

[0174] 4. Particle speed and position update

[0175] As shown in formula (17), the particle swarm algorithm mainly consists of three parts: the first part represents the speed of the particle in the previous state, which is used to ensure the global convergence performance of the method; the second and third parts are to make the algorithm have local convergence ability. In order to solve the problem of traditional particle swarm algorithm falling into local optimality, the present invention introduces the mutation and crossover operations of the genetic algorithm (GA) algorithm, and updates the corresponding parts in formula (17). The update method of particle i at time t+1 is as follows:

[0176]

[0177] Among them, M urepresents the mutation operation, C g and C p It represents a crossover operation.

[0178] Mutation operation: particles satisfy r 1 When the condition is less than w, the particle undergoes mutation operation, where r 1 is a random number between 0 and 1. Individuals are selected from the particle population for mutation, and the mutation method adopts basic bit mutation. The range of gene mutation should be random mutation within the constraint.

[0179] Crossover operation: The last two parts of formula (17) combine the crossover operation idea of ​​GA algorithm, and the particles satisfy r 2 <c 1 , r 3 <c 2 When the condition is met, a crossover operation occurs, where r 2 , r 3 is a random number between 0 and 1. (1) satisfies c 1 When the particle and the individual optimally cross operation occurs; (2) satisfying c 2 When , the particle crosses with the global optimum. The genetic crossover operation uses uniform crossover to generate a random bit string as the crossover mask.

[0180] Calculate the fitness function value fitness of the particles obtained through crossover and mutation of the genetic algorithm. If the fitness value is greater than the fitness of the original particle, update the original particle to join the population, and update the individual optimum and the global optimum at the same time; otherwise, do not update the population.

[0181] 5. Algorithm Process

[0182] The PSO-GA process is as follows Figure 4 As shown, the specific steps are as follows.

[0183] Step 1: Initialize the numerical settings of parameters such as population number, number of iterations, inertia weight, and learning factor in PSO-GA.

[0184] Step 2 generates the initial particle population according to the particle initialization rules in the particle initialization section.

[0185] Step 3: Calculate the fitness function value of each particle under different conditions according to formulas (17), (18) and (20), set the fitness value of each particle in the first generation as the individual optimal value, and select the particle with the largest fitness function value as the global optimal.

[0186] Step 4: According to the genetic algorithm rules in the node particle speed and position update, select particles for mutation and crossover operations, and calculate the fitness value of the particles after the genetic operation. Compare the individual optimal and global optimal values ​​with the updated particle fitness values ​​to determine whether the population needs to be updated. If the current particle fitness value is greater than the individual optimal and global optimal, it is updated.

[0187] Step 5 determines whether the number of times meets the algorithm end condition, such as the maximum number of iterations. If the condition is met, the algorithm ends; otherwise, jump back to step 3.

[0188] 3. Invention Simulation and Result Analysis

[0189] 1. Simulation settings

[0190] The simulation experiment of the present invention is carried out under a 64-bit Windows 10 system, with a configuration of 16GB memory and a 3.00GHz i5Intel processor. The simulation environment is based on 200 sharded blockchain system verification nodes, which are randomly divided into K block producers in each epoch. The algorithm for optimizing the system performance of the proposed sharded blockchain is implemented using MATLAB. The parameter settings of PSO-GA are as follows: the population size is 60 and the maximum number of iterations is 300. The specific parameter settings used in the simulation are summarized in Table 1. The experimental performance is analyzed in terms of system throughput TPS (Transaction per Second), which represents the throughput of the sharded blockchain system under the constraints.

[0191] Table 1 Experimental parameter settings

[0192]

[0193] The present invention considers simulation experiments under four different network conditions, scenario 1: 200 nodes, malicious node probability 0.05, transmission rate 100Mbps; scenario 2: 200 nodes, malicious node probability 0.01, transmission rate 100Mbps; scenario 3: 200 nodes, malicious node probability 0.05, transmission rate 50Mbps; scenario 4: 400 nodes, malicious node probability 0.05, transmission rate 100Mbps. The four scenarios of the present invention respectively consider the differences in network conditions such as the number of system nodes, the proportion of system malicious nodes, and the transmission rate between system nodes, and on this basis, the effectiveness of the method proposed by the present invention is analyzed and demonstrated.

[0194] 2. Comparison method

[0195] Based on the above experimental setup, the proposed PSO-GA method is compared and analyzed with the following three benchmarks:

[0196] 1) Random: The algorithm randomly generates the optimization parameters of the shard block system. Each time, it will be executed 30,000 times randomly, and the solution with the highest fitness function value will be selected as the solution;

[0197] 2) DE

[23] : Differential Evolution (DE), which is also a kind of intelligent optimization algorithm. The algorithm-related parameter settings are consistent with the method settings proposed in the present invention;

[0198] 3) Brute force: Enumerate all possible system optimization parameters and obtain the solution with the highest system throughput TPS under the constraints proposed by the present invention.

[0199] 3. Analysis of experimental results

[0200] In order to analyze the effectiveness of the PSO-GA algorithm proposed in the present invention, the system throughput TPS of the sharded blockchain and the algorithm completion time are used as evaluation indicators of the method to comprehensively reflect the effectiveness of the method of the present invention.

[0201] The present invention experiments the PSO-GA algorithm, random algorithm, DE algorithm and brute force algorithm under given network conditions. Table 2 shows the TPS value of each algorithm under different sharded blockchain network conditions and the difference value from the brute force enumeration of the ideal solution. It can be clearly seen from the table that the difference between the method proposed by the present invention and the ideal solution is almost negligible, but the proposed PSO-GA method is improved by 2%-5% compared with DE and random algorithms. It has good performance in all network scenarios.

[0202] Table 2 TPS under different network conditions

[0203]

[0204] Figure 5 The completion time of each method under different network conditions is shown. It can be clearly seen from the figure that compared with the brute force method, the other three methods require significantly less execution time. The execution time of the method of the present invention and the random method is similar because the random experiment setting is based on the PSO-GA method; the execution time of the DE algorithm is more than twice that of the method of the present invention. The simulation experimental results in different network scenarios are consistent.

[0205] In summary, combined with Table 2 and Figure 5 It can be concluded that the PSO-GA algorithm can achieve a better balance between TPS and algorithm execution time than other methods. The PSO-GA algorithm performs optimally under the constraints.

Claims

1. Sharded blockchain system performance optimization method based on PSO-GA, Features The following steps are involved: Step 1: Problem modeling; Transactions come from various application scenarios in the IoT network, where data is shared or processed in different scenarios; transaction data generated in different scenarios is shared in the database through the blockchain system; The blockchain network receives transactions from the IoT network and records the transactions in the blockchain ledger to ensure reliable data storage and management, so that shared data and its logical relationships are stored immutably; Step 2: The proposed PSO-GA method; combining particle swarm optimization and genetic algorithm to optimize the parameters of the sharded blockchain system; the particle swarm optimization algorithm further uses swarm intelligence to establish a simplified model through the study of bird flock predation behavior. The model corresponds the optimization problem search space to the flight space of the bird flock, and the individuals are used to represent the feasible solution of the problem. The individuals are abstracted into particles without mass and volume, and the process of the bird flock searching for food corresponds to the process of solving the optimization problem; Each particle in the particle swarm algorithm represents a candidate solution to the optimization problem. Given their initial position and initial velocity, the optimal solution to the problem is found through continuous iteration. Each particle moves in the entire problem space at a certain speed and direction and updates its movement. The speed is affected by many factors. The fitness function is introduced to evaluate the quality of each particle's solution. The function determines the quality of the solution generated by the particle within the space. In each iteration, the particle updates its position and flight speed in the solution space by tracking two "extreme values".

2. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 1, It is characterized in that The step 1 includes establishing a PBFT consensus model; The PBFT consensus model has five phases: request phase, pre-preparation phase, preparation phase, submission phase, and reply phase; All blockchain verification nodes are assigned to different shards, and the sharding results are as random and decentralized as possible; After the shards are divided, the transaction shards evenly distribute each transaction to the shards and process it through a two-step consensus process; the two steps include intra-shard consensus and final consensus; all consensus processes are implemented through the PBFT algorithm; Before sharding, all nodes participating in the network will form their own ID by solving a PoW problem. The node ID is calculated by combining the random seed, public key and IP address. After the ID is calculated, the shard number is determined by the last l bits of the ID. The value of l depends on the number of shards in the sharded blockchain network. Nodes with the same shard number are divided into the same shard. 1) Intra-shard consensus: After sharding, each shard receives its own transaction pool; Each shard processes transactions independently, creates local blocks and executes the PBFT consensus process within the shard. After the local blocks are trusted by the internal consensus process, they will be sent to the final consensus shard group for final consensus. During this process, all shards are processing transactions in parallel; 2) Final consensus: In the final consensus stage, the consensus group receives blocks from different shards from each shard; the master node in the final consensus group merges all blocks in ascending order of shard numbers to generate the final block, and then uses the PBFT consensus algorithm again to achieve the purpose of final consensus; The sharded blockchain system supporting the Internet of Things consists of a two-layer structure, namely a network consisting of IoT devices and a sharded blockchain consensus group consisting of N verification devices; assuming that the sharded blockchain system has K shards, It means that the consensus group composed of verification devices is divided into two layers, the on-chip consensus layer and the final consensus layer. The on-chip consensus layer has K groups, so there are K+1 groups in total in the system. The final consensus layer has nodes, and the number of nodes in each shard in the on-chip consensus layer is Assume that the message verification process includes two operations: signature verification and message authentication code operation, which use θ and α CPU cycles respectively.

3. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 2, It is characterized in that Step 1 includes establishing a latency model; latency refers to the time required for a transaction to enter the blockchain system and eventually be processed and become irreversible; transactions entering the network are automatically assigned to shards by the last l bits of the sender and verified through intra-shard consensus and final consensus processes; The transaction process consists of two steps: 1) Block interval; 2) Total consensus delay, the total delay of the transaction It is derived from the following formula: Where T I is the block interval, For Sharding Total consensus delay of Determined by the on-chip consensus delay and the final consensus delay, it is derived from the following formula: in and T final They represent the intra-shard consensus and final consensus delays respectively; the intra-shard consensus delay and final consensus delay include message propagation and message verification delays, which are derived from the following formula: T final =T dprop +T dval (3) in and represents the propagation delay and verification delay of the intra-shard consensus process in the k-shard blockchain, T dprop and T dval It represents the propagation delay and verification delay in the final consensus process; At the beginning of the initial consensus of each shard, the master node creates M blocks and broadcasts copies to other nodes. The master node performs a message authentication code verification operation on each request and performs signature verification on each block request; At the end of the commit phase, the master and replica nodes reply their intra-shard consistency to the final consensus group to obtain final consistency; at this time, the master and replica nodes create C message authentication codes for each request; so the master node in the intra-shard consensus model consumes resources to perform a total of M signature checks and M(1+C)+4(N k -1) message authentication code operations, the replica node considers processing M signatures and CM+4(N k -1) message authentication code operation; It is assumed that the processing time of the primary node and the processing time of the replica node in the kth shard are: where c k It refers to the computing resources of the master node and the replica node in shard k. In the same shard, the processing time of the master node is longer than that of the replica node. In addition, the consensus in the shard is processed in parallel, and the delay is determined by the shard with the largest delay. In addition, the verification process of the master and the replica is executed in parallel. It is believed that: The consensus process is carried out in parallel on all shards. The propagation delay of each step in the intra-shard consensus is expressed by the following formula: Where B is the block size, It represents the data transmission rate between node p and node q in shard k. Assuming the timeout limit of the maximum waiting time ζ, the message propagation between nodes in the consensus process is set with a timeout, which cannot exceed the maximum waiting time, that is, there are the following constraints: Because the transmission rate is assumed to be uniformly distributed within the same time slot, and and Equal, that is, the internal propagation delay of the consensus step request within each shard is calculated as follows: Similarly, the final consensus latency refers to the time it takes for the blocks that are agreed upon within the k shards to be delivered to the final consensus group to reach the final consensus. The final consensus group verifies kM signatures and verifies the kM message authentication codes of the blocks received from each shard. The final consensus group nodes perform PBFT consistency again and then return the merged block to all other nodes. Then, the processing time of the master node and replica node in the final consensus group is considered to be expressed as: where c f It represents the computing resources of the master node and the replica node in the final consensus. From the above formula, it can be concluded that the processing time of the master node in the final consensus group is longer than that of the replica node, so the verification delay in the final consensus group can be obtained: T dval =max{T dprimary ,T dreplica } (10) The propagation delay of each step in the final consensus is expressed as follows: in It represents the data transmission rate between nodes p and q in the final consensus group. Similar to the intra-chip consensus propagation, T dpreprepare , T dprepare , T dcom With T dreq are equal, so the final propagation delay in the consensus group is as follows: The transaction consensus delay invention assumes that it is completed within multiple consecutive block intervals u, so the delay is subject to the following constraints: in It is obtained from formulas (2) and (3) above.

4. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 3, It is characterized in that The step 1 includes security analysis; security constraints vary depending on the type of consensus; the PBFT-based algorithm uses the individual voting rights of each replica to reduce individual centralization; the PBFT consensus scheme satisfies the relationship (3f+1)≤n, and there are up to f malicious nodes among n nodes; Assume there are K shards, the probability of a malicious node in the blockchain is denoted as p, and the total number of nodes and the number of faulty nodes in shard i are N respectively. i and f i , then each shard should satisfy constraint 3f i +1≤N i To meet the security boundary of PBFT, the number of malicious nodes in the final consensus group is f dc When the final consensus group meets constraint 3f dc +1≤C; Each shard group and the final consensus group need to satisfy 3Np+1≤N i and 3Np+1≤C conditions to meet the safety limit; and It turns out that C≤N i , so we get the following security constraints: Blockchain TPS refers to the number of transactions that a blockchain system can process per second; the block generator is a period T for each block. I Generate a local block with a maximum size of B; if the average transaction size is b, the block header size is B H , the number of shards is K, then the maximum TPS of the blockchain system is calculated by the following formula: In the system parameters Under given conditions, it is expected that by adjusting the number of shards K and the block interval T I and block size B to maximize the blockchain system throughput T; the above joint optimization problem is formally defined as: Constraint C1 indicates the maximum waiting time for each consensus step to be completed; constraint C2 indicates the relationship between the total consensus delay and the block interval; constraint C3 indicates the range of the number of shards K that meets security conditions.

5. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 4, It is characterized in that In step 2, the particle updates its speed and position according to equations (17) and (18); x ij (t+1)=x ij (t)+v ij (t+1) (18) Where: t represents the current number of iterations; c 1 and c 2 represents the learning factor, also known as the acceleration constant; r 1 and r 2 is a uniform random number in the range of [0,1], in order to increase the randomness of particle flight; v ij and x ij Respectively represent the speed and position of the jth optimization target of the ith particle, and define the maximum speed v max To limit the speed of the particle, it is a constant; p ij (t) and p gj (t) are the optimal position searched so far by particle i and the optimal position searched by the entire particle swarm after t iterations; w is the inertia weight, which determines the influence of the previous iteration speed on the current speed.

6. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 1, It is characterized in that The second step includes coding the problem; the coding scheme is carried out according to the principles of soundness and completeness; soundness means that the coded particles must correspond to the potential solutions of the problem in the problem space; Completeness means that all feasible solutions to the problem can be represented by particles in the coding space; the system optimization problem is encoded in the form of parameter type-specific parameters; each particle represents a system performance optimization solution for a sharded blockchain, and the position of particle i at time t It is expressed by formula (19); in, Represents the allocation position of the dth optimization parameter at time t, such as the number of shards, block size, and block interval.

7. According to the PSO-GA-based sharded blockchain system performance optimization method of claim 5, It is characterized in that Step 2 includes particle initialization; establishing an initial population; first, half of the particles are generated as follows: according to the security constraint formula (14), particles are randomly generated under the condition of satisfying it; the remaining particles are randomly generated from the set of parameters of the sharded blockchain system that can be optimized.

8. The method for optimizing the performance of a sharded blockchain system based on PSO-GA according to claim 7, wherein, Step 2 includes a fitness function; the fitness function of a particle is used to evaluate the quality of different particles. The particle corresponding to a larger fitness function value is better, and the search direction of the fitness function is consistent with the direction in which the fitness value increases; the fitness function fitness is: in is the sharded blockchain system throughput of the i-th particle; the particle with a larger system throughput has a larger fitness value; the problem is converted into solving the problem of solving the maximum fitness value of the particle.

9. The method for optimizing the performance of a sharded blockchain system based on PSO-GA according to claim 5, wherein, Step 2 includes updating the velocity and position of particles; as shown in formula (17), the particle swarm algorithm mainly consists of three parts: the first part represents the velocity of the particle in the previous state, which is used to ensure the global convergence performance of the method; the second and third parts enable the algorithm to have local convergence ability; the mutation and crossover operations of the genetic algorithm GA are introduced, and the corresponding parts in formula (17) are updated; the update method of particle i at time t + 1 is as follows: Among them, M u represents the mutation operation, C g and C p It represents the crossover operation; Mutation operation: particles satisfy r 1 When the condition is less than w, the particle undergoes mutation operation, where r 1 is a random number between 0 and 1; individuals are selected from the particle population for mutation, and the mutation method adopts basic bit mutation. The range of gene mutation should be random mutation within the constraint; Crossover operation: The last two parts of formula (17) combine the crossover operation idea of ​​genetic algorithm GA, and the particles satisfy r 2 <c 1 , r 3 <c 2 When the condition is met, a crossover operation occurs, where r 2 , r 3 A random number between 0 and 1 that satisfies c 1 When the particle and the individual optimally cross operation occurs; satisfying c 2 When , the particle and the global optimum undergo a crossover operation; the genetic crossover operation uses uniform crossover to generate a random bit string as a crossover mask; Calculate the fitness function value fitness of the particles obtained through the crossover and mutation of the genetic algorithm. If the fitness value is greater than the fitness of the original particle, update the original particle and add it to the population, and at the same time update the individual best and the global best; otherwise, do not update the population.

10. The method for optimizing the performance of a sharded blockchain system based on PSO-GA according to claim 8, wherein, Step 2 includes an algorithm flow, and the specific steps are as follows; Step 1): Initialize the numerical settings of the population size, number of iterations, inertia weight, and learning factor parameters in PSO-GA; Step 2): Generate an initial particle population according to the particle initialization rules in the particle initialization section; Step 3): Calculate the fitness function values of each particle in different cases according to formulas (17), (18), and (20), set the fitness value of each particle in the first generation as the individual best value, and select the particle with the largest fitness function value from them as the global best; Step 4): According to the genetic algorithm rules in the section of updating the velocity and position of particles, select particles for mutation and crossover operations, and calculate the fitness values of the particles after the genetic operations; compare the individual best and the global best with the updated particle fitness values obtained, and judge whether it is necessary to update the population. If the current particle fitness value is greater than the individual best and the global best, then update; Update; Step 5): Judge whether the number of times meets the algorithm end condition, such as the maximum number of iterations. If the condition is satisfied, the algorithm ends; Otherwise, jump back to Step 3).