Proof-of-Work Mechanism Simulation Method, Device, Medium and Terminal Based on Probability Density Function
By adopting the proof-of-work mechanism simulation method based on probability density function in the blockchain simulation system, the problems of inefficiency and waste of computing power resources in the existing technology are solved, and efficient simulation of the computing power level in real scenes and high-fidelity block time simulation are realized.
Patent Information
- Application Number
- CN202211005140.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-22
- Publication Date
- 2025-06-27
- Estimated Expiration
- 2042-08-22
AI Technical Summary
The existing blockchain simulation system is inefficient, resulting in wasting computing resources, unable to simulate the computing power level of real scenes, and it is difficult to simulate the large fluctuations in computing power in the network, limiting the application value of the simulation environment.
The simulation method of the proof of work mechanism based on the probability density function is adopted. By querying the parameter information of the new block and the simulation network node information, input the simulation parameter information into the probability simulation algorithm for calculation, and obtaining the final simulation block time and final block node serial number.
The simulation of the operating state of the blockchain network under any difficulty and arbitrary computing power is realized, reducing resource consumption in the simulation environment and improving the simulation accuracy of the block time of the proof of work algorithm.
Smart Images

Figure CN115562957B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of blockchain, and particularly to a simulation method, device, medium and terminal for a proof-of-work mechanism based on a probability density function. Background Art
[0002] After functional data analysis and hierarchical module decomposition of a real blockchain system, the research content is divided into four levels: a consensus layer, a network layer, a storage layer, and a contract layer. In the simulation work of all four levels, the simulation of the consensus algorithm is the core content of completing the entire simulation work. Currently, the mainstream public blockchain systems in operation are all based on the proof-of-work mechanism, and the simulation environment needs to test the security of the blockchain network under any computing power scenario. Specifically, it is necessary to be able to dynamically adjust the node computing power and simulate the block generation time required at any computing power level. However, in the simulation environment, due to the limitation of the single-machine performance and the requirement for simulating a large number of nodes, it is impossible to actually run various proof-of-work algorithms.
[0003] In existing blockchain simulation systems, in order to achieve the purpose of simulating the proof-of-work mechanism, the method of directly running real proof-of-work algorithms is generally adopted. Directly running the proof-of-work algorithm will cause a large number of simulation nodes to repeatedly perform hash calculations, bringing great performance pressure to the simulation host environment.
[0004] In addition, due to the limitation of the single-machine performance of the host environment, the upper limit of the sum of the computing powers of all simulation nodes is the local actual computing power. It is impossible to simulate the computing power level of the real scenario, and it is difficult to simulate the large fluctuations in the computing power in the network, resulting in limited application value of the simulation environment and being not conducive to verifying the difficulty adjustment algorithm of the blockchain system and the security of the blockchain system in extreme scenarios. Summary of the Invention
[0005] In view of the above deficiencies of the prior art, the purpose of the present application is to provide a simulation method, device, medium and terminal for a proof-of-work mechanism based on a probability density function, aiming to solve the problems of low efficiency in existing blockchain simulation systems, waste of computing power resources, and inability to simulate the computing power level of the real scenario.
[0006] To solve the above technical problems, in the first aspect of the embodiments of the present application, a simulation method for a proof-of-work mechanism based on a probability density function is provided, and the method includes:
[0007] A simulation method for a proof-of-work mechanism based on a probability density function includes:
[0008] Query the parameter information of the new block and the information of the simulation network nodes to obtain simulation parameter information;
[0009] Input the simulation parameter information into a probability simulation algorithm for calculation to obtain the final simulated block generation time and the serial number of the final block generation node;
[0010] Return the final simulated block generation time and the serial number of the final block generation node.
[0011] As a further improved technical solution, the simulation parameter information includes the block difficulty value and the hash rate information.
[0012] As a further improved technical solution, the parameter information of querying a new block and the simulation network node information to obtain the simulation parameter information includes:
[0013] Query the parameter information of the new block to obtain the block difficulty value;
[0014] Query the simulation computing power of n nodes in the simulation network to obtain the hash rate information of the n nodes.
[0015] As a further improved technical solution, the inputting the simulation parameter information into a probability simulation algorithm for calculation to obtain the final simulated block generation time and the serial number of the final block generation node includes:
[0016] Input the simulation parameter information into a probability simulation algorithm and set the initial block generation time to infinity;
[0017] Traverse n nodes, generate the number of calculation times of the simulation nodes through the probability simulation algorithm, obtain the simulated block generation time based on the number of calculation times of the simulation nodes, compare the simulated block generation times, and obtain the final simulated block generation time and the serial number of the final block generation node.
[0018] As a further improved technical solution, the traversing n nodes, generating the number of calculation times of the simulation nodes through the probability simulation algorithm, and obtaining the simulated block generation time based on the number of calculation times of the simulation nodes includes:
[0019] Obtain the Pascal distribution parameters corresponding to each node based on the block difficulty value corresponding to each node, sequentially input the Pascal distribution parameters corresponding to each node into the probability simulation formula for calculation to obtain the calculation results corresponding to each node, take the reciprocal of each calculation result to obtain the number of calculation times of the simulation nodes corresponding to the n nodes respectively, where the block difficulty value is d, and the Pascal distribution parameters include the number of calculation times r of hash calculation failure, the number of calculation times k of hash calculation success, and the probability p of each hash calculation success, r = 2, k = 1, p = 1 / d;
[0020] Obtain the simulated block generation times corresponding to the n nodes based on the number of calculation times of the simulation nodes corresponding to the n nodes and the hash rate information corresponding to the n nodes.
[0021] As a further improved technical solution, the probability simulation formula is the Pascal distribution formula, and the Pascal distribution formula is as follows:
[0022]
[0023] Where r is the number of calculation attempts with hash calculation failure, k is the number of successful hash calculations, and p is the probability of successful hash calculation each time.
[0024] As a further improved technical solution, the comparison of the simulated block generation time to obtain the final simulated block generation time and the final block generation node number includes:
[0025] Compare the initial simulated block generation time with the initial block generation time, and obtain the conclusion that the initial simulated block generation time is less than the initial block generation time. Update the initial simulated block generation time to the current minimum value.
[0026] Compare the current simulated block generation time with the current minimum value. If it is concluded that the current simulated block generation time is less than the current minimum value, update the current simulated block generation time to the current minimum value. After traversing n nodes, obtain the minimum simulated block generation time.
[0027] Use the minimum simulated block generation time as the final simulated block generation time, and use the block generation node number corresponding to the minimum simulated block generation time as the final block generation node number.
[0028] The second aspect of the embodiments of the present application provides a proof-of-work mechanism simulation device based on a probability density function, including:
[0029] An information acquisition module, configured to query parameter information of a new block and simulation network node information to obtain simulation parameter information;
[0030] A calculation module, configured to input the simulation parameter information into a probability simulation algorithm for calculation to obtain the final simulated block generation time and the final block generation node number;
[0031] A return information module, configured to return the final simulated block generation time and the final block generation node number.
[0032] The third aspect of the embodiments of the present application provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in any one of the above-mentioned proof-of-work mechanism simulation methods based on a probability density function.
[0033] The fourth aspect of the embodiments of the present application provides a terminal device, which includes: a processor, a memory, and a communication bus; a computer-readable program that can be executed by the processor is stored on the memory;
[0034] The communication bus realizes the connection and communication between the processor and the memory;
[0035] When the processor executes the computer-readable program, it implements the steps in any of the above-mentioned workload proof mechanism simulation methods based on the probability density function.
[0036] Beneficial effects: Compared with the prior art, the workload proof mechanism simulation method based on the probability density function of the present invention includes querying the parameter information of the new block and the simulation network node information to obtain the simulation parameter information; inputting the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulated block generation time and the final block generation node serial number; returning the final simulated block generation time and the final block generation node serial number; by adopting the above method, the present invention utilizes the probability characteristics of the workload proof mechanism itself to realize the simulation of the consensus algorithm, solves the problem of a large number of repeated hash calculations in the existing simulation methods, only needs one calculation to derive the simulated block generation time, greatly reduces the resource consumption in the simulation environment, and finally realizes the simulation of the running state of the blockchain network under any difficulty and any computing power, and realizes the high-fidelity simulation of the block generation time of the workload proof algorithm. Brief Description of the Drawings
[0037] Figure 1 is the flowchart of the workload proof mechanism simulation method based on the probability density function of the present invention.
[0038] Figure 2 is the structural schematic diagram of the terminal device provided by the present invention.
[0039] Figure 3 is the block diagram of the device structure provided by the present invention.
[0040] Figure 4 is the operation flowchart of the workload proof mechanism simulation method based on the probability density function of the present invention.
[0041] The realization, functional characteristics and advantages of the object of the present invention will be further described with reference to the embodiments and the accompanying drawings. Detailed Embodiments
[0042] To facilitate the understanding of the present application, the present application will be described more comprehensively below with reference to the relevant drawings. The preferred embodiments of the present application are given in the drawings. However, the present application can be implemented in many different forms and is not limited to the embodiments described herein. On the contrary, these embodiments are provided to make the disclosure of the present application more thorough and comprehensive.
[0043] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the technical field to which this application belongs. The terms used in the specification of this application are only for the purpose of describing specific embodiments and are not intended to limit this application.
[0044] The inventors have found through research that the prior art has the following problems:
[0045] (1) The blockchain is a linear long chain, composed of several blocks connected in series. The secure and stable operation of the blockchain depends on the secure and stable operation of the consensus algorithm. The consensus algorithm refers to a distributed algorithm that multiple nodes run in a distributed scenario to reach the same data state. In a distributed scenario, faults such as network packet loss, clock drift, node downtime, and node misbehavior may occur. The consensus algorithm needs to be able to tolerate these errors and ensure that multiple nodes obtain the same data state;
[0046] Before each new block is added to the blockchain, it is broadcast to all nodes in the network. After receiving the block content, each existing node will execute the consensus algorithm to verify the legality of the block. The consensus algorithm is usually a simulation method; in the traditional simulation method, the proof-of-work mechanism will perform repeated hash calculations until a hash value that meets the block difficulty is solved for other nodes to verify. Since this process requires hundreds of millions of loop calculations, the efficiency of the simulation nodes implemented by this method is extremely low, bringing great performance pressure to the simulation host environment;
[0047] In addition, due to the limitation of the single-machine performance of the host environment, the upper limit of the sum of the computing powers of all simulation nodes is the local actual computing power. It is impossible to simulate the computing power level of the real scenario, and it is difficult to simulate large fluctuations in the computing power in the network, correspondingly resulting in limited application value of the simulation environment and being unfavorable for verifying the difficulty adjustment algorithm of the blockchain system and the security of the blockchain system in extreme scenarios.
[0048] To solve the above problems, the following will combine the accompanying drawings to detail various non-limiting embodiments of this application.
[0049] As Figure 1 shown, a proof-of-work mechanism simulation method based on probability density function provided by an embodiment of this application includes the following steps:
[0050] S1, query the parameter information of the new block and the simulation network node information to obtain the simulation parameter information;
[0051] Specifically, after the previous block in the simulation environment is successfully added to the blockchain, the process of generating a new block will be started, and the global scheduler will be notified to start generating a block. After receiving the block generation task, the global scheduler queries the parameter information of the new block and the simulation network node information to obtain the simulation parameter information.
[0052] Among them, the simulation parameter information includes the block difficulty value and the hash rate information.
[0053] Among them, the steps of obtaining the simulation parameter information by querying the parameter information of the new block and the simulation network node information are as follows:
[0054] S101, query the parameter information of the new block to obtain the block difficulty value;
[0055] S102, query the simulation computing power of n nodes in the simulation network to obtain the hash rate information of the n nodes.
[0056] Specifically, the fields included in the header information of a typical blockchain system mainly include the parent block hash, the block hash, and the block height. The process of a block finally being added to the chain mainly includes four steps: generation, broadcasting, verification, and chain addition. The additional mark in the block header is generated in the generation stage, and other nodes verify whether the block is legal in the verification stage.
[0057] By specifying the additional mark in the block header as a field of an 8-byte array, this 8-byte array field is used to record the node simulation computing power in the simulation block generation stage. When entering the verification stage before the block is added to the chain, the remaining nodes will check whether the new block is legal through this 8-byte array field.
[0058] By querying the simulation computing power of n nodes in the simulation network, the hash rate information of the n nodes can be obtained. By querying the parameter information of the new block, the block difficulty value can be obtained.
[0059] S2, input the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulation block generation time and the final block generation node serial number;
[0060] Specifically, the simulation parameter information includes the hash rate information of n nodes and the block difficulty values corresponding to the n nodes. Input the hash rate information of the n nodes and the block difficulty values corresponding to the n nodes into the probability simulation algorithm for calculation to obtain the final simulation block generation time and the final block generation node serial number.
[0061] Among them, the steps of inputting the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulation block generation time and the final block generation node serial number are as follows:
[0062] S201, input the simulation parameter information into the probability simulation algorithm and set the initial block generation time to infinity;
[0063] S202. Traverse n nodes, generate the number of calculations of the simulation nodes through a probability simulation algorithm, obtain the simulation block generation time based on the number of calculations of the simulation nodes, compare the simulation block generation times, and obtain the final simulation block generation time and the serial number of the final block-generating node.
[0064] The process of traversing n nodes, generating the number of calculations of the simulation nodes through a probability simulation algorithm, and obtaining the simulation block generation time based on the number of calculations of the simulation nodes specifically includes the following steps:
[0065] Obtain the Pascal distribution parameters corresponding to each node based on the block difficulty value corresponding to each node. Sequentially input the Pascal distribution parameters corresponding to each node into the probability simulation formula for calculation to obtain the calculation results corresponding to each node. Take the reciprocal of each calculation result to obtain the number of calculations of the simulation nodes corresponding to the n nodes respectively. Among them, the block difficulty value is d, and the Pascal distribution parameters include the number of calculations r of hash calculation failures, the number of calculations k of hash calculation successes, and the probability p of each hash calculation success. r = 2, k = 1, p = 1 / d;
[0066] Obtain the simulation block generation times corresponding to the n nodes based on the number of calculations of the simulation nodes corresponding to the n nodes and the hash rate information corresponding to the n nodes.
[0067] Specifically, the probability p of each hash calculation success can be calculated through the formula p = 1 / d using the block difficulty value d corresponding to each node in the simulation parameter information. Secondly, the number of calculations r of hash calculation failures and the number of calculations k of hash calculation successes are both constants 2 and 1 and do not need to be calculated. The Pascal distribution parameters include the number of calculations r of hash calculation failures, the number of calculations k of hash calculation successes, and the probability p of each hash calculation success. Input the Pascal distribution parameters into the probability simulation formula for calculation to obtain the calculation results corresponding to each node. Take the reciprocal of each calculation result to obtain the number of calculations of the simulation nodes corresponding to the n nodes respectively. After obtaining the number of calculations of the simulation nodes, divide it by the hash rate corresponding to this node to obtain the corresponding simulation block generation time. Among them, the hash rate information contains the hash rates corresponding to the n nodes.
[0068] Among them, the process of comparing the simulation block generation times to obtain the final simulation block generation time and the serial number of the final block-generating node specifically includes the following steps:
[0069] Compare the initial simulation block generation time with the initial block generation time, obtain the conclusion that the initial simulation block generation time is less than the initial block generation time, and update the initial simulation block generation time to the current minimum value;
[0070] Compare the current simulated block generation time with the current minimum value. If it is concluded that the current simulated block generation time is less than the current minimum value, update the current simulated block generation time to the current minimum value. After traversing n nodes, obtain the minimum simulated block generation time;
[0071] Take the minimum simulated block generation time as the final simulated block generation time, and take the block generation node serial number corresponding to the minimum simulated block generation time as the final block generation node serial number. Each node has its own node serial number. Let the node serial number be i, and the serial number i of the first node is 1.
[0072] Specifically, set the initial block generation time to infinity, and set the simulated block generation time corresponding to the first node obtained by calculation as the initial simulated block generation time. First, compare the initial simulated block generation time with the initial block generation time. If it is concluded that the initial simulated block generation time is less than the initial block generation time, update the initial simulated block generation time to the current minimum value. Since the initial block generation time is infinity, therefore, the initial simulated block generation time must be less than the initial block generation time;
[0073] Set the simulated block generation time corresponding to the currently calculated subsequent node as the current simulated block generation time, and compare the current simulated block generation time with the current minimum value. If it is concluded that the current simulated block generation time is less than the current minimum value, update the current simulated block generation time to the current minimum value. After traversing n nodes, obtain the minimum simulated block generation time. For example: the serial number i of the second node is 2, compare the simulated block generation time corresponding to the second node with the current minimum value. If the simulated block generation time corresponding to the second node is less than the current minimum value, update the simulated block generation time corresponding to the second node to the current minimum value. The serial number i of the third node is 3, and then compare the simulated block generation time corresponding to the third node with the current minimum value. Assume that the number of all nodes is n. Until after traversing n nodes, obtain the minimum simulated block generation time, that is, when the node serial number i = n, finally find the minimum simulated block generation time. Take the minimum simulated block generation time as the final simulated block generation time, and take the block generation node serial number corresponding to this minimum simulated block generation time as the final block generation node serial number.
[0074] Among them, the probability simulation formula is the Pascal distribution formula, and the Pascal distribution formula is as follows:
[0075]
[0076] In the formula, r is the number of calculation times of hash calculation failure, k is the number of calculation times of hash calculation success, and p is the probability of successful hash calculation each time.
[0077] Specifically, the principle of the Pascal distribution formula is:
[0078] The process of a single node calculating a hash value and determining whether it meets the block difficulty can be regarded as a discrete random variable. Assuming that the output results of the current hash algorithm are evenly distributed, the probability of generating a block in each calculation process is equal. Therefore, the calculation process of a single node follows a binomial distribution. Considering n calculation processes as random variables X1, X2,..., Xn, these random variables are independent and identically distributed, and have finite mathematical expectations and variances: E(Xi) = μ, D(xi) = δ2 (i = 1, 2...), then its distribution function is shown in formula (1):
[0079] Formula (1): In formula (1), n is the number of random variables, x is the sum of random variables, δ is the standard deviation of random variables, and μ is the mathematical expectation of random variables;
[0080] Since the number of calculations of a single node is extremely large, according to the central limit theorem, the above formula satisfies formula (2).
[0081] Formula (2):
[0082] Formula (3) shows that when n is very large, the random variable Yn approximately follows the standard normal distribution N(0, 1). Therefore, formula (4) shows that the block generation behavior approximately follows the normal distribution N(nμ, nδ2). Let the block difficulty be d, the node computing power be c, and the time required to generate a block be t, then μ = 1 / d, δ2 = 1 / d(1 - 1 / d), n = ct. Finally, the block generation behavior and the block generation time of a single node satisfy the normal distribution N(ct / d, ct(d - 1) / d2). Using this conclusion, the distribution of the number of blocks generated by each node within a fixed time can be calculated.
[0083] Formula (3):
[0084] Formula (4):
[0085] Therefore, the number of calculations required for the next block generation can be calculated using the Pascal distribution. Formula (5) is the Pascal distribution formula, and the simulation environment is the case where k = 1 and p = 1 / d. After obtaining the number of calculations and dividing it by the computing power of this node, the simulated block generation time can be obtained.
[0086] Formula (5):
[0087] In the formula, r is the number of calculation failures for hash calculation, k is the number of calculation successes for hash calculation, and p is the probability of success for each hash calculation.
[0088] In summary, as shown in Algorithm 1, by using the block difficulty, the simulated computing power of nodes, and the probability density function of the Pascal distribution, the block generation time of a single node can be calculated. In the entire simulation network, the block generation times of all nodes are calculated in sequence. By comparing, the node with the minimum time consumption is regarded as the accounting node. After encapsulating the block, the current block generation process ends and enters the block generation process of the next block.
[0089] Algorithm 1:
[0090]
[0091] S3. Return the final simulated block generation time and the serial number of the final block generation node.
[0092] Specifically, after the calculation, the final simulated block generation time and the serial number of the final block generation node are returned to the global scheduler.
[0093] Based on the above simulation method of the proof-of-work mechanism based on the probability density function, this embodiment provides a simulation device of the proof-of-work mechanism based on the probability density function, including:
[0094] Information acquisition module 1, used to query the parameter information of the new block and the information of the simulation network nodes to obtain the simulation parameter information;
[0095] Calculation module 2, used to input the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulated block generation time and the serial number of the final block generation node;
[0096] Return information module 3, used to return the final simulated block generation time and the serial number of the final block generation node.
[0097] In addition, it is worth noting that the working process of the simulation device of the proof-of-work mechanism based on the probability density function provided in this embodiment is the same as the working process of the above simulation method of the proof-of-work mechanism based on the probability density function. Specifically, it can refer to the working process of the simulation method of the proof-of-work mechanism based on the probability density function, which will not be elaborated here.
[0098] Based on the above simulation method of the proof-of-work mechanism based on the probability density function, this embodiment provides a computer-readable storage medium. The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the simulation method of the proof-of-work mechanism based on the probability density function as described in the above embodiment.
[0099] Such as Figure 2As shown, based on the above workload proof mechanism simulation method based on probability density function, the present application also provides a terminal device, which includes at least one processor 20; a display screen 21; and a memory 22, and may further include a communication interface 23 and a bus 24. Among them, the processor 20, the display screen 21, the memory 22 and the communication interface 23 can communicate with each other through the bus 24. The display screen 21 is set to display a user guidance interface preset in the initial setting mode. The communication interface 23 can transmit information. The processor 20 can call the logical instructions in the memory 22 to execute the method in the above embodiments.
[0100] In addition, when the logical instructions in the above-mentioned memory 22 are implemented in the form of software functional units and sold or used as an independent product, they can be stored in a computer-readable storage medium.
[0101] The memory 22, as a computer-readable storage medium, can be set to store software programs and computer-executable programs, such as the program instructions or modules corresponding to the methods in the embodiments of the present disclosure. The processor 20 executes functional applications and data processing by running the software programs, instructions or modules stored in the memory 22, that is, implements the methods in the above embodiments.
[0102] The memory 22 may include a program storage area and a data storage area. Among them, the program storage area can store an operating system and application programs required for at least one function; the data storage area can store data created according to the use of the terminal device, etc. In addition, the memory 22 may include high-speed random access memory and may also include non-volatile memory. For example, various media that can store program codes such as USB flash drives, mobile hard disks, read-only memory (ROM), random access memory (RAM), magnetic disks or optical discs can also be transient storage media.
[0103] Compared with the prior art, the simulation method of the proof-of-work mechanism based on the probability density function of the present invention includes querying the parameter information of the new block and the simulation network node information to obtain the simulation parameter information; inputting the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulated block generation time and the final block generation node serial number; returning the final simulated block generation time and the final block generation node serial number; by adopting the above method, the present invention utilizes the probability characteristics inherent in the proof-of-work mechanism to realize the simulation of the consensus algorithm, solves the problem of a large number of repeated hash calculations in the existing simulation methods, only needs one calculation to derive the simulated block generation time, greatly reduces the resource consumption in the simulation environment, and finally realizes the simulation of the running state of the blockchain network under any difficulty and any computing power conditions, and realizes the high-fidelity simulation of the block generation time of the proof-of-work algorithm.
[0104] It should be understood that the application of the present invention is not limited to the above examples. For those of ordinary skill in the art, improvements or transformations can be made according to the above description, and all such improvements and transformations should fall within the protection scope of the appended claims of the present invention.
[0105] Of course, the description of the above embodiments of the present invention is relatively detailed, but it should not be construed as a limitation to the protection scope of the present invention. The present invention can also have other various implementation manners. Based on this implementation manner, other implementation manners obtained by those of ordinary skill in the art without any creative work all fall within the protection scope of the present invention. The protection scope of the present invention shall be subject to the appended claims.
Claims
1. A simulation method for the proof-of-work mechanism based on the probability density function, characterized in that, It includes: Query the parameter information of the new block and the simulation network node information to obtain the simulation parameter information; Input the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulated block generation time and the final block generation node serial number; Return the final simulated block generation time and the final block generation node serial number; The simulation parameter information includes the block difficulty value and the hash rate information; The querying the parameter information of the new block and the simulation network node information to obtain the simulation parameter information includes: Query the parameter information of the new block to obtain the block difficulty value; Query the simulation computing power of n nodes in the simulation network to obtain the hash rate information of the n nodes; The inputting the simulation parameter information into the probability simulation algorithm for calculation to obtain the final simulated block generation time and the final block generation node serial number includes: Input the simulation parameter information into the probability simulation algorithm and set the initial block generation time to infinity; Traverse n nodes, generate the calculation times of the simulation nodes through the probability simulation algorithm, obtain the simulated block generation time based on the calculation times of the simulation nodes, compare the simulated block generation times, and obtain the final simulated block generation time and the final block generation node serial number.
2. The simulation method of the proof-of-work mechanism based on the probability density function according to claim 1, wherein The traversing n nodes, generating the calculation times of the simulation nodes through the probability simulation algorithm, and obtaining the simulated block generation time based on the calculation times of the simulation nodes includes: Obtain the Pascal distribution parameter corresponding to each node based on the block difficulty value corresponding to each node, sequentially input the Pascal distribution parameter corresponding to each node into the probability simulation formula for calculation to obtain the calculation result corresponding to each node, and take the reciprocal of each calculation result to obtain the calculation times of the simulation nodes corresponding to the n nodes respectively. Among them, the block difficulty value is d, and the Pascal distribution parameter includes the calculation times r of hash calculation failure, the calculation times k of hash calculation success, and the probability p of each hash calculation success, r = 2, k = 1, p = 1 / d; Obtain the simulated block generation time corresponding to the n nodes based on the calculation times of the simulation nodes corresponding to the n nodes and the hash rate information corresponding to the n nodes.
3. The simulation method of the proof-of-work mechanism based on the probability density function according to claim 2, wherein The probability simulation formula is the Pascal distribution formula, and the Pascal distribution formula is as follows: Among them, r is the calculation times of hash calculation failure, k is the calculation times of hash calculation success, and p is the probability of each hash calculation success.
4. The simulation method of the proof-of-work mechanism based on the probability density function according to claim 3, wherein The comparing the simulated block generation times to obtain the final simulated block generation time and the final block generation node serial number includes: Compare the initial simulated block generation time with the initial block generation time, obtain the conclusion that the initial simulated block generation time is less than the initial block generation time, and update the initial simulated block generation time to the current minimum value; Compare the current simulated block generation time with the current minimum value. If it is obtained that the current simulated block generation time is less than the current minimum value, then update the current simulated block generation time to the current minimum value. After traversing n nodes, obtain the minimum simulated block generation time; Take the minimum simulated block generation time as the final simulated block generation time, and take the block generation node serial number corresponding to the minimum simulated block generation time as the final block generation node serial number.
5. A workload proof mechanism simulation device based on a probability density function, which is used to implement the workload proof mechanism simulation method based on a probability density function as described in any one of claims 1-4, and is characterized in that It includes: An information acquisition module, configured to query parameter information of a new block and simulation network node information to obtain simulation parameter information; A calculation module, configured to input the simulation parameter information into a probability simulation algorithm for calculation to obtain a final simulated block generation time and a final block generation node serial number; A returned information module, configured to return the final simulated block generation time and the final block generation node serial number.
6. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores one or more programs, and the one or more programs can be executed by one or more processors to implement the steps in the proof-of-work mechanism simulation method based on a probability density function according to any one of claims 1-4.
7. A terminal device, characterized in that, Including: A processor, a memory, and a communication bus; a computer-readable program executable by the processor is stored on the memory; The communication bus realizes connection communication between the processor and the memory; When the processor executes the computer-readable program, it implements the steps in the proof-of-work mechanism simulation method based on a probability density function according to any one of claims 1-4.
Citation Information
Patent Citations
Consensus mechanism performance analysis method and device for block chain, and storage medium
CN114217934A