Block chain test method and device and storage medium

By constructing the Markov chain transfer matrix and state space, combined with the balance test model, the problems of uneven distribution and centralization of computing power caused by the imbalance of node block production rate in small blockchains are solved, and the balanced detection and early warning of blockchain computing power are achieved.

CN120705043APending Publication Date: 2025-09-26PEKING UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510805169.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-17
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing technologies have failed to effectively address the imbalanced computing power distribution and centralization problems caused by the high block production rates of some nodes in small blockchains.

Method used

By constructing the transfer matrix and state space of the Markov chain, the block generation probability value of the node is determined, and the balance test model is used to detect the block generation balance of each node in the blockchain, identify the risk of computing power imbalance in advance and propose response plans.

Benefits of technology

It realizes the balance detection of the distribution of computing power of the blockchain, avoids the centralization problem caused by the imbalance of computing power, and improves the decentralization of the blockchain.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120705043A_ABST
    Figure CN120705043A_ABST
Patent Text Reader

Abstract

The invention discloses a block chain testing method and device and a storage medium, and belongs to the technical field of block chains. According to the invention, the block-out state of each node is preset according to the block-out sequence of each node in the block chain, and the transfer matrix and the state space of the Markov chain are constructed, so that the change rule of the block-out between the nodes can be captured by using the transfer matrix and the state space, and then the block-out probability value is determined. According to the method, the block-out probability distribution of each node can be obtained, and then the block-out balance corresponding to each node in the block chain can be determined according to the calculated block-out probability value by using the balance test model. According to the method, the out-of-block performance of a single node is considered, the out-of-block balance degree of the whole block chain is concerned, according to the tested out-of-block balance, it is known that the computing power of the block chain is about to be unbalanced or is unbalanced in advance, a corresponding coping scheme is put forward, and therefore the problem of centralization caused by the unbalanced computing power is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of blockchain technology, and particularly relates to a blockchain testing method, device, and storage medium. Background Art

[0002] Small blockchains typically employ a simplified block structure and storage method. To reduce computing resource consumption, they can employ a Proof-of-Work (PoW) consensus mechanism. Blockchain PoW is a consensus mechanism that expends computing resources to solve mathematical problems. Its core goal is to ensure network security, decentralization, and immutability of transactions. Although designed for decentralization, PoW can easily lead to the concentration of computing power in practice. This can lead to an imbalance in the distribution of computing power within a blockchain, contributing to centralization issues.

[0003] Currently, no effective solution has been proposed to the technical problems of imbalanced computing power distribution and centralization caused by the high block production rate of some nodes in the blockchain in the above-mentioned existing technologies. Summary of the Invention

[0004] The embodiments of the present application provide a blockchain testing method, device, and storage medium to at least solve the technical problems of imbalanced computing power distribution and centralization caused by the high block production rate of some nodes in the blockchain in the prior art.

[0005] According to one aspect of an embodiment of the present application, a blockchain testing method is provided, the steps of which include:

[0006] The Markov chain transition matrix and state space are constructed based on the pre-set block production status of each node in the blockchain, where the block production status is used to indicate the block production order of each node in the blockchain;

[0007] Generate the parameter values ​​of the transfer matrix based on the block samples of the preset period, where the block samples are used to indicate the nodes that produce blocks in the blockchain at different times;

[0008] The block generation probability value of each node corresponding to the state space is determined according to the parameter value of the transfer matrix and the state space; and the block generation balance corresponding to each node in the blockchain is determined according to the block generation probability value using the balance test model, where the block generation balance is used to indicate whether each node in the blockchain generates blocks in a balanced manner.

[0009] According to another aspect of an embodiment of the present application, a blockchain testing device is also provided, including: a construction module for constructing a transfer matrix and a state space of a Markov chain according to a preset block production status of each node in the blockchain, wherein the block production status is used to indicate the block production order of each node in the blockchain; a parameter value generation module for generating parameter values ​​of the transfer matrix according to block production samples of a preset period, wherein the block production samples are used to indicate the nodes of the blockchain that produce blocks at different times; a probability value determination module for determining the block production probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space; and a balance determination module for determining the block production balance corresponding to each node in the blockchain according to the block production probability value using a balance test model, wherein the block production balance is used to indicate whether each node of the blockchain produces blocks in a balanced manner.

[0010] According to another aspect of an embodiment of the present application, a blockchain testing device is also provided, including: a processor; and a memory, connected to the processor, for providing the processor with instructions for processing the following processing steps: constructing a transfer matrix and a state space of a Markov chain according to a preset block production status of each node in the blockchain, wherein the block production status is used to indicate the block production order of each node in the blockchain; generating parameter values ​​of the transfer matrix according to block production samples of a preset period, wherein the block production samples are used to indicate the nodes of the blockchain that produce blocks at different times; determining the block production probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space; and determining the block production balance corresponding to each node in the blockchain according to the block production probability value using a balance test model, wherein the block production balance is used to indicate whether each node of the blockchain produces blocks in a balanced manner.

[0011] According to another aspect of the embodiments of the present application, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.

[0012] In an embodiment of the present application, a test server pre-sets the block generation status of each node in the blockchain based on their block generation order and constructs a Markov chain transition matrix and state space. This allows the transition matrix and state space to capture the changing patterns of block generation between nodes. The test server then determines the block generation probability value, obtaining the block generation probability distribution for each node. Furthermore, this technical solution utilizes a balance testing model to determine the block generation balance corresponding to each node in the blockchain based on the calculated block generation probability values. This not only considers the block generation performance of individual nodes, but also the balance of block generation across the entire blockchain. Based on the tested block generation balance, it is possible to predict in advance whether the blockchain's computing power is about to or has already become unbalanced, and propose corresponding countermeasures to avoid the centralization problem caused by computing power imbalance. This solves the technical problem of imbalanced computing power distribution and centralization caused by the high block generation rates of some nodes in the blockchain, which exists in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS

[0013] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0014] Figure 1 is a hardware structure block diagram of a computing device for implementing the method according to embodiment 1 of the present application;

[0015] Figure 2 This is a schematic diagram of the blockchain testing method system according to Example 1 of the present application;

[0016] Figure 3 1 is a flowchart of the blockchain testing method according to the first aspect of Example 1 of the present application;

[0017] Figure 4 is a module schematic diagram of the balance test model according to the second aspect of Example 1 of the present application;

[0018] Figure 5 is a schematic diagram of a blockchain testing method and apparatus according to Example 2 of the present application; and

[0019] Figure 6 This is a schematic diagram of the blockchain testing method device described in Example 3 of the present application. DETAILED DESCRIPTION

[0020] In order to enable those skilled in the art to better understand the technical solutions of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work should fall within the scope of protection of this application.

[0021] It should be noted that the terms "first", "second", etc. in the specification and claims of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0022] Example 1

[0023] According to this embodiment, a method embodiment of a blockchain testing method is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0024] The method embodiment provided in this embodiment can be executed in a mobile terminal, a computer terminal, a server or a similar computing device. Figure 1 The following is a hardware structure diagram of a computing device for implementing a blockchain testing method. Figure 1 As shown, the computing device may include one or more processors (the processor may include but is not limited to a microprocessor MCU or a programmable logic device FPGA, etc.), a memory for storing data, and a transmission device for communication functions. In addition, it may also include: a display, an input / output interface (I / O interface), a universal serial bus (USB) port (which may be included as one of the ports of the I / O interface), a network interface, a power supply and / or a camera. It will be understood by those skilled in the art that Figure 1 The structure shown is only for illustration and does not limit the structure of the above electronic device. Figure 1 More or fewer components than shown, or with Figure 1 Different configurations shown.

[0025] It should be noted that the one or more processors and / or other data processing circuits described above may generally be referred to herein as "data processing circuitry." The data processing circuitry may be embodied in whole or in part as software, hardware, firmware, or any other combination thereof. In addition, the data processing circuitry may be a single, independent processing module, or may be incorporated in whole or in part into any of the other components of the computing device. As described in the embodiments of the present application, the data processing circuitry serves as a processor control (e.g., selection of a variable resistor terminal path connected to an interface).

[0026] The memory can be used to store software programs and modules for application software, such as the program instructions / data storage device corresponding to the blockchain testing method in the embodiments of this application. The processor executes the software programs and modules stored in the memory to perform various functional applications and data processing, thereby implementing the blockchain testing method for the aforementioned application. The memory can include high-speed random access memory (RAM) and non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some examples, the memory may further include memory located remotely from the processor, which can be connected to the computing device via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.

[0027] The transmission device is used to receive or send data via a network. Specific examples of the aforementioned network may include a wireless network provided by a communications provider of the computing device. In one embodiment, the transmission device includes a network interface controller (NIC), which can be connected to other network devices via a base station to enable communication with the Internet. In another embodiment, the transmission device may be a radio frequency (RF) module, which is used to communicate with the Internet wirelessly.

[0028] The display may be, for example, a touch screen liquid crystal display (LCD) that enables a user to interact with a user interface of the computing device.

[0029] It should be noted that, in some optional embodiments, the above Figure 1 The computing device shown may include hardware elements (including circuits), software elements (including computer code stored on a computer-readable medium), or a combination of both hardware and software elements. Figure 1 This is merely one example of a particular embodiment and is intended to illustrate the types of components that may be present in the computing device described above.

[0030] Figure 2 Schematic diagram of the blockchain testing system according to this embodiment. Figure 2 As shown, the system includes: a blockchain 100 and a test server 200.

[0031] The test server 200 is used to count the block generation probabilities of the nodes in the blockchain 100, thereby testing the balance of block generation of each node in the blockchain.

[0032] And the blockchain 100 includes m nodes, namely N1~N m Blockchain 100 adopts the Proof of Work (POW) consensus mechanism.

[0033] It should be noted that the test server 200 in the system can be adapted to the hardware structure described above.

[0034] Under the above operating environment, according to the first aspect of this embodiment, a blockchain testing method is provided. Figure 2 The test server 200 shown in FIG. Figure 3 A schematic diagram showing the process of the method is shown in FIG. Figure 3 As shown, the method includes:

[0035] S302: Constructing a Markov chain transition matrix and state space based on the pre-set block generation status of each node in the blockchain, wherein the block generation status is used to indicate the block generation order of each node in the blockchain;

[0036] S304: Generate parameter values ​​of a transfer matrix based on block generation samples of a preset period, where the block generation samples are used to indicate the nodes that generate blocks in the blockchain at different times;

[0037] S306: Determine the block generation probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space; and

[0038] S308: Using the balance test model, determine the block generation balance corresponding to each node in the blockchain according to the block generation probability value, wherein the block generation balance is used to indicate whether each node in the blockchain generates blocks in a balanced manner.

[0039] Specifically, nodes N1 to N1 in the blockchain 100 m Responsible for generating blocks, the test server 200 will regularly check the nodes N1 to N m Perform detection and testing to determine nodes N1 to N in blockchain 100 m Whether block production is balanced.

[0040] Therefore, during the testing phase, the testing server 200 performs the following operations according to the nodes N1 to N2 in the blockchain 100: mThe block generation order of each node is pre-set. i,j . Among them a i,j Represents node N i Block out to node N j The probability of block transfer. i = 1 ~ m, j = 1 ~ m. That is, at node N i The next moment after the block is generated is when node N j The probability of generating a block. For example, the pre-set block generation status of each node includes node N1 generating a block to nodes N1~N m The probability of block transfer: a 1,1 、a 1,2 ,...,a 1,m ; Node N2 generates blocks to nodes N1~N m The probability of block transfer: a 2,1 、a 2,2 ,...,a 2,m ; And so on, by node N m Block generation to nodes N1~N m The probability of block transfer: a m,1 、a m,2 ,...,a m,m .

[0041] Furthermore, the test server 200 generates a block according to the block status a i,j Construct the transfer matrix A of the Markov chain:

[0042]

[0043] Furthermore, the test server 200 constructs the state space D of the Markov chain:

[0044]

[0045] Among them, d i Indicates N i The probability of producing a block, i=1~m.

[0046] Furthermore, after constructing the transfer matrix of the Markov chain, the test server 200 obtains the block samples of the preset L cycles, wherein the block samples are used to indicate the nodes of the blockchain that produce blocks at different times in the preset cycle. Thus, the test server 200 obtains the block samples of nodes N1 to N2 according to the block samples of the tth cycle. m The order of block generation generates parameter values ​​A corresponding to the parameters in the transfer matrix t (t=1~L):

[0047]

[0048] where a t i,jRepresents the node N corresponding to the block sample of the tth cycle i Block out to node N j The probability of block transfer.

[0049] Furthermore, the test server 200 transfers the parameter value A of the matrix t Substitute them into the transfer matrix in turn, and determine the block probability value corresponding to the state space according to the parameter value of the transfer matrix and the state space. The converged state space D can be calculated according to the following formula t The probability of producing a block is:

[0050] (A t -I)×D t =0.

[0051] Right now:

[0052]

[0053] Among them, d t i Indicates that node N is in the state of Markov chain convergence i The probability of generating a block. I is the identity matrix.

[0054] Thus, the test server 200 calculates the block probability value D according to the above formula t =[d t 1,d t 2,...,d t m ] T .

[0055] Furthermore, the test server 200 is pre-set with a balance test model, so that the balance test model is used to determine the block probability value D. t , determining the block balance corresponding to each node in the blockchain. The block balance indicates whether each node in the blockchain produces blocks in a balanced manner. The test server 200 then proposes a corresponding solution based on the block balance.

[0056] As mentioned in the background, small blockchains typically employ a simplified block structure and storage method. To reduce computing resource consumption, they can employ a Proof-of-Work (PoW) consensus mechanism. Blockchain PoW is a consensus mechanism that uses computing resources to solve mathematical problems. Its core goal is to ensure network security, decentralization, and immutability of transactions. Although originally designed for decentralization, PoW can easily lead to the concentration of computing power in actual operation. This can lead to an imbalance in computing power distribution and cause centralization issues.

[0057] To address the above-mentioned technical issues, the technical solutions of the embodiments of the present application pre-set the block generation status of each node in the blockchain based on their block generation order and construct a Markov chain transition matrix and state space. This allows the transition matrix and state space to capture the changing patterns of block generation between nodes. The test server then determines the block generation probability value, obtaining the block generation probability distribution for each node. Furthermore, this technical solution utilizes a balance testing model to determine the block generation balance corresponding to each node in the blockchain based on the calculated block generation probability values. This not only considers the block generation performance of individual nodes, but also the balance of block generation across the entire blockchain. Based on the tested block generation balance, it is possible to predict in advance whether the blockchain's computing power is about to or has already become unbalanced, and propose corresponding countermeasures, thereby avoiding the centralization problem caused by computing power imbalance. This solves the technical problem of imbalanced computing power distribution and centralization caused by the high block generation rates of some nodes in the blockchain, which exists in the prior art.

[0058] Optionally, the operation of generating parameter values ​​of a transfer matrix based on block generation samples of a preset period includes: determining each node as a target node in sequence; counting a first number of times the target node generates a block based on the block generation samples; counting a second number corresponding to the target node and other nodes that generate a block at the next moment based on the block generation order of each node in the block generation sample, wherein the second number is used to indicate the number of times the block generation is transferred from the target node to other nodes; and calculating the parameter values ​​of the transfer matrix based on the first number and the second number of the target node.

[0059] Specifically, the test server 200 obtains the block samples of the preset L periods. Each period includes n+1 block samples. For example, in period t (t=1~L), the block samples include SN t 1~SN t n+1 SN t k Indicates the block-producing node at the kth moment in cycle t, k = 1 to n; SN t n+1 represents the block producing node at the n+1th moment in period t. Table 1 shows the block producing samples of L periods.

[0060] Table 1

[0061] Cycle 1 <![CDATA[SN 1 1]]> <![CDATA[SN 1 2]]> ... <![CDATA[SN 1 n ]]> <![CDATA[SN 1 n+1 ]]> Cycle 2 <![CDATA[SN 2 1]]> <![CDATA[SN 2 2]]> ... <![CDATA[SN 2 n ]]> <![CDATA[SN 2 n+1 ]]> ... ... ... ... ... ... Period L <![CDATA[SN L 1]]> <![CDATA[SN L 2]]> ... <![CDATA[SN L n ]]> <![CDATA[SN L n+1 ]]>

[0062] Furthermore, the test server 200 connects nodes N1 to N m As the target node in turn, the target node N is counted in each cycle t. i Number of blocks produced Num t i (i.e., the first count).

[0063] For example, taking N1 as the target node, in cycle 1, the block sample SN 1 1 is the target node N1, which means that the block generating node at the first moment of cycle 1 is N1, so as of the first moment, the number of blocks generated by the target node N1 is Num 1 1=1 (i.e., the first count); for example, in cycle 1, the block sample SN 1 2 is also the target node N1, which means that the block generating node at the second moment of cycle 1 is N1, so as of the second moment, the number of blocks generated by the target node N1 is Num 1 1=2 (i.e., the first number); and so on, the test server 200 counts the number of blocks produced by the target node N1 from cycle 1 to the nth moment Num 1 1 is the first number of the node N1 that is finally counted. Thus, the test server 200 counts the number of the target node N1 at the end of each period t according to the above method. i Number of blocks produced Num t i As the final statistical node N i The first time.

[0064] Furthermore, the test server 200 determines the target node N in each cycle t. i And at the next moment, the block node N j The corresponding block status a i,j , and statistics and block status a i,j The corresponding number Num t i,j (i.e., the second number.) The second number is used to indicate the number of times the block generation process has been transferred from the target node to other nodes.

[0065] For example, taking N1 as the target node, in cycle 1, when the block sample SN 1 1 is the target node N1, the block sample SN 1 2 is also the target node N1, then the corresponding block status is a 1,1 . So far, compared with the block status a 1,1 The corresponding number Num 1 1,1 =1 (i.e., the second number).

[0066] In cycle 1, when the block sample SN 1 2 is the target node N1, the block sample SN 1 3 is also the target node N1, then the corresponding block status is a 1,1 . So far, compared with the block status a 1,1 The corresponding number Num1 1,1 =2 (i.e., the second number).

[0067] In cycle 1, when the block sample SN 1 3 is the target node N1, the block sample SN 1 4 is node N2, then the corresponding block status is a 1,2 . So far, compared with the block status a 1,2 The corresponding number Num 1 1,2 =1 (i.e., the second number).

[0068] Similarly, in cycle 1, when the block sample SN 1 n The target node is N1, and the block sample is SN 1 n+1 For node N m , then the corresponding block status is a 1,m Thus, the test server 200 counts the block status a up to now. 1,m The corresponding number Num 1 1,m (i.e., the second count).

[0069] Thus, the test server 200 counts and generates block status a in the above manner. i,j The corresponding number Num t i,j (i.e., the second count).

[0070] Furthermore, the test server 200 determines the target node N i The first number Num t i and the second number Num t i,j , calculate each block state a in the transfer matrix i,j The parameter value a t i,j .

[0071] This technical solution thus reflects the block production rate of each node and its correlation with other nodes by sequentially identifying each node as the target node and counting the number of blocks produced by the node in different cycles (i.e., the first count) and the number of blocks produced by other related nodes in the next moment (i.e., the second count). This allows us to determine the trend of block production transfers. When the test server determines that the target node frequently transfers to a certain block production node after producing blocks based on the second count, it can promptly determine whether the transferred block production node is an abnormal node, thereby quickly locating it and achieving efficient blockchain detection.

[0072] Optionally, the operation of calculating the parameter value of the transfer matrix according to the first number and the second number of the target node includes: calculating the ratio between the first number and the second number of the target node as the corresponding parameter value in the transfer matrix.

[0073] Specifically, the test server 200 obtains the target node N i The first number Num t i and the second number Num t i,j , then calculate the target node N i The first number Num t i and the second number Num t i,j The ratio between them is used as the corresponding parameter value a in the transfer matrix t i,j , where the calculation formula is:

[0074]

[0075] For example, for the target node N1, the corresponding parameter value a t 1,j for:

[0076]

[0077] …

[0078]

[0079] For the target node N2, the corresponding parameter value a t 2,j for:

[0080]

[0081] …

[0082]

[0083] Similarly, for the target node N m , then the corresponding parameter value a t m,j for:

[0084]

[0085] …

[0086]

[0087] Thus, the test server 200 is based on the parameter value a t i,jget

[0088] Therefore, this technical solution can quickly quantify the actual probability of block transfer between nodes and improve the calculation speed by calculating the ratio between the first number (total number of block generation) of the target node and the second number (number of transfers to other nodes).

[0089] Optionally, the operation of determining the block probability value of each node corresponding to the state space based on the parameter value of the transfer matrix and the state space includes: using the transfer matrix and a preset unit matrix to construct an equation with the state space; and solving the equation according to the parameter value of the transfer matrix to calculate the block probability value of each node corresponding to the state space.

[0090] Specifically, the test server 200 uses the transfer matrix A and the preset identity matrix I to construct an equation related to the state space D:

[0091] (AI)×D=0.

[0092] The identity matrix

[0093] Then the test server 200 obtains the parameter value A of the transfer matrix corresponding to each period t t And the corresponding state space D t , then the parameter value A of the transfer matrix t Substitute into the equation (AI)×D=0 in sequence, and then according to the parameter value A of the transfer matrix t And the state space D t Determine the block probability value corresponding to the state space, where the converged state space D can be calculated according to the following formula t The probability of producing a block is:

[0094] (A t -I)×D t =0.

[0095] Right now:

[0096]

[0097] Among them, d t i Indicates that node N is in the state of Markov chain convergence i The probability of generating a block. I is the identity matrix.

[0098] Thus, the test server 200 calculates the block probability value D according to the above formula t =[d t 1,d t 2,...,d tm ] T .

[0099] Therefore, this technical solution periodically updates the parameter value A t Based on this, we can solve D by substituting the equation into the real-time equation. t , so that the changes in the computing power of each node can be determined in real time.

[0100] Optionally, the operation of using the balance test model to determine the block balance corresponding to each node in the blockchain based on the block probability value includes: splicing the block probability values ​​corresponding to multiple preset periods to generate fusion feature information; and using the balance test model to determine the block balance corresponding to each node in the blockchain based on the fusion feature information.

[0101] Specifically, the test server 200 obtains the block probability value D of L preset cycles 1 ~D L .in

[0102] D 1 =[d 1 1,d 1 2,...,d 1 m ] T ;

[0103] D 2 =[d 2 1,d 2 2,...,d 2 m ] T ;

[0104] …

[0105] D L =[d L 1,d L 2,...,d L m ] T .

[0106] After that, the test server 200 will generate a block probability value D 1 ~D L Splicing is performed to generate fusion feature information R = [D 1 ,D 2 ,...,D L]. The test server 200 then inputs the fused feature information into the balance test model, processes the fused feature information R through the balance test model, and outputs a balance probability value corresponding to the block production balance. When the balance probability value is greater than or equal to 50%, the test server 200 determines that the block production of each node in the blockchain 100 is balanced; when the balance probability value is less than 50%, the test server 200 determines that the block production of the nodes in the blockchain 100 is unbalanced.

[0107] Therefore, this technical solution combines the block generation probability values ​​of multiple cycles into fused feature information, so that the balance test model can not only capture the block generation distribution within a single cycle, but also analyze the long-term trend of node generation, solving the misjudgment problem that may be caused by traditional methods relying only on single sampling.

[0108] Optionally, the balance test model is used to determine the block balance corresponding to each node in the blockchain based on the fused feature information, including: processing the fused feature information through the RNN of the balance test model to generate semantic feature information; processing the semantic feature information through the fully connected layer to generate an integral vector; and classifying the integral vector through a classifier to determine the block balance corresponding to each node in the blockchain.

[0109] Specifically, refer to Figure 4 As shown in Figure 1, the balance test model includes RNN, fully connected layer and classifier.

[0110] The test server 200 inputs the fused feature information R into the balance test model. The balance test model inputs the received fused feature information into the RNN, which performs semantic extraction on the fused feature information to generate semantic feature information. The balance test model then inputs the semantic feature information output by the RNN into the fully connected layer, which processes the semantic feature information and generates an integral vector. The balance test model then inputs the integral vector into the classifier, which classifies the integral vector and outputs a balance probability value corresponding to the balance of block production. When the balance probability value is greater than or equal to 50%, the test server 200 determines that the block production of each node in the blockchain 100 is balanced; when the balance probability value is less than 50%, the test server 200 determines that the block production of the nodes in the blockchain 100 is unbalanced.

[0111] Therefore, this technical solution uses RNN to perform semantic extraction on multi-cycle fusion feature information, which can extract the temporal dependency of node block generation and identify the rising trend of the probability of a node generating blocks in multiple consecutive cycles, thereby providing early warning of centralization risks.

[0112] Optionally, the method further includes issuing an early warning if it is determined that block production balance does not meet a balance condition. Specifically, if the test server 200 determines that the block production balance of each node in the blockchain 100 does not meet a balance condition, that is, if the test server 200 determines that the block production of nodes in the blockchain 100 is unbalanced, a real-time early warning is issued and the computing power share of the node with the most block production is limited to enforce decentralization. This prevents the concentration of computing power and prevents the network from being controlled by a small number of nodes.

[0113] In addition, according to a second aspect of this embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.

[0114] According to this embodiment, the test server pre-determines the block generation status of each node in the blockchain based on their block generation order and constructs a Markov chain transition matrix and state space. This allows the transition matrix and state space to capture the changing patterns of block generation between nodes. The test server then determines the block generation probability value, obtaining the block generation probability distribution for each node. Furthermore, this technical solution utilizes a balance testing model to determine the block generation balance corresponding to each node in the blockchain based on the calculated block generation probability values. This not only considers the block generation performance of individual nodes, but also the balance of block generation across the entire blockchain. Based on the block generation balance determined by the test, it is possible to predict in advance whether the blockchain's computing power is about to or has already become unbalanced, and propose corresponding countermeasures to avoid the centralization problem caused by computing power imbalance. This solves the technical problem of computing power imbalance and centralization caused by the high block generation rates of some nodes in the blockchain, which exists in the prior art.

[0115] It should be noted that for the aforementioned method embodiments, for simplicity of description, they are all expressed as a series of action combinations. However, those skilled in the art should be aware that the present invention is not limited by the order of the actions described, because according to the present invention, certain steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.

[0116] Through the description of the above embodiments, those skilled in the art can clearly understand that the method according to the above embodiment can be implemented by means of software plus the necessary general hardware platform, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal device (which can be a mobile phone, computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.

[0117] Example 2

[0118] Figure 5 The blockchain testing device 500 according to this embodiment is shown, and the device 500 corresponds to the method according to the first aspect of embodiment 1. Figure 5 As shown, the device 500 includes: a construction module 510, which is used to construct a transfer matrix and a state space of a Markov chain according to a preset block generation state of each node in the blockchain, wherein the block generation state is used to indicate the block generation order of each node in the blockchain; a parameter value generation module 520, which is used to generate parameter values ​​of the transfer matrix according to block generation samples of a preset period, wherein the block generation samples are used to indicate the nodes of the blockchain that generate blocks at different times; a probability value determination module 530, which is used to determine the block generation probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space; and a balance determination module 540, which is used to determine the block generation balance corresponding to each node in the blockchain according to the block generation probability value using a balance test model, wherein the block generation balance is used to indicate whether each node of the blockchain generates blocks in a balanced manner.

[0119] Optionally, the parameter value generation module 520 includes: a first determination submodule, which is used to determine each node as a target node in sequence; a first statistics submodule, which is used to count the first number of times the target node generates a block based on the block generation sample; a second statistics submodule, which is used to count the second number corresponding to the target node and other nodes that generate a block at the next moment based on the block generation order of each node in the block generation sample, wherein the second number is used to indicate the number of times the block generation is transferred from the target node to other nodes; and a first calculation submodule, which is used to calculate the parameter value of the transfer matrix based on the first number and the second number of the target node.

[0120] Optionally, the first calculation submodule includes: a calculation unit, configured to calculate a ratio between the first number and the second number of the target node as a corresponding parameter value in the transfer matrix.

[0121] Optionally, the probability value determination module 530 includes: a construction submodule for constructing an equation related to the state space using a transfer matrix and a preset unit matrix; and a second calculation submodule for solving the equation according to the parameter value of the transfer matrix to calculate the block probability value of each node corresponding to the state space.

[0122] Optionally, the balance determination module 540 includes: a first generation submodule, configured to concatenate block generation probability values ​​corresponding to multiple preset periods to generate fused feature information; and a second determination submodule, configured to determine the block generation balance corresponding to each node in the blockchain based on the fused feature information using a balance test model.

[0123] Optionally, the second determination submodule includes: a first generation unit, used to process the fusion feature information through the RNN of the balance test model to generate semantic feature information; a second generation unit, used to process the semantic feature information through the fully connected layer to generate an integral vector; and a determination unit, used to classify the integral vector through a classifier to determine the block balance corresponding to each node in the blockchain.

[0124] Optionally, the blockchain testing device 500 further includes: an early warning module, configured to issue an early warning when the block balance does not meet the balance conditions.

[0125] According to this embodiment, the test server pre-determines the block generation status of each node in the blockchain based on their block generation order and constructs a Markov chain transition matrix and state space. This allows the transition matrix and state space to capture the changing patterns of block generation between nodes. The test server then determines the block generation probability value, obtaining the block generation probability distribution for each node. Furthermore, this technical solution utilizes a balance testing model to determine the block generation balance corresponding to each node in the blockchain based on the calculated block generation probability values. This not only considers the block generation performance of individual nodes, but also the balance of block generation across the entire blockchain. Based on the block generation balance determined by the test, it is possible to predict in advance whether the blockchain's computing power is about to or has already become unbalanced, and propose corresponding countermeasures to avoid the centralization problem caused by computing power imbalance. This solves the technical problem of computing power imbalance and centralization caused by the high block generation rates of some nodes in the blockchain, which exists in the prior art.

[0126] Example 3

[0127] Figure 6 The blockchain testing device 700 according to the first aspect of this embodiment is shown. The device 700 corresponds to the method according to the first aspect of embodiment 1. Figure 6As shown, the device 700 includes: a processor 710; and a memory 720, connected to the processor 710, for providing instructions for the processor 710 to process the following processing steps: constructing a transfer matrix and a state space of a Markov chain according to a preset block generation state of each node in the blockchain, wherein the block generation state is used to indicate the block generation order of each node in the blockchain; generating parameter values ​​of the transfer matrix according to block generation samples of a preset period, wherein the block generation samples are used to indicate the nodes of the blockchain that generate blocks at different times; determining the block generation probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space; and determining the block generation balance corresponding to each node in the blockchain according to the block generation probability value using a balance test model, wherein the block generation balance is used to indicate whether each node in the blockchain generates blocks in a balanced manner.

[0128] Optionally, the operation of generating parameter values ​​of a transfer matrix based on block generation samples of a preset period includes: determining each node as a target node in sequence; counting a first number of times the target node generates a block based on the block generation samples; counting a second number corresponding to the target node and other nodes that generate a block at the next moment based on the block generation order of each node in the block generation sample, wherein the second number is used to indicate the number of times the block generation is transferred from the target node to other nodes; and calculating the parameter values ​​of the transfer matrix based on the first number and the second number of the target node.

[0129] Optionally, the operation of calculating the parameter value of the transfer matrix according to the first number and the second number of the target node includes: calculating the ratio between the first number and the second number of the target node as the corresponding parameter value in the transfer matrix.

[0130] Optionally, the operation of determining the block probability value of each node corresponding to the state space based on the parameter value of the transfer matrix and the state space includes: using the transfer matrix and a preset unit matrix to construct an equation related to the state space; and solving the equation according to the parameter value of the transfer matrix to calculate the block probability value of each node corresponding to the state space.

[0131] Optionally, the operation of using the balance test model to determine the block balance corresponding to each node in the blockchain based on the block probability value includes: splicing the block probability values ​​corresponding to multiple preset periods to generate fusion feature information; and using the balance test model to determine the block balance corresponding to each node in the blockchain based on the fusion feature information.

[0132] Optionally, the balance test model is used to determine the block balance corresponding to each node in the blockchain based on the fused feature information, including: processing the fused feature information through the RNN of the balance test model to generate semantic feature information; processing the semantic feature information through the fully connected layer to generate an integral vector; and classifying the integral vector through a classifier to determine the block balance corresponding to each node in the blockchain.

[0133] Optionally, the memory 620 is further configured to provide the processor 610 with instructions for processing the following processing steps: further comprising: issuing an early warning when the block generation balance does not meet the balance condition.

[0134] According to this embodiment, the test server pre-determines the block generation status of each node in the blockchain based on their block generation order and constructs a Markov chain transition matrix and state space. This allows the transition matrix and state space to capture the changing patterns of block generation between nodes. The test server then determines the block generation probability value, obtaining the block generation probability distribution for each node. Furthermore, this technical solution utilizes a balance testing model to determine the block generation balance corresponding to each node in the blockchain based on the calculated block generation probability values. This not only considers the block generation performance of individual nodes, but also the balance of block generation across the entire blockchain. Based on the block generation balance determined by the test, it is possible to predict in advance whether the blockchain's computing power is about to or has already become unbalanced, and propose corresponding countermeasures to avoid the centralization problem caused by computing power imbalance. This solves the technical problem of computing power imbalance and centralization caused by the high block generation rates of some nodes in the blockchain, which exists in the prior art.

[0135] The serial numbers of the above embodiments of the present invention are for description only and do not represent the advantages or disadvantages of the embodiments.

[0136] In the above embodiments of the present invention, the description of each embodiment has its own focus. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.

[0137] In the several embodiments provided in this application, it should be understood that the disclosed technical content can be implemented in other ways. Among them, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of units or modules, which can be electrical or other forms.

[0138] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.

[0139] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0140] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), mobile hard disk, magnetic disk or optical disk, etc. Various media that can store program codes.

[0141] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principles of the present invention. These improvements and modifications should also be regarded as within the scope of protection of the present invention.

Claims

1. A blockchain testing method, comprising the following steps: The Markov chain’s transition matrix and state space are constructed based on the pre-set block generation status of each node in the blockchain, where the block generation status is used to indicate the block generation order of each node in the blockchain; Generate the parameter values ​​of the transfer matrix based on the block samples of the preset period, where the block samples are used to indicate the nodes that produce blocks in the blockchain at different times; Determine the block generation probability value of each node corresponding to the state space based on the parameter value of the transfer matrix and the state space; And use the balance test model to determine the block balance corresponding to each node in the blockchain according to the block probability value, where the block balance is used to indicate whether each node in the blockchain produces blocks in a balanced manner.

2. The blockchain testing method according to claim 1, wherein: The operation of generating the parameter value of the transfer matrix according to the block generation sample of the preset period specifically includes: determining each node as the target node in sequence; counting the first number of times the target node generates a block according to the block generation sample; counting the second number corresponding to the target node and other nodes that generate a block at the next moment according to the block generation order of each node in the block generation sample, wherein the second number is used to indicate the number of times the block generation is transferred from the target node to other nodes; and calculating the parameter value of the transfer matrix according to the first number and the second number of the target node.

3. The blockchain testing method according to claim 2, wherein: The operation of calculating the parameter value of the transfer matrix according to the first number and the second number of the target node specifically includes: calculating the ratio between the first number and the second number of the target node as the corresponding parameter value in the transfer matrix.

4. The blockchain testing method according to claim 1, wherein: The operation of determining the block probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space specifically includes: using the transfer matrix and the preset unit matrix to construct an equation with the state space; and solving the equation according to the parameter value of the transfer matrix to calculate the block probability value of each node corresponding to the state space.

5. The blockchain testing method according to claim 1, wherein: The operation of using the balance test model to determine the block balance corresponding to each node in the blockchain based on the block probability value specifically includes: splicing the block probability values ​​corresponding to multiple preset periods to generate fusion feature information; and using the balance test model to determine the block balance corresponding to each node in the blockchain based on the fusion feature information.

6. The blockchain testing method according to claim 5, wherein: The balance test model is used to determine the block balance corresponding to each node in the blockchain based on the fused feature information. Specifically, the operation includes: processing the fused feature information through the RNN of the balance test model to generate semantic feature information; processing the semantic feature information through the fully connected layer to generate an integral vector; and classifying the integral vector through the classifier to determine the block balance corresponding to each node in the blockchain.

7. The blockchain testing method according to claim 1, wherein: The balance test model includes an RNN, a fully connected layer, and a classifier. The balance test model inputs the received fusion feature information into the RNN, performs semantic extraction on the fusion feature information through the RNN, and generates semantic feature information. The balance test model then inputs the semantic feature information output by the RNN into the fully connected layer, processes the semantic feature information through the fully connected layer, and generates an integral vector. The balance test model then inputs the integral vector into the classifier, classifies the integral vector through the classifier, and outputs a balance probability value corresponding to the balance of the block.

8. The blockchain testing method according to claim 1, wherein: When it is determined that the block balance does not meet the balance conditions, a real-time warning will be issued, and the computing power share of the node with the most blocks will be limited to enforce decentralization.

9. A blockchain testing device, characterized in that: include: A construction module is used to construct the transition matrix and state space of the Markov chain based on the pre-set block production status of each node in the blockchain, where the block production status is used to indicate the block production order of each node in the blockchain; A parameter value generation module is used to generate parameter values ​​of the transfer matrix based on block generation samples of a preset period, where the block generation samples are used to indicate the nodes that generate blocks on the blockchain at different times; The probability value determination module is used to determine the block probability value of each node corresponding to the state space based on the parameter value of the transfer matrix and the state space; And a balance determination module, which is used to use the balance test model to determine the block balance corresponding to each node in the blockchain according to the block probability value, wherein the block balance is used to indicate whether each node in the blockchain produces blocks in a balanced manner.

10. The blockchain testing device according to claim 9, wherein: The parameter value generation module includes: A first determination submodule is used to sequentially determine each node as a target node; A first statistical submodule is used to count the first number of times the target node generates blocks based on the block generation samples; The second statistical submodule is used to count the second number of nodes corresponding to the target node and other nodes that will produce blocks at the next moment according to the block production order of each node in the block production sample. The second number is used to indicate the number of times the block is transferred from the target node to other nodes; and the first calculation submodule is used to calculate the parameter value of the transfer matrix according to the first number and the second number of the target node.

11. The blockchain testing device according to claim 10, wherein: The first calculation submodule includes: a calculation unit, which is used to calculate the ratio between the first number and the second number of the target node as the corresponding parameter value in the transfer matrix.

12. The blockchain testing device according to claim 9, wherein: The probability value determination module includes: A construction submodule is used to construct equations related to the state space using the transfer matrix and the preset identity matrix; And the second calculation submodule is used to solve the equation according to the parameter value of the transfer matrix and calculate the block probability value of each node corresponding to the state space.

13. The blockchain testing device according to claim 9, wherein: The balance determination module includes: The first generating submodule is used to splice the block generation probability values ​​corresponding to multiple preset periods to generate fusion feature information; and a second determination submodule, for determining the balance of blocks corresponding to each node in the blockchain according to the fusion feature information using the balance test model.

14. The blockchain testing device according to claim 13, wherein: The second determining submodule includes: A first generating unit is configured to process the fused feature information through the RNN of the balance test model to generate semantic feature information; The second generation unit is used to process the semantic feature information through a fully connected layer to generate an integral vector; and a determination unit, configured to classify the integral vectors through a classifier to determine the balance of blocks corresponding to each node in the blockchain.

15. The blockchain testing device according to claim 9, wherein: The blockchain testing device also includes an early warning module for issuing an early warning when the block balance does not meet the balance condition.

16. A blockchain testing device, comprising: processor; and a memory connected to the processor, configured to provide the processor with instructions for performing the following processing steps: The Markov chain’s transition matrix and state space are constructed based on the pre-set block generation status of each node in the blockchain, where the block generation status is used to indicate the block generation order of each node in the blockchain; Generate the parameter values ​​of the transfer matrix based on the block samples of the preset period, where the block samples are used to indicate the nodes that produce blocks in the blockchain at different times; Determine the block generation probability value of each node corresponding to the state space based on the parameter value of the transfer matrix and the state space; And use the balance test model to determine the block balance corresponding to each node in the blockchain according to the block probability value, where the block balance is used to indicate whether each node in the blockchain produces blocks in a balanced manner.

17. The blockchain testing device according to claim 16, wherein: The operation of generating the parameter values ​​of the transfer matrix based on the block samples of the preset period specifically includes: Determine each node as the target node in turn; count the first number of times the target node generates a block based on the block generation sample; According to the block generation order of each node in the block generation sample, the second number corresponding to the target node and other nodes that generate blocks at the next moment is counted, where the second number is used to indicate the number of times the block generation is transferred from the target node to other nodes; And calculating the parameter value of the transfer matrix according to the first degree and the second degree of the target node.

18. The blockchain testing device according to claim 17, wherein: The operation of calculating the parameter value of the transfer matrix according to the first number and the second number of the target node specifically includes: calculating the ratio between the first number and the second number of the target node as the corresponding parameter value in the transfer matrix.

19. The blockchain testing device according to claim 16, wherein: The operation of determining the block probability value of each node corresponding to the state space according to the parameter value of the transfer matrix and the state space specifically includes: using the transfer matrix and the preset unit matrix to construct an equation related to the state space; and solving the equation according to the parameter value of the transfer matrix to calculate the block probability value of each node corresponding to the state space.

20. The blockchain testing device according to claim 16, wherein: The operation of using the balance test model to determine the block balance corresponding to each node in the blockchain based on the block probability value specifically includes: splicing the block probability values ​​corresponding to multiple preset periods to generate fusion feature information; and using the balance test model to determine the block balance corresponding to each node in the blockchain based on the fusion feature information.

21. The blockchain testing device according to claim 20, wherein: The balance test model is used to determine the block balance corresponding to each node in the blockchain based on the fused feature information. Specifically, the operation includes: processing the fused feature information through the RNN of the balance test model to generate semantic feature information; processing the semantic feature information through the fully connected layer to generate an integral vector; and classifying the integral vector through the classifier to determine the block balance corresponding to each node in the blockchain.

22. The blockchain testing device according to claim 16, wherein: The memory is also used to provide the processor with instructions for processing the following processing steps: issuing an early warning when the block balance does not meet the balance condition.

23. A computer-readable storage medium having a computer program stored thereon, wherein when the computer program is executed by a processor, the steps of the method according to claim 1 are implemented.