Block chain system pressure balancing method and related device
By obtaining the target system information of the blockchain system and determining and implementing the pressure equilibrium strategy, the problem of poor pressure equilibrium caused by relying solely on node capabilities in the existing technology is solved, reducing the risk of transaction loss, and improving the throughput of the blockchain system and TPS performance.
Patent Information
- Application Number
- CN202310734492.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-20
- Publication Date
- 2024-12-20
AI Technical Summary
The existing blockchain system only relies on the transaction processing capacity of each blockchain node for pressure equilibrium, resulting in poor pressure equilibrium effect and failure to fully consider the transaction pool capacity, resulting in an increase in the risk of transaction loss.
By obtaining the target system information of the blockchain system, including the node resource information and transaction pool capacity of each blockchain node, the target pressure equilibrium strategy is determined, and based on this strategy, transactions are distributed to each blockchain node's transaction pool based on this strategy. Quantity to ensure balanced distribution.
It effectively reduces the risk of transaction loss, improves the pressure equalization effect and throughput of the blockchain system, and improves TPS performance.
Smart Images

Figure CN119172387A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a pressure balancing method and related devices for a blockchain system. Background Art
[0002] Blockchain technology can solve the problem of trust establishment between nodes in a decentralized system through distributed node verification and consensus mechanisms, and realize a decentralized and distributed trust establishment mechanism, thereby completing the transfer of value while transmitting information. The transaction privacy, security, data immutability and auditability, integrity, system transparency and fault tolerance of blockchain make blockchain widely used in many fields, including identity management, intelligent transportation, supply chain management, Internet of Things, Industrial Internet, Energy Internet, etc. The number of transactions that can be processed per second (Transactions Per Second, TPS) is an important indicator in the blockchain system. In the blockchain system, the higher the TPS, the more transactions the system can process per second, which means that the system has a larger throughput and higher performance. Therefore, improving the TPS of the blockchain system has always been an important goal of blockchain technology research and development.
[0003] In related technologies, pressure balancing is mainly achieved by utilizing the transaction processing capability of each blockchain node.
[0004] However, the transaction pool capacity of blockchain nodes may change, and only using the transaction processing capacity of each blockchain node to balance the pressure will result in poor pressure balancing effect. Summary of the invention
[0005] The embodiments of the present application provide a pressure balancing method and related devices for a blockchain system, which are used to solve the technical problem in the related art that pressure balancing is performed only by utilizing the transaction processing capability of each blockchain node, resulting in poor pressure balancing effect.
[0006] On the one hand, an embodiment of the present application provides a pressure balancing method for a blockchain system, the blockchain system including at least two blockchain nodes, the method including: obtaining target system information of the blockchain system, the target system information including at least one item of node resource information of each blockchain node and a transaction pool capacity of a transaction pool corresponding to each blockchain node, the at least one item of node resource information being used to indicate the ability of the blockchain node to process transactions, and the transaction pool capacity being used to indicate the maximum number of transactions that can be stored in the transaction pool;
[0007] Determine a target pressure balancing strategy for the blockchain system based on the target system information, where the target pressure balancing strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period;
[0008] The number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy.
[0009] In a possible implementation, determining a target pressure balancing strategy of a blockchain system based on target system information includes:
[0010] Perform pressure scheduling based on target system information polling to obtain a target pressure balancing strategy corresponding to each pressure scheduling, wherein the target pressure balancing strategy includes a pressure test value of each blockchain node, and the pressure test value is used to indicate the number of transactions distributed to the transaction pool corresponding to the blockchain node in unit time;
[0011] The number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy, including:
[0012] For each pressure scheduling process, the target pressure balance strategy is obtained, and the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy.
[0013] In a possible implementation, the first pressure scheduling process includes:
[0014] A stress test value of each blockchain node is determined based on at least one item of node resource information of each blockchain node.
[0015] In one possible implementation, determining a stress test value of each blockchain node based on at least one item of node resource information of each blockchain node includes:
[0016] Determine the transaction processing capability of each blockchain node based on at least one item of node resource information of each blockchain node;
[0017] Based on the transaction processing capacity of each blockchain node, determine the total transaction processing capacity of at least two blockchain nodes, where the total transaction processing capacity is positively correlated with the transaction processing capacity of each blockchain node;
[0018] Determine the capacity ratio of the transaction processing capacity of each blockchain node to the total transaction processing capacity, and determine the stress test value of each blockchain node based on the product of the capacity ratio corresponding to each blockchain node and the block capacity of the blockchain system.
[0019] In a possible implementation, the Nth pressure scheduling process includes:
[0020] Obtain the N-1th stress test result of each blockchain node. The N-1th stress test result is obtained when the transaction is distributed to each blockchain node using the target stress balance strategy corresponding to the N-1th stress scheduling process;
[0021] If the N-1th stress test result of any blockchain node meets the preset stress adjustment condition, the stress test value of the satisfied blockchain node is adjusted;
[0022] Wherein, N is an integer not less than 2.
[0023] In a possible implementation, the stress test result includes the current transaction quantity of the corresponding transaction pool;
[0024] Pressure regulation conditions include:
[0025] The current transaction quantity of the corresponding transaction pool is outside the threshold interval formed by a preset first target transaction quantity threshold and a preset second target transaction quantity threshold, the first target transaction quantity threshold is greater than or equal to the first target transaction quantity, the second target transaction quantity threshold is less than or equal to the corresponding second target quantity, and the first target transaction quantity threshold is less than the second target transaction quantity threshold;
[0026] Among them, the first target transaction number is determined based on the block capacity of the blockchain system, and the second target transaction number is determined based on the transaction pool capacity corresponding to the blockchain node.
[0027] In a possible implementation, the stress test result also includes a current resource utilization rate of at least one node resource;
[0028] Pressure regulation conditions also include:
[0029] The current resource utilization of any node resource is greater than the preset utilization threshold.
[0030] In a possible implementation, the first target transaction quantity is linearly positively correlated with a first product result corresponding to the blockchain node, the first product result is the product of the block capacity of the blockchain system and a preset capacity multiplication factor, and the capacity multiplication factor is a value greater than 1; and / or,
[0031] The second target transaction quantity corresponding to the blockchain node is linearly positively correlated with the second product result corresponding to the blockchain node. The second product result is the product of the transaction pool capacity corresponding to the blockchain node and the first difference. The first difference is positively correlated with the total number of nodes of at least two blockchain nodes.
[0032] In a possible implementation, adjusting the stress test value of the blockchain node to be satisfied includes:
[0033] If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is less than the first target transaction quantity threshold, then the stress test value of the satisfied blockchain node is increased; and / or,
[0034] If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is greater than the second target transaction quantity threshold, the stress test value of the satisfied blockchain node is adjusted to a value less than the preset stress test value threshold.
[0035] In a possible implementation, the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy, including:
[0036] Based on the target pressure balancing strategy, at least one pressure test task corresponding to a target blockchain node is sent to the pressure balancing control node. The pressure test task includes a test address and a pressure test value. The pressure balancing control node is used to distribute transactions to the transaction pool pointed to by the test address in the pressure test task based on the pressure test value in the pressure test task;
[0037] Among them, the stress test value of the target blockchain node is greater than the preset stress test value threshold.
[0038] In a possible implementation, the first scheduling time interval is positively correlated with the second scheduling time interval and the third scheduling time interval, the first scheduling time interval is the time interval between the M+1th pressure scheduling process and the Mth pressure scheduling process, the second scheduling time interval is the time interval between the Mth pressure scheduling process and the M-1th pressure scheduling process, and the third scheduling time interval is the time interval between the M-1th pressure scheduling process and the M-2th pressure scheduling process;
[0039] Wherein, M is an integer not less than 3.
[0040] On the other hand, an embodiment of the present application provides a pressure balancing device for a blockchain system, the blockchain system including at least two blockchain nodes, the device including:
[0041] An information acquisition module, used to acquire target system information of the blockchain system, the target system information including at least one item of node resource information of each blockchain node and the transaction pool capacity of the transaction pool corresponding to each blockchain node, the at least one item of node resource information is used to indicate the ability of the blockchain node to process transactions, and the transaction pool capacity is used to indicate the maximum number of transactions that can be stored in the transaction pool;
[0042] A strategy determination module, used to determine a target pressure balancing strategy of the blockchain system based on target system information, where the target pressure balancing strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period;
[0043] The pressure balancing module is used to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy.
[0044] On the other hand, an embodiment of the present application provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the steps of any one of the methods.
[0045] On the other hand, an embodiment of the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the steps of any aspect of the method are implemented.
[0046] On the other hand, an embodiment of the present application provides a computer program product, including a computer program, which implements the steps of any aspect of the method when the computer program is executed by a processor.
[0047] The technical solution provided in the embodiment of the present application has the following beneficial effects: the target pressure balancing strategy of the blockchain system is determined by the target system information of the blockchain system, and then the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balancing strategy. The target system information includes at least one item of node resource information of each blockchain node and the transaction pool capacity of the transaction pool corresponding to each blockchain node. The node resource information can reflect the ability of the blockchain node to process transactions, and the transaction pool capacity can reflect the maximum number of transactions that the transaction pool corresponding to the blockchain node can accommodate. That is, the generated target pressure balancing strategy takes into account at least two factors, namely, the ability of each blockchain node to process transactions and the maximum number of transactions that the transaction pool corresponding to the blockchain node can accommodate. This avoids the risk of transaction loss caused by only using the ability of each blockchain node to process transactions for pressure balancing in the related technology without considering the transaction pool capacity of the transaction pool, thereby achieving the goal of reducing the risk of transaction loss while maintaining the throughput of the blockchain system, thereby improving the pressure balancing effect of the blockchain system. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0049] Figure 1A A schematic diagram of the structure of a data sharing system provided in an embodiment of the present application;
[0050] Figure 1B A schematic diagram of a blockchain provided in an embodiment of the present application;
[0051] Figure 1C A schematic diagram of a new block generation process provided in an embodiment of the present application
[0052] Figure 2 A flowchart of a pressure balancing method for a blockchain system provided in an embodiment of the present application;
[0053] Figure 3 This is a flow chart of another pressure balancing method for a blockchain system provided in an embodiment of the present application;
[0054] Figure 4 It is a flow chart of pressure scheduling based on pressure test tasks provided by an embodiment of the present application;
[0055] Figure 5 It is a schematic diagram of a framework of a technical implementation provided by an embodiment of the present application;
[0056] Figure 6 This embodiment of the present application provides a method based on Figure 6 A schematic diagram of a pressure equalization process of the framework;
[0057] Figure 7 A schematic diagram of the structure of a pressure equalization device for a blockchain system provided in an embodiment of the present application;
[0058] Figure 8 A schematic diagram of the structure of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0059] The embodiments of the present application are described below in conjunction with the drawings in the present application. It should be understood that the implementation methods described below in conjunction with the drawings are exemplary descriptions for explaining the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions of the embodiments of the present application.
[0060] Those skilled in the art will appreciate that, unless expressly stated, the singular forms "one", "an", "" and "the" used herein may also include plural forms. It will be further understood that the terms "including" and "comprising" used in the embodiments of the present application mean that the corresponding features may be implemented as the presented features, information, data, steps, operations, components and / or assemblies, but do not exclude implementation as other features, information, data, steps, operations, components, assemblies and / or combinations thereof supported by the technical field. It will be understood that when we refer to a component as being "connected" or "coupled" to another component, the component may be directly connected or coupled to the other component, or may refer to a connection relationship between the component and the other component through an intermediate component. In addition, the "connection" or "coupling" used herein may include wireless connection or wireless coupling. The term "and / or" used herein indicates at least one of the items defined by the term, for example, "A and / or B" indicates implementation as "A", or implementation as "A", or implementation as "A and B".
[0061] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.
[0062] The following describes several exemplary embodiments to illustrate the technical solutions of the embodiments of the present application and the technical effects produced by the technical solutions of the present application. It should be noted that the following embodiments can refer to, draw on or combine with each other, and the same terms, similar features and similar implementation steps in different embodiments will not be described repeatedly.
[0063] The present application embodiment involves a blockchain system, which can be a data sharing system formed by connecting a client and multiple nodes (any form of computing devices in the access network, such as a server, a user terminal) through network communication. Figure 1A The data sharing system shown, the data sharing system 100 refers to a system for sharing data between blockchain nodes (hereinafter referred to as nodes) and blockchain nodes. The data sharing system may include multiple nodes 101, and multiple nodes 101 may refer to each client in the data sharing system. Each node 101 can receive input information when performing normal work, and maintain the shared data in the data sharing system based on the received input information. In order to ensure the information intercommunication within the data sharing system, there may be an information connection between each node in the data sharing system, and information can be transmitted between nodes through the above information connection. For example, when any node in the data sharing system receives input information, other nodes in the data sharing system obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the data sharing system are consistent.
[0064] Each node in the data sharing system has a corresponding node identifier, and each node in the data sharing system can store the node identifiers of other nodes in the data sharing system, so that the generated blocks can be broadcast to other nodes in the data sharing system according to the node identifiers of other nodes. A node identifier list as shown in the following table can be maintained in each node, and the node name and node identifier are stored in the node identifier list accordingly. Among them, the node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address and any other information that can be used to identify the node. Table 1 only takes the IP address as an example for illustration.
[0065] Node Name Node ID Node 1 117.114.151.174 Node 2 117.116.189.145 … … Node N 119.123.789.258
[0066] Each node in the data sharing system stores the same blockchain. The blockchain consists of multiple blocks, see Figure 1B The blockchain consists of multiple blocks. The genesis block includes a block header and a block body. The block header stores the input information characteristic value, version number, timestamp and difficulty value, and the block body stores the input information; the next block of the genesis block takes the genesis block as the parent block, and the next block also includes a block header and a block body. The block header stores the input information characteristic value of the current block, the block header characteristic value, version number, timestamp and difficulty value of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, ensuring the security of the input information in the block.
[0067] When generating each block in the blockchain, see Figure 1C When the node where the blockchain is located receives the input information, it verifies the input information. After the verification is completed, the input information is stored in the memory pool and the hash tree used to record the input information is updated. After that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried to calculate the eigenvalue multiple times so that the calculated eigenvalue can satisfy the following formula:
[0068] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET
[0069] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.
[0070] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the node where the blockchain is located sends the newly generated block to other nodes in the data sharing system according to the node identification of other nodes in the data sharing system. Other nodes verify the newly generated block and add the newly generated block to the blockchain stored in them after the verification is completed.
[0071] The present application provides a method for balancing the pressure of a blockchain system, which can be applied to a computer device. The computer device can be a related device, server, etc. that has a communication connection with the blockchain system, or a related node in the blockchain system, which is not limited here. Figure 2 As shown, the method includes:
[0072] S210. Obtain target system information of the blockchain system, where the target system information includes at least one item of node resource information of each blockchain node and a transaction pool capacity of a transaction pool corresponding to each blockchain node.
[0073] Among them, at least one node resource information is used to indicate the ability of the blockchain node to process transactions. Optionally, at least one node resource information includes but is not limited to memory information, CPU information and / or disk information. CPU information includes the number of CPU cores and / or CPU frequency. The transaction pool capacity is used to indicate the maximum number of transactions that the transaction pool can store, that is, the number of transactions that the transaction pool can store generally does not exceed the transaction pool capacity. Optionally, a blockchain node generally corresponds to one or more transaction pools.
[0074] Specifically, transactions generally need to be stored in a transaction pool before being uploaded to the chain.
[0075] It should be noted that the transaction mentioned in this embodiment may be an actual business transaction, such as "invoicing" and other actual business transactions, and is not limited here.
[0076] S220. Determine a target pressure balancing strategy for the blockchain system based on the target system information.
[0077] Among them, the target pressure balance strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period.
[0078] Specifically, the more transactions in the corresponding transaction pool, the more transactions the blockchain node needs to process. The transaction pool capacity affects the maximum number of transactions that can be stored in the transaction pool, and the ability of the blockchain to process transactions affects the digestion of the current number of transactions in the transaction pool. The target pressure balancing strategy in this embodiment is determined based on at least two types of information, such as at least one node resource information of each blockchain and the transaction pool capacity of the transaction pool corresponding to each blockchain node. That is, the determined target pressure balancing strategy at least takes into account the ability of the blockchain node to process transactions and the maximum number that can be stored in the transaction pool, taking into account the load capacity of the blockchain node and the risk of transaction loss.
[0079] S230. Adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balance strategy.
[0080] In this embodiment, generally speaking, the stronger the ability of a blockchain node to process transactions and the larger the transaction pool capacity of the corresponding transaction pool, the greater the number of transactions distributed to the blockchain node within a preset time period.
[0081] Specifically, in the blockchain system, the problem that pressure balancing needs to solve is how to distribute transactions evenly, including but not limited to distributing transaction requests and block packaging tasks, so that the resource utilization of each blockchain node is relatively balanced, thereby improving the performance and reliability of the entire blockchain system.
[0082] The technical solution of this embodiment determines the target pressure balancing strategy of the blockchain system through the target system information of the blockchain system, and then adjusts the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy. The target system information includes at least one node resource information of each blockchain node and the transaction pool capacity of the transaction pool corresponding to each blockchain node. The node resource information can reflect the ability of the blockchain node to process transactions, and the transaction pool capacity can reflect the maximum number of transactions that the transaction pool corresponding to the blockchain node can accommodate. That is, the generated target pressure balancing strategy takes into account at least two factors, such as the ability of each blockchain node to process transactions and the maximum number of transactions that the transaction pool corresponding to the blockchain node can accommodate. This avoids the risk of transaction loss caused by only using the ability of each blockchain node to process transactions in related technologies to balance pressure without considering the transaction pool capacity of the transaction pool, thereby achieving the reduction of the risk of transaction loss while maintaining the throughput of the blockchain system, improving the TPS pressure balancing effect of the blockchain system, and thus improving the CTPS (confirmed transactions per second, Confirmed Transactions Per Second) performance of the blockchain system. In addition,
[0083] It should be noted that, in a possible implementation method, a predetermined mapping relationship can be used to determine the target pressure balance strategy of the blockchain system based on the target system information, and the number of transactions distributed to the transaction pool corresponding to each blockchain node can be adjusted according to the target pressure balance strategy.
[0084] In this embodiment, the mapping relationship may be a mapping between predetermined system information and a pressure balancing strategy, and the target pressure balancing strategy of the blockchain system may be directly determined based on the mapping relationship and the target system information.
[0085] In another possible implementation, during the operation of the blockchain system, the pressure balance of the blockchain system can be dynamically adjusted continuously, thereby dynamically maintaining the pressure balance effect of the blockchain system.
[0086] The following embodiment describes a solution for dynamically adjusting the pressure balance of a blockchain system based on any of the above embodiments.
[0087] In a possible implementation, a target pressure balancing strategy of a blockchain system is determined based on target system information, including:
[0088] Perform pressure scheduling based on target system information polling to obtain a target pressure balancing strategy corresponding to each pressure scheduling;
[0089] The number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy, including:
[0090] For each pressure scheduling process, the target pressure balance strategy is obtained, and the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy.
[0091] See also Figure 3 , Figure 3 This is a flow chart of another pressure balancing method of a blockchain system provided in an embodiment of the present application. Figure 3 The pressure balancing method of the blockchain system shown includes:
[0092] S310. Obtain target system information of the blockchain system, where the target system information includes at least one item of node resource information of each blockchain node and a transaction pool capacity of a transaction pool corresponding to each blockchain node.
[0093] S320, performing pressure scheduling processing based on target system information polling to obtain a target pressure balancing strategy corresponding to each pressure scheduling processing.
[0094] In this embodiment, the pressure scheduling process is executed in round-robin, that is, the pressure scheduling process is executed multiple times, and each pressure scheduling process can obtain the corresponding target pressure balancing strategy. Therefore, it can be known that the target pressure balancing strategy is dynamically adjusted.
[0095] The target pressure balance strategy includes a pressure test value for each blockchain node, and the pressure test value is used to indicate the number of transactions distributed to the transaction pool corresponding to the blockchain node per unit time. The target pressure balance strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period, and the preset time period may be an idle time period between two adjacent pressure scheduling processes. Generally speaking, the number of transactions distributed per unit time period calculated by the number of transactions distributed to the transaction pool corresponding to the blockchain node within the preset time period will not exceed the number of transactions distributed per unit time indicated by the pressure test value corresponding to the blockchain node.
[0096] S330. For each pressure scheduling process, the target pressure balancing strategy is obtained, and the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balancing strategy.
[0097] In this embodiment, each pressure scheduling process may obtain a new target pressure balance strategy. Then, each time a new target pressure balance strategy is obtained, the transaction pool corresponding to each blockchain node can be adjusted according to the latest target pressure balance strategy.
[0098] It can be understood that the relevant description of S310-S330 can refer to the description of any of the above embodiments, and will not be repeated here.
[0099] The technical solution of this embodiment obtains the target system information of the blockchain system, performs pressure scheduling processing based on the target system information, and obtains the target pressure balancing strategy corresponding to each pressure scheduling processing. The target pressure balancing strategy obtained by each pressure scheduling processing is used to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy. Since the pressure scheduling processing is performed by polling, a new target pressure balancing strategy is obtained each time the pressure scheduling processing is performed. The number of transactions distributed to the transaction pool corresponding to each blockchain node can be adjusted according to the latest target pressure balancing strategy. The load pressure fluctuations of the blockchain system caused by network delays and other reasons can be adaptively adjusted, thereby further improving the pressure balancing effect.
[0100] It should be noted that the duration of adjusting the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balance strategy obtained by the N-1th pressure scheduling process can be set as needed. For example, the duration can end when the Nth pressure scheduling process starts, or it can end after the target pressure balance strategy corresponding to the Nth pressure scheduling process is obtained, which is not limited here.
[0101] It is understandable that each time a pressure scheduling process is executed, a certain amount of machine resources are consumed. If the time interval of the pressure scheduling process is too small, it will cause a large pressure on the machine resources. If the time interval of the pressure scheduling process is too large, it may not be possible to balance the pressure in time, resulting in reduced stability, efficiency and reliability of the blockchain system.
[0102] Therefore, how to determine the interval time of pressure scheduling treatment is also very important.
[0103] In a possible implementation, the first scheduling time interval is positively correlated with the second scheduling time interval and the third scheduling time interval, the first scheduling time interval is the time interval between the M+1th pressure scheduling process and the Mth pressure scheduling process, the second scheduling time interval is the time interval between the Mth pressure scheduling process and the M-1th pressure scheduling process, and the third scheduling time interval is the time interval between the M-1th pressure scheduling process and the M-2th pressure scheduling process;
[0104] Wherein, M is an integer not less than 3.
[0105] In this embodiment, after the Mth pressure scheduling process is executed, the M+1th pressure scheduling process is executed after a first scheduling time interval.
[0106] Optionally, the first scheduling time interval is the sum of the second scheduling time interval and the third scheduling time interval.
[0107] In this embodiment, by dynamically adjusting the time interval of detection and scheduling tasks, the machine resources can be fully utilized as much as possible to improve the performance and efficiency of the system while ensuring the stability of the system. Specifically, when the load of the blockchain system is light, the time interval of detection and scheduling tasks can be gradually increased to reduce the impact on system performance; when the load of the blockchain system is heavy, the time interval of detection and scheduling tasks can be gradually shortened to timely discover and deal with system resource bottlenecks and ensure the stable operation of the blockchain system. When the time interval reaches a certain value (for example, 3 seconds), the timer is reset and the rotation usage is restarted.
[0108] The following embodiments further illustrate how to perform polling pressure scheduling processing based on any of the above embodiments.
[0109] In a possible implementation, the first pressure scheduling process includes:
[0110] A stress test value of each blockchain node is determined based on at least one item of node resource information of each blockchain node.
[0111] In this embodiment, the stress test value of each blockchain node obtained by the first stress scheduling process can be understood as the initial stress test value. First, the number of transactions distributed to the corresponding transaction pool of each blockchain node is adjusted with the initial stress test value. Then, in the subsequent stress scheduling process, the current stress scheduling process can adaptively adjust the target load balancing strategy based on the pressure balancing situation of the target pressure balancing strategy obtained by the previous stress scheduling process.
[0112] It should be noted that, generally speaking, the stronger the blockchain node's ability to process transactions, the greater the stress test value obtained by the first stress scheduling process.
[0113] In another possible implementation, an initial stress test value may be set based on experience.
[0114] The technical solution of this embodiment determines the stress test value of each blockchain node based on at least one item of node resource information of each blockchain node. That is, the startup of the stress scheduling processing of the blockchain system refers to the ability of each blockchain node to process transactions, thereby ensuring the stability of the blockchain system when the stress scheduling processing is started.
[0115] In one possible implementation, determining a stress test value of each blockchain node based on at least one item of node resource information of each blockchain node includes:
[0116] Determine the transaction processing capability of each blockchain node based on at least one item of node resource information of each blockchain node;
[0117] Based on the transaction processing capacity of each blockchain node, determine the total transaction processing capacity of at least two blockchain nodes, where the total transaction processing capacity is positively correlated with the transaction processing capacity of each blockchain node;
[0118] Determine the capacity ratio of the transaction processing capacity of each blockchain node to the total transaction processing capacity, and determine the stress test value of each blockchain node based on the product of the capacity ratio corresponding to each blockchain node and the block capacity of the blockchain system.
[0119] Among them, the block capacity is limited to the number of bytes stored in each block, which can be understood as limiting the number of transactions that each block can accommodate.
[0120] In this embodiment, at least one item including the number of CPU cores is used as an example for illustration.
[0121] In the blockchain system, suppose there are n nodes, the number of CPU cores of the machine where each node is located is m_n (the number of CPU cores of each node is uncertain and may be inconsistent), and the block capacity obtained from the chain is c. The total number of cores on the chain is m_total, that is, m_total = m_1 + m_2 + ... + m_n. Therefore, the proportion of the number of cores of each node is m_n / m_total. According to this rule formula:
[0122] The pressure test value obtained by the first pressure scheduling process = c*(m_n / m_total).
[0123] It can be understood that if the node resource information of the blockchain node is at least two items, the at least two items can be normalized, and the transaction processing capacity of the blockchain node can be determined based on the result of the normalization.
[0124] The above embodiment describes the method of the first pressure scheduling process. The following embodiment describes the second and subsequent pressure scheduling processes based on any of the above embodiments.
[0125] In a possible implementation, the Nth pressure scheduling process includes:
[0126] Obtain the N-1th stress test result of each blockchain node. The N-1th stress test result is obtained when the transaction is distributed to each blockchain node using the target stress balance strategy corresponding to the N-1th stress scheduling process;
[0127] If the N-1th stress test result of any blockchain node meets the preset stress adjustment condition, the stress test value of the satisfied blockchain node is adjusted;
[0128] Wherein, N is an integer not less than 2.
[0129] Among them, the N-1 stress test result may refer to the result that can reflect the stress balance situation of the target stress balance strategy corresponding to the N-1 stress scheduling process. In this embodiment, the stress test value of each blockchain node determined by the N-1 stress scheduling process is determined based on the N-1 stress test result, that is, the target stress balance strategy corresponding to the N-1 stress scheduling process is determined based on the N-1 stress test result, that is, the current stress scheduling process is related to the stress balance result of the previous stress scheduling process.
[0130] It can be understood that in this embodiment, if the N-1th stress test results of each blockchain node do not meet the pressure adjustment conditions, the stress test value of each blockchain node can be kept unchanged, and the target pressure balance strategy corresponding to the Nth pressure scheduling process can be consistent with the target pressure balance strategy corresponding to the N-1th pressure scheduling process.
[0131] The technical solution of this embodiment obtains the N-1th stress test result of each blockchain node. If the N-1th stress test result of any blockchain node meets the preset pressure adjustment condition, the stress test value of the satisfied blockchain node is adjusted; if the N-1th stress test result of each blockchain node does not meet the pressure adjustment condition, the stress test value of each blockchain node can be kept unchanged, and the target pressure balancing strategy can be dynamically and adaptively adjusted, thereby improving the stability and reliability of the pressure balancing of the blockchain system.
[0132] In a possible implementation, the stress test result includes the current transaction quantity of the corresponding transaction pool;
[0133] Pressure regulation conditions include:
[0134] The current transaction quantity of the corresponding transaction pool is outside the threshold interval formed by a preset first target transaction quantity threshold and a preset second target transaction quantity threshold, the first target transaction quantity threshold is greater than or equal to the first target transaction quantity, the second target transaction quantity threshold is less than or equal to the corresponding second target quantity, and the first target transaction quantity threshold is less than the second target transaction quantity threshold;
[0135] The first target transaction number is determined based on the block capacity of the blockchain system, and the second target transaction number is determined based on the transaction pool capacity corresponding to the blockchain node. The first target transaction number is smaller than the second target transaction number.
[0136] Generally speaking, the more transactions in the corresponding transaction pool, the more transactions the blockchain node needs to process, and the greater the load on the blockchain node. If the current number of transactions in the corresponding transaction pool is within the threshold range, it means that the stress test value of the blockchain node is a relatively appropriate value, taking into account the ability of the blockchain node to process transactions and the risk of losing transactions. Therefore, the stress test value of the blockchain node can remain unchanged at this time. If the current number of transactions in the corresponding transaction pool is outside the threshold range, it means that the stress test value at this time is either too high, with the risk of transaction loss; or the stress test value is too low, with the problem of poor TPS caused by not making good use of the ability of the blockchain node to process transactions. Therefore, it is necessary to adjust the stress test value of the blockchain node so that the number of transactions in the transaction pool corresponding to the blockchain node is maintained within the threshold range as much as possible, thereby taking into account high TPS and reducing the risk of transaction loss.
[0137] It should be noted that the stress test values of blockchain nodes that are adjusted to meet the requirements include:
[0138] If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is less than the first target transaction quantity threshold, then the stress test value of the satisfied blockchain node is increased; and / or,
[0139] If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is greater than the second target transaction quantity threshold, the stress test value of the satisfied blockchain node is adjusted to a value less than the preset stress test value threshold.
[0140] In this embodiment, if the current number of transactions in the transaction pool corresponding to the blockchain node whose stress test result meets the stress adjustment condition is less than the first target transaction number threshold, it means that when the transaction is distributed to the transaction pool corresponding to the blockchain node with the current stress test value, the transaction processing capacity of the blockchain node is still relatively large, so the stress test value of the blockchain node can be increased. If the current number of transactions in the transaction pool corresponding to the blockchain node whose stress test result meets the stress adjustment condition is greater than the second target transaction number threshold, it means that when the blockchain node distributes transactions with the current stress test, when the transaction is distributed to the transaction pool corresponding to the blockchain node with the current stress test value, the transaction processing capacity of the blockchain node is used more, and the remaining capacity is less, and the blockchain node has a greater risk of losing transactions, so it is necessary to adjust the stress test value of the blockchain node that meets the stress test to a value less than the preset stress test value threshold, so that the transaction pool corresponding to the blockchain node no longer receives new transactions or receives a very small part of transactions.
[0141] In one possible implementation, the first target transaction quantity is linearly positively correlated with a first product result corresponding to the blockchain node, and the first product result is the product of the block capacity of the blockchain system and a preset capacity multiplication factor, and the capacity multiplication factor is a value greater than 1.
[0142] In this embodiment, the first target transaction quantity can be understood as the valley value of the transaction pool capacity, that is, the minimum transaction quantity received per unit time.
[0143] The transaction pool capacity valley value can be set according to the actual situation of the blockchain. Generally speaking, the capacity multiplication factor can be set to a reasonable value, such as 1.75. Therefore, the transaction pool capacity valley value can be calculated by the following formula:
[0144] The transaction pool capacity valley = block capacity * capacity multiplication factor.
[0145] In one possible implementation, the second target transaction quantity corresponding to the blockchain node is linearly positively correlated with the second product result corresponding to the blockchain node, the second product result is the product of the transaction pool capacity corresponding to the blockchain node and the first difference, and the first difference is positively correlated with the total number of nodes of at least two blockchain nodes.
[0146] In this embodiment, the second target transaction number can be understood as the peak capacity of the transaction pool, that is, the maximum number of transactions received per unit time. Optionally, the second target transaction number is less than the transaction pool capacity. By setting the second target transaction number to be less than the transaction pool capacity, a little storage space can be left for the transaction pool, further reducing the risk of transaction loss.
[0147] In the blockchain system, the maximum capacity of the transaction pool is a key indicator. An overly large transaction pool may lead to a bottleneck in machine resources, which in turn affects the operating efficiency of the entire blockchain system. In order to avoid this situation, it is necessary to set an upper limit for the transaction pool, that is, the peak capacity of the transaction pool. This peak value can be a function of the maximum capacity of the transaction pool and the total number of nodes. The peak capacity of the transaction pool corresponding to each blockchain node can be calculated using the following formula:
[0148] Peak transaction pool capacity = transaction pool capacity * (1-1 / total number of nodes).
[0149] In the above embodiments, it is introduced that whether to adjust the stress test value can be confirmed by the current transaction number. However, in some cases of the examples, although the current transaction number of the corresponding transaction pool can reflect the remaining transaction processing capacity of the blockchain node to a certain extent, there are still inaccuracies.
[0150] In a possible implementation, the stress test result also includes a current resource utilization rate of at least one node resource;
[0151] Pressure regulation conditions also include:
[0152] The current resource utilization of any node resource is greater than the preset utilization threshold.
[0153] In this embodiment, if the current resource utilization of any node resource of the blockchain node is greater than the preset utilization threshold, the stress test value of the blockchain node can be reduced. Optionally, if the current resource utilization of any node resource of the blockchain node is less than the utilization threshold, and the current transaction number of the transaction pool corresponding to the blockchain node is less than the first target transaction number threshold, the stress test value of the blockchain node is increased.
[0154] The technical solution of this embodiment can improve the adjustment accuracy of the stress test value and further enhance the pressure balancing effect by combining the current resource utilization rate of at least one node resource of the blockchain node to adjust the stress test value.
[0155] For example, the calculation method of the first stress test value, the trading pool capacity valley value, and the trading pool capacity peak value can be implemented by the following code segment:
[0156] Code Snippet 1:
[0157] #Calculate the initial value of blockchain pressure
[0158] def calc_pressure_init(block_capacity, node_cores):
[0159] total_cores = sum(node_cores)
[0160] node_ratio=[m / total_cores for m in node_cores]
[0161] pressure_init=block_capacity*max(node_ratio)
[0162] return pressure_init
[0163] #Calculate the valley value of the transaction pool capacity
[0164] def calc_txpool_min(block_capacity):
[0165] txpool_min=block_capacity*1.75
[0166] return txpool_min
[0167] #Calculate the peak capacity of the transaction pool
[0168] def calc_txpool_max(txpool_total_capacity, node_count):
[0169] txpool_max=txpool_total_capacity*(1-1 / node_count)
[0170] return txpool_max
[0171] #test
[0172] node_cores=[8, 16, 32, 64]
[0173] block_capacity = 1000
[0174] txpool_total_capacity=10000
[0175] node_count = len(node_cores)
[0176] pressure_init=calc_pressure_init(block_capacity,node_cores)txpool_min=calc_txpool_min(block_capacity)
[0177] txpool_max = calc_txpool_max (txpool_total_capacity, node_count) print (f "The initial pressure test value of the blockchain is: {pressure_init}")
[0178] print(f"The transaction pool capacity valley is: {txpool_min}")
[0179] print(f"The peak transaction pool capacity is: {txpool_max}").
[0180] Code Snippet 2:
[0181] import threading
[0182] import time class PressureTask:
[0183] def__init__(self, pressure, duration):
[0184] self.pressure=pressure#pressure test value
[0185] self.duration = duration #pressure duration
[0186] def run(self):
[0187] print("Start executing the pressure test task, the pressure test value is: {}, the duration is: {} seconds".format(self.pressure, self.duration))
[0188] #Execute stress test task code
[0189] time.sleep(self.duration)
[0190] print("Stress test task completed")
[0191] class PressureScheduler:
[0192] def__init__(self, block_capacity, node_cores, node_count):
[0193] self.block_capacity = block_capacity #block capacity
[0194] self.node_cores = node_cores # Node memory core number list
[0195] self.node_count = node_count #Total number of nodes
[0196] self.fibonacci = [1, 1] #Fibonacci sequence
[0197] self.current_pressure=0#Current pressure test value
[0198] self.pressure_task=None#Current pressure test task
[0199] self.max_pool_capacity = 1000 # Maximum capacity of the transaction pool
[0200] self.pool_capacity = 0 #Current transaction pool capacity (current number of transactions in the transaction pool)
[0201] def create_pressure_task(self, pressure, duration).
[0202] The following embodiment, based on any of the above embodiments, describes how to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balance strategy.
[0203] In one possible implementation, the computer device of this embodiment can directly adjust the number of transactions distributed by the transaction pool corresponding to each blockchain node based on the target pressure balance strategy.
[0204] In this embodiment, there is a certain connection relationship between the computer device and the transaction pool of the blockchain system.
[0205] In another possible implementation, the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy, including:
[0206] The number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balance strategy, including:
[0207] Based on the target pressure balancing strategy, a pressure testing task corresponding to at least one target blockchain node is sent to the pressure balancing control node. The pressure testing task includes a test address and a pressure testing value. The pressure balancing control node is used to distribute transactions to the transaction pool pointed to by the test address in the pressure testing task based on the pressure testing value in the pressure testing task.
[0208] In this embodiment, the pressure balance control node may be a node that has a certain connection relationship with the transaction pool of the blockchain system and can distribute transactions to the transaction pool. Optionally, the pressure balance control node may include a press or a press cluster, and the press cluster may include at least two presses.
[0209] It should be noted that the pressure balance control node can be a node in the blockchain system or a node independent of the blockchain system, which is not limited here.
[0210] Generally speaking, the first number of transactions distributed by the stress machine to the transaction pool corresponding to the blockchain node per unit time is less than or equal to the second number of transactions distributed per unit time indicated by the stress test value of the blockchain node.
[0211] In one possible implementation, at least two presses included in the press cluster may correspond one-to-one to at least two transaction pools, that is, each press is responsible for distributing transactions to one of the transaction pools, which can improve the stability and reliability of distributing transactions to the blockchain system.
[0212] Optionally, at least one target blockchain node in this embodiment may be all blockchain nodes, that is, the stress test tasks corresponding to each blockchain node will be sent to the pressure balance control node; at least one target blockchain node in this embodiment may also be some blockchain nodes, that is, the stress test tasks corresponding to some blockchain nodes will be sent to the pressure balance control node, and there is no limitation here.
[0213] In one possible implementation, the stress test value of the target blockchain node is greater than a preset stress test value threshold.
[0214] In this embodiment, the computer device generates a stress test task corresponding to at least one blockchain node whose stress test value is greater than a preset stress test value threshold, and sends at least one stress test task to the pressure balance control node.
[0215] It can be understood that by sending a stress test task corresponding to at least one blockchain node whose stress test value is greater than the preset stress test value threshold, and not sending the corresponding stress test task to the blockchain node whose stress test value is less than the preset stress test value threshold, the network delay requirements between the computer device and the pressure balancing control node can be reduced, thereby improving the stability, efficiency and reliability of the blockchain system pressure balancing.
[0216] Optionally, each stress test subtask has a unique task identifier (ID). If the stress test value of the blockchain node changes, the stress test value of the stress test task corresponding to the blockchain node is updated based on the correspondence between the node identifier of the blockchain node and the task ID, and sent to the pressure balance control node.
[0217] See also Figure 4 , Figure 4 FIG. 1 is a flow chart of a pressure scheduling based on a pressure test task provided by an embodiment of the present application. Figure 4 As shown:
[0218] a. Create a stress test task: This step involves creating a task queue and assigning a unique task ID to each task. The task queue stores the stress test tasks to be executed. Each stress test task contains information such as the test address and test parameters required for stress testing. The test parameters may include but are not limited to stress test values.
[0219] b. Determine whether to increase pressure: This step is the core of the entire scheduling layer. It is necessary to dynamically adjust the intensity of the stress test according to the current system resource situation, transaction pool capacity and other factors. If the current system resources are sufficient, if the transaction volume in the transaction pool corresponding to the blockchain node does not exceed the transaction pool capacity valley value, the pressure can be increased. When the transaction volume in the transaction pool corresponding to the blockchain node exceeds the transaction pool capacity peak value, the blockchain node stops all pressure. When the actual transaction volume of the transaction pool is between the transaction capacity valley value and the transaction capacity peak value, there is no need to adjust the pressure.
[0220] c. This step involves removing completed tasks from the task queue and terminating the stress test task that is being executed. The task to be stopped needs to be uniquely identified based on the task ID.
[0221] See also Figure 5 and Figure 6 . Figure 5 It is a schematic diagram of a framework of a technical implementation provided in an embodiment of the present application. Figure 6 This embodiment of the present application provides a method based on Figure 6 Schematic diagram of the flow chart of pressure equalization of the framework.
[0222] like Figure 5 The framework shown schematically includes detection layer, algorithm layer, scheduling layer and pressure layer.
[0223] Detection layer: This layer is mainly responsible for detecting at least one node resource information of the machine where the node is located, including CPU, memory, disk, etc., as well as node information on the blockchain, such as transaction pool capacity, block capacity, etc. This information can be collected, processed and analyzed through various detection tools and application programming interfaces (APIs) to provide basic data for subsequent pressure calculations and adjustments.
[0224] Algorithm layer: This layer is mainly responsible for calculating the stress test value of each node based on the data provided by the detection layer, and adjusting the pressure balance according to the stress test value. The algorithm of this layer can be adopted in many ways, such as adaptive algorithm based on the number of node cores and transaction pool capacity, algorithm based on node load and transaction volume, which are not limited here.
[0225] Scheduling layer: This layer is mainly responsible for converting the stress test value calculated by the algorithm layer into an actual stress balancing strategy, including adjusting the node stress, optimizing the node stress distribution, etc. It implements the communication protocol between different nodes, the task allocation and stress balancing implementation methods, as well as high availability and fault recovery.
[0226] Pressure layer: This layer is the top layer of the entire framework, including blockchain applications and application interfaces. The application layer needs to interact with the scheduling layer to obtain node load status, transaction information, etc. in a timely manner, and apply the pressure balancing strategy of the scheduling layer to the blockchain application to achieve pressure balancing of the entire blockchain system.
[0227] like Figure 6 The process shown includes:
[0228] S601, initialization of the pressure layer: When the pressure layer is initialized, the system will establish the basic data structure of the pressure test related information, including but not limited to pressure test tasks, detection tasks, scheduling tasks, etc. The algorithm layer obtains chain information from the detection layer, such as the transaction pool capacity of each node, block capacity and other information.
[0229] S602, detection layer detection: The detection layer will detect at least one node resource information and chain information of each blockchain node in the blockchain system, and collect and store the data in real time.
[0230] S603, the algorithm layer obtains resource information and chain information of each node, wherein the chain information includes transaction pool capacity and block capacity.
[0231] S604, Algorithm layer calculation: The algorithm layer obtains chain information from the detection layer, such as node transaction pool capacity, block capacity, etc., and uses the pressure balance algorithm to calculate the initial pressure test value to ensure system performance and reliability. The constructed pressure test task is sent to the blockchain.
[0232] S605, stress test task construction: Based on the initial stress value calculated in S630, the stress layer will construct a stress test task for execution on the chain.
[0233] S606, stress test task execution: send the constructed stress test task to the blockchain and execute it.
[0234] S607. Check chain resource status: During the execution of the stress test task, the detection layer will continuously check the node resource status of the blockchain node to ensure the availability and stability of system resources.
[0235] S608, transaction pool detection: read node information from the detection layer and obtain the transaction volume of the transaction pool corresponding to each blockchain node. The system will dynamically adjust the stress test task based on the transaction volume data in the transaction pool of each node to ensure that the number of transactions in the transaction pool does not exceed the preset capacity (peak capacity of the transaction pool).
[0236] S609: Determine whether pressure needs to be increased.
[0237] S610, stress test task adjustment: When the system detects that the number of transactions in the trading pool has reached the maximum threshold, the system will automatically stop the stress test task and make dynamic adjustments.
[0238] In this embodiment, for each blockchain node, the node resource information and transaction pool capacity are combined to dynamically allocate stress test tasks to ensure the stability and efficiency of the system. At the same time, the algorithm also uses the Fibonacci sequence algorithm to adjust the resource detection frequency, reduce system resource waste, and improve system performance. The application value of this technology lies in improving the throughput, stability and reliability of the blockchain system, providing strong support for the promotion and development of blockchain applications.
[0239] The present application embodiment provides a pressure balancing device for a blockchain system, such as Figure 7 As shown, the pressure balancing device 700 of the blockchain system may include: an information acquisition module 710, a strategy determination module 720 and a pressure balancing module 730, wherein:
[0240] The information acquisition module 710 is used to acquire target system information of the blockchain system. The target system information includes at least one item of node resource information of each blockchain node and the transaction pool capacity of the transaction pool corresponding to each blockchain node. The at least one item of node resource information is used to indicate the ability of the blockchain node to process transactions. The transaction pool capacity is used to indicate the maximum number of transactions that can be stored in the transaction pool.
[0241] A strategy determination module 720 is used to determine a target pressure balance strategy of the blockchain system based on the target system information, where the target pressure balance strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period;
[0242] The pressure balancing module 730 is used to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy.
[0243] In a possible implementation, the policy determination module 720 is used to:
[0244] Perform pressure scheduling based on target system information polling to obtain a target pressure balancing strategy corresponding to each pressure scheduling, wherein the target pressure balancing strategy includes a pressure test value of each blockchain node, and the pressure test value is used to indicate the number of transactions distributed to the transaction pool corresponding to the blockchain node in unit time;
[0245] The pressure balancing module 730 is used to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy obtained for each pressure scheduling process.
[0246] In one possible implementation, the policy determination module 720 is used to determine the stress test value of each blockchain node based on at least one item of node resource information of each blockchain node in the case of the first stress scheduling process.
[0247] In one possible implementation, the policy determination module 720 is used to determine the transaction processing capability of each blockchain node based on at least one item of node resource information of each blockchain node;
[0248] Based on the transaction processing capacity of each blockchain node, determine the total transaction processing capacity of at least two blockchain nodes, where the total transaction processing capacity is positively correlated with the transaction processing capacity of each blockchain node;
[0249] Determine the capacity ratio of the transaction processing capacity of each blockchain node to the total transaction processing capacity, and determine the stress test value of each blockchain node based on the product of the capacity ratio corresponding to each blockchain node and the block capacity of the blockchain system.
[0250] In a possible implementation, the strategy determination module 720 is used to obtain the N-1th stress test result of each blockchain node in the case of the Nth stress scheduling process, where the N-1th stress test result is obtained when the transaction is distributed to each blockchain node using the target stress balance strategy corresponding to the N-1th stress scheduling process;
[0251] If the N-1th stress test result of any blockchain node meets the preset stress adjustment condition, the stress test value of the satisfied blockchain node is adjusted;
[0252] Wherein, N is an integer not less than 2.
[0253] In a possible implementation, the stress test result includes the current transaction quantity of the corresponding transaction pool;
[0254] Pressure regulation conditions include:
[0255] The current transaction quantity of the corresponding transaction pool is outside the threshold interval formed by a preset first target transaction quantity threshold and a preset second target transaction quantity threshold, the first target transaction quantity threshold is greater than or equal to the first target transaction quantity, the second target transaction quantity threshold is less than or equal to the corresponding second target quantity, and the first target transaction quantity threshold is less than the second target transaction quantity threshold;
[0256] Among them, the first target transaction number is determined based on the block capacity of the blockchain system, and the second target transaction number is determined based on the transaction pool capacity corresponding to the blockchain node.
[0257] In a possible implementation, the stress test result also includes a current resource utilization rate of at least one node resource;
[0258] Pressure regulation conditions also include:
[0259] The current resource utilization of any node resource is greater than the preset utilization threshold.
[0260] In a possible implementation, the first target transaction quantity is linearly positively correlated with a first product result corresponding to the blockchain node, the first product result is the product of the block capacity of the blockchain system and a preset capacity multiplication factor, and the capacity multiplication factor is a value greater than 1; and / or,
[0261] The second target transaction quantity corresponding to the blockchain node is linearly positively correlated with the second product result corresponding to the blockchain node. The second product result is the product of the transaction pool capacity corresponding to the blockchain node and the first difference. The first difference is positively correlated with the total number of nodes of at least two blockchain nodes.
[0262] In one possible implementation, the strategy determination module 720 is used to increase the stress test value of the satisfied blockchain node if the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is less than the first target transaction quantity threshold; and / or,
[0263] If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is greater than the second target transaction quantity threshold, the stress test value of the satisfied blockchain node is adjusted to a value less than the preset stress test value threshold.
[0264] In a possible implementation, the pressure balancing module 730 is used to send a pressure test task corresponding to at least one target blockchain node to the pressure balancing control node based on the target pressure balancing strategy, the pressure test task includes a test address and a pressure test value, and the pressure balancing control node is used to distribute transactions to the transaction pool pointed to by the test address in the pressure test task based on the pressure test value in the pressure test task;
[0265] Among them, the stress test value of the target blockchain node is greater than the preset stress test value threshold.
[0266] In a possible implementation, the first scheduling time interval is positively correlated with the second scheduling time interval and the third scheduling time interval, the first scheduling time interval is the time interval between the M+1th pressure scheduling process and the Mth pressure scheduling process, the second scheduling time interval is the time interval between the Mth pressure scheduling process and the M-1th pressure scheduling process, and the third scheduling time interval is the time interval between the M-1th pressure scheduling process and the M-2th pressure scheduling process;
[0267] Wherein, M is an integer not less than 3.
[0268] The pressure balancing device of the blockchain system of this embodiment can execute the steps of the pressure balancing method of the blockchain system shown in the previous embodiments of this application. The implementation principle is similar and will not be repeated here.
[0269] The beneficial effects of the pressure equalization device of the blockchain system can be found in the description of the pressure equalization method of the blockchain system in the previous text. The same applies to the effect description of the computer device, computer readable storage medium and computer program product below.
[0270] In an embodiment of the present application, a computer device is provided, including a memory, a processor, and a computer program stored in the memory, and the processor executes the above computer program to implement the steps of the method of any of the above embodiments.
[0271] In an alternative embodiment, a computer device is provided, such as Figure 8 As shown, Figure 8The computer device 8000 shown includes: a processor 8001 and a memory 8003. The processor 8001 and the memory 8003 are connected, such as through a bus 8002. Optionally, the computer device 8000 may also include a transceiver 8004, which may be used for data interaction between the computer device and other computer devices, such as data transmission and / or data reception. It should be noted that in actual applications, the transceiver 8004 is not limited to one, and the structure of the computer device 8000 does not constitute a limitation on the embodiments of the present application.
[0272] The processor 8001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array) or other programmable logic devices, transistor logic devices, hardware components or any combination thereof. It may implement or execute various exemplary logic blocks, modules and circuits described in conjunction with the disclosure of this application. The processor 8001 may also be a combination that implements computing functions, such as a combination of one or more microprocessors, a combination of a DSP and a microprocessor, etc.
[0273] The bus 8002 may include a path to transmit information between the above components. The bus 8002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus. The bus 8002 may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 8 Only one thick line is used in the diagram, but this does not mean that there is only one bus or only one type of bus.
[0274] The memory 8003 can be a ROM (Read Only Memory) or other types of static storage devices that can store static information and instructions, a RAM (Random Access Memory) or other types of dynamic storage devices that can store information and instructions, or an EEPROM (Electrically Erasable Programmable Read Only Memory), a CD-ROM (Compact Disc Read Only Memory) or other optical disk storage, optical disk storage (including compact discs, laser discs, optical discs, digital versatile discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium that can be used to carry or store computer programs and can be read by a computer, without limitation herein.
[0275] The memory 8003 is used to store the computer program for executing the embodiment of the present application, and the execution is controlled by the processor 8001. The processor 8001 is used to execute the computer program stored in the memory 8003 to implement the steps shown in the above method embodiment.
[0276] An embodiment of the present application provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps and corresponding contents of the aforementioned method embodiment can be implemented.
[0277] The embodiment of the present application also provides a computer program product, including a computer program, which can implement the steps and corresponding contents of the aforementioned method embodiment when executed by a processor.
[0278] It is to be understood that, although each operation step is indicated by arrows in the flowchart of the embodiment of the present application, the implementation order of these steps is not limited to the order indicated by the arrows. Unless clearly stated herein, in some implementation scenarios of the embodiment of the present application, the implementation steps in each flowchart can be performed in other orders according to demand. In addition, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on actual implementation scenarios. Some or all of these sub-steps or stages may be executed at the same time, and each sub-step or stage in these sub-steps or stages may also be executed at different times respectively. In different scenarios of execution time, the execution order of these sub-steps or stages may be flexibly configured according to demand, and the embodiment of the present application does not limit this.
[0279] The terms "first", "second", etc. in the claims, specification and drawings of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a process, method, system, product or electronic device that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or electronic devices. Mentioning "embodiment" in this article means that the specific features, structures or characteristics described in conjunction with the embodiment may be included in at least one embodiment of the present application. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments. The term "and / or" used in the present application specification and the attached claims refers to any combination of one or more of the associated listed items and all possible combinations, and includes these combinations.
[0280] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented by electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Professional and technical personnel may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0281] The above disclosure is only the preferred embodiment of the present application, which cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A pressure balancing method for a blockchain system, characterized in that: The blockchain system includes at least two blockchain nodes, and the method includes: Obtaining target system information of the blockchain system, the target system information including at least one item of node resource information of each blockchain node and a transaction pool capacity of a transaction pool corresponding to each blockchain node, the at least one item of node resource information being used to indicate a capability of the blockchain node to process transactions, and the transaction pool capacity being used to indicate a maximum number of transactions that can be stored in the transaction pool; Determine a target pressure balancing strategy of the blockchain system based on the target system information, where the target pressure balancing strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period; The number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balancing strategy.
2. The method according to claim 1, characterized in that The determining a target pressure balancing strategy of the blockchain system based on the target system information includes: Perform pressure scheduling processing based on the target system information polling to obtain a target pressure balancing strategy corresponding to each pressure scheduling processing, wherein the target pressure balancing strategy includes a pressure test value of each blockchain node, and the pressure test value is used to indicate the number of transactions distributed to the transaction pool corresponding to the blockchain node per unit time; The step of adjusting the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy includes: For each target pressure balancing strategy obtained by pressure scheduling processing, the number of transactions distributed to the transaction pool corresponding to each blockchain node is adjusted based on the target pressure balancing strategy.
3. The method according to claim 2, characterized in that The first pressure dispatch process includes: A stress test value of each blockchain node is determined based on at least one item of node resource information of each blockchain node.
4. The method according to claim 3, characterized in that The determining of the stress test value of each blockchain node based on at least one item of node resource information of each blockchain node includes: Determine the transaction processing capability of each blockchain node based on at least one item of node resource information of each blockchain node; Determining a total transaction processing capacity of the at least two blockchain nodes based on the transaction processing capacity of each blockchain node, wherein the total transaction processing capacity is positively correlated with the transaction processing capacity of each blockchain node; Determine the capacity ratio of the transaction processing capacity of each blockchain node to the total transaction processing capacity, and determine the stress test value of each blockchain node based on the product result between the capacity ratio corresponding to each blockchain node and the block capacity of the blockchain system.
5. The method according to any one of claims 2 to 4, characterized in that: The Nth pressure dispatch process includes: Obtaining the N-1th stress test result of each blockchain node, where the N-1th stress test result is obtained when distributing transactions to each blockchain node using a target stress balance strategy corresponding to the N-1th stress scheduling process; If the N-1th stress test result of any blockchain node meets the preset stress adjustment condition, the stress test value of the satisfied blockchain node is adjusted; Wherein, N is an integer not less than 2.
6. The method according to claim 5, characterized in that The stress test result includes the current transaction quantity of the corresponding transaction pool; The pressure adjustment conditions include: The current transaction quantity of the corresponding transaction pool is outside the threshold interval formed by a preset first target transaction quantity threshold and a preset second target transaction quantity threshold, the first target transaction quantity threshold is greater than or equal to the first target transaction quantity, the second target transaction quantity threshold is less than or equal to the corresponding second target quantity, and the first target transaction quantity threshold is less than the second target transaction quantity threshold; Among them, the first target transaction number is determined based on the block capacity of the blockchain system, and the second target transaction number is determined based on the transaction pool capacity corresponding to the blockchain node.
7. The method according to claim 6, characterized in that The stress test result also includes the current resource utilization rate of at least one node resource; The pressure adjustment conditions also include: The current resource utilization of any node resource is greater than the preset utilization threshold.
8. The method according to claim 6, characterized in that The first target transaction quantity is linearly positively correlated with a first product result corresponding to the blockchain node, the first product result is the product of the block capacity of the blockchain system and a preset capacity multiplication factor, and the capacity multiplication factor is a value greater than 1; and / or, The second target transaction quantity corresponding to the blockchain node is linearly positively correlated with the second product result corresponding to the blockchain node, and the second product result is the product of the transaction pool capacity corresponding to the blockchain node and the first difference, and the first difference is positively correlated with the total number of nodes of the at least two blockchain nodes.
9. The method according to claim 6, characterized in that The stress test value of the blockchain node satisfied by the adjustment includes: If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is less than the first target transaction quantity threshold, then increasing the stress test value of the satisfied blockchain node; and / or, If the current transaction quantity of the transaction pool corresponding to the satisfied blockchain node is greater than the second target transaction quantity threshold, the stress test value of the satisfied blockchain node is adjusted to a value less than the preset stress test value threshold.
10. The method according to claim 9, characterized in that The step of adjusting the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy includes: Sending a stress test task corresponding to at least one target blockchain node to the stress balance control node based on the target stress balance strategy, wherein the stress test task includes a test address and a stress test value, and the stress balance control node is used to distribute transactions to the transaction pool pointed to by the test address in the stress test task based on the stress test value in the stress test task; Among them, the stress test value of the target blockchain node is greater than the preset stress test value threshold.
11. The method according to claim 2, characterized in that The first scheduling time interval is positively correlated with the second scheduling time interval and the third scheduling time interval. The first scheduling time interval is the time interval between the M+1th pressure scheduling process and the Mth pressure scheduling process, the second scheduling time interval is the time interval between the Mth pressure scheduling process and the M-1th pressure scheduling process, and the third scheduling time interval is the time interval between the M-1th pressure scheduling process and the M-2th pressure scheduling process; Wherein, M is an integer not less than 3.
12. A pressure balancing device for a blockchain system, characterized in that: The blockchain system includes at least two blockchain nodes, and the device includes: An information acquisition module, used to acquire target system information of the blockchain system, wherein the target system information includes at least one item of node resource information of each blockchain node and a transaction pool capacity of a transaction pool corresponding to each blockchain node, wherein the at least one item of node resource information is used to indicate the ability of the blockchain node to process transactions, and the transaction pool capacity is used to indicate the maximum number of transactions that can be stored in the transaction pool; A strategy determination module, used to determine a target pressure balancing strategy of the blockchain system based on the target system information, wherein the target pressure balancing strategy is used to indicate the number of transactions distributed to the transaction pool corresponding to each blockchain node within a preset time period; The pressure balancing module is used to adjust the number of transactions distributed to the transaction pool corresponding to each blockchain node based on the target pressure balancing strategy.
13. A computer device comprising a memory, a processor and a computer program stored in the memory, characterized in that: The processor executes the computer program to implement the steps of the method according to any one of claims 1 to 11.
14. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
15. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 11 are implemented.
