Block discharging difficulty adjusting method and device

By obtaining and analyzing basic data in the blockchain network, calculating the actual and target energy consumption indicators, and adjusting the difficulty of the block, solving the problem of unable to control the energy consumption of the blockchain network, realized the reasonable management and network of energy consumption and the network Improvement.

CN119359304APending Publication Date: 2025-01-24WEBANK (CHINA)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411468220.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-21
Publication Date
2025-01-24

AI Technical Summary

Technical Problem

After the scale of the proof-of-work blockchain network has expanded and the intensification of consensus competition, energy consumption cannot be stabilized within a reasonable range.

Method used

By obtaining the basic data of the blockchain network, including total power consumption data, total power data, number of nodes, number of blocks out of block, total block transaction, network delay and transaction confirmation time, calculate the actual energy consumption indicators and target energy sources Consumption indicators, and adjust the difficulty of blocks according to these indicators, actual difficulties, and adaptive coefficients to control energy consumption.

Benefits of technology

Effectively control the energy consumption of the blockchain network, ensure that it is within a reasonable range, reduce unnecessary waste of resources, and improve network performance and sustainable development.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119359304A_ABST
    Figure CN119359304A_ABST
Patent Text Reader

Abstract

The invention discloses a block-out difficulty adjustment method and device, and the method comprises the steps: obtaining the basic data of a block chain network within a target time, the basic data comprising total power consumption data, total computing power data, a node number, a block-out number, a block total transaction number, network delay, and transaction confirmation time; determining an actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks, the total transaction number of the blocks, the network delay and the transaction confirmation time; determining a target energy consumption index according to the total power consumption data and the total computing power data; and according to the actual energy consumption index, the target energy consumption index, the actual block-out difficulty and the adaptive coefficient, determining the target block-out difficulty. The power consumption and the computing power are considered in the block-out difficulty adjustment algorithm, and the block-out difficulty is adjusted according to the actual energy and computing power consumption conditions of the block chain network, so that the energy consumption of the block chain network is ensured to be within a reasonable range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of blockchain technology, and in particular to a method and device for adjusting the difficulty of producing blocks. Background Art

[0002] With the rapid development of blockchain technology, blockchain based on Proof of Work (PoW) has become one of the mainstream consensus mechanisms. However, with the expansion of blockchain network scale and the intensification of consensus competition, the energy cost consumed by consensus activities has gradually become a concern.

[0003] Traditional PoW consensus algorithms usually rely on a large amount of computing resources to ensure the security and stability of the network, which leads to a huge consumption of electricity resources in the consensus process, and the energy consumption of the entire blockchain network cannot be stabilized within a reasonable range. Summary of the invention

[0004] The embodiment of the present application provides a method and device for adjusting the difficulty of block generation, which takes power consumption and computing power into consideration in the difficulty adjustment algorithm of block generation, and then adjusts the difficulty of block generation according to the actual energy and computing power consumption of the blockchain network, thereby ensuring that the energy consumption of the blockchain network is within a reasonable range.

[0005] In a first aspect, an embodiment of the present application provides a method for adjusting block difficulty, including:

[0006] Obtain basic data of the blockchain network within the target time, including total power consumption data, total computing power data, number of nodes, number of blocks produced, total number of transactions in the block, network delay, and transaction confirmation time;

[0007] Determine the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay, and the transaction confirmation time;

[0008] Determine a target energy consumption index according to the total power consumption data and the total computing power data;

[0009] The target block difficulty is determined according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient.

[0010] In a second aspect, an embodiment of the present application provides a block difficulty adjustment device, including:

[0011] An acquisition module is used to acquire basic data of the blockchain network within the target time, including total power consumption data, total computing power data, number of nodes, number of blocks produced, total number of transactions in the block, network delay, and transaction confirmation time;

[0012] A processing module is used to determine the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay and the transaction confirmation time; and to determine the target energy consumption index according to the total power consumption data and the total computing power data; and to determine the target block difficulty according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient.

[0013] In a third aspect, an embodiment of the present application provides a computer, including:

[0014] A memory, a processor, and an executable program code stored in the memory and executable on the processor, wherein the processor executes the method as described in any one of the first aspects when executing the executable program code.

[0015] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, on which a block difficulty adjustment program is stored, the block difficulty adjustment program includes execution instructions, and the execution instructions are used to execute the method as described in any one of the first aspects.

[0016] In a fifth aspect, the present application provides a computer program product, which, when executed by a processor, is used to implement the method as described in any one of the first aspects.

[0017] By implementing the embodiment of the present application, the server of the block difficulty adjustment system first obtains the basic data of the blockchain network within the target time, and the basic data includes total power consumption data, total computing power data, number of nodes, number of blocks, total number of transactions in the block, network delay and transaction confirmation time; then the actual energy consumption index is determined according to the total power consumption data, number of nodes, number of blocks, total number of transactions in the block, network delay and transaction confirmation time; then the target energy consumption index is determined according to the total power consumption data and the total computing power data; then the target block difficulty is determined according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient. By taking power consumption and computing power into consideration in the block difficulty adjustment algorithm, the block difficulty is adjusted according to the actual energy and computing power consumption of the blockchain network, thereby ensuring that the energy consumption of the blockchain network is within a reasonable range. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the background technology, the drawings required for use in the embodiments of the present application or the background technology will be described below.

[0019] Figure 1 This is an architecture diagram of a block difficulty adjustment system provided in an embodiment of the present application;

[0020] Figure 2 It is a flowchart of a method for adjusting the difficulty of producing a block provided by an embodiment of the present application;

[0021] Figure 3 This is a schematic diagram of an architecture for obtaining the total number of transactions in a block provided by an embodiment of the present application;

[0022] Figure 4 It is an architecture diagram of a long short-term memory model provided in an embodiment of the present application;

[0023] Figure 5 It is a structural diagram of a block difficulty adjustment device provided in an embodiment of the present application;

[0024] Figure 6 It is a structural diagram of a computer provided in an embodiment of the present application. DETAILED DESCRIPTION

[0025] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution 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 creative work should fall within the scope of protection of the present application.

[0026] The terms "first", "second", "third", etc. in the specification, claims and drawings of this application are used to distinguish different objects, rather than to describe a specific order. 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 that includes a series of steps or units is not limited to the listed steps or units, but optionally includes steps or units that are not listed, or optionally includes other steps or units inherent to these processes, methods, products or devices.

[0027] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0028] With the rapid development of blockchain technology, blockchain based on Proof of Work (PoW) has become one of the mainstream consensus mechanisms. However, with the expansion of blockchain network scale and the intensification of consensus competition, the energy cost consumed by consensus activities has gradually become a matter of concern. Traditional PoW consensus algorithms usually rely on a large amount of computing resources to ensure the security and stability of the network, which leads to a huge consumption of power resources in the consensus process, and the energy consumption of the entire blockchain network cannot be stabilized within a reasonable range.

[0029] In view of the above problems, the embodiment of the present application provides a method and device for adjusting the difficulty of block generation. The server of the block generation difficulty adjustment system first obtains the basic data of the blockchain network within the target time, and the basic data includes total power consumption data, total computing power data, number of nodes, number of blocks generated, total number of block transactions, network delay and transaction confirmation time; then the actual energy consumption index is determined according to the total power consumption data, number of nodes, number of blocks generated, total number of block transactions, network delay and transaction confirmation time; then the target energy consumption index is determined according to the total power consumption data and total computing power data; then the target block generation difficulty is determined according to the actual energy consumption index, the target energy consumption index, the actual block generation difficulty and the adaptive coefficient. By taking power consumption and computing power into consideration in the block generation difficulty adjustment algorithm, the block generation difficulty is adjusted according to the actual energy and computing power consumption of the blockchain network, thereby ensuring that the energy consumption of the blockchain network is within a reasonable range.

[0030] See also Figure 1 , Figure 11 is an architecture diagram of a block difficulty adjustment system provided in an embodiment of the present application. The block difficulty adjustment system 100 includes a server 101 and a client 102. The server 101 of the block difficulty adjustment system 100 can be a server cluster composed of one server or multiple servers, which is used to perform operations such as data preparation, model training, parameter optimization, and block difficulty adjustment. Specifically, in the data preparation stage, the server 101 is responsible for obtaining basic data of the blockchain network within the target time, including total power consumption data, total computing power data, number of nodes, number of blocks, total number of transactions in the block, network delay, and transaction confirmation time. The server 101 can This information can be collected by communicating with nodes in the network or accessing corresponding data sources; in the model training stage, server 101 trains the long short-term memory model based on the collected data, including adjusting the network structure, selecting a suitable loss function, setting hyperparameters, etc.; in the parameter optimization stage, server 101 uses optimization algorithms such as gradient descent to repeatedly iteratively update the model parameters according to the training data to minimize the loss function; in the block difficulty adjustment stage, server 101 calculates the actual energy consumption index and the target energy consumption index based on the basic data, and then obtains the target block difficulty based on the actual energy consumption index, the target energy consumption index and the actual block difficulty.

[0031] The client 102 can be a computer, a mobile terminal, a handheld terminal, a cellular terminal or the like. The client 102 can receive data transmitted from the server, such as actual energy consumption indicators, target energy consumption indicators, and target block difficulty, etc. The client 102 is also responsible for communicating with other nodes, sharing the target block difficulty calculated by itself, and participating in the consensus process to reach an agreement.

[0032] Based on this, the present application provides a method and device for adjusting the difficulty of block production, and the present application is described in detail below in conjunction with the accompanying drawings.

[0033] See also Figure 2 , Figure 2 : is a flowchart of a method for adjusting the difficulty of a block provided in an embodiment of the present application. Figure 2 As shown, the method comprises the following steps:

[0034] S201, obtaining basic data of the blockchain network within the target time.

[0035] Among them, the blockchain network is a distributed decentralized network composed of multiple participants (nodes) that maintain and update a public, tamper-proof data structure, namely the blockchain, through a consensus mechanism. The blockchain network contains many nodes distributed around the world. Each node can be an independently operated computer or device, which are connected to each other and form a peer-to-peer network. In order to ensure that all nodes in the entire network reach a consensus and update data, a specific consensus mechanism is adopted in the blockchain network. Common consensus mechanisms include Proof of Work, Proof of Stake, etc.

[0036] The basic principle of proof of work is to perform hash calculation on the block header hash and a random nonce value in the blockchain, and then compare them to determine whether the hash value is within a specific unit, where the value range of a hash value is 2 to the power of 256. If the consensus node calculates a nonce value that is within the value range, it broadcasts it to the entire network, notifies other consensus nodes, and adds the block corresponding to the nonce value to the blockchain, starting the consensus calculation for the next block.

[0037] The generation block time of a blockchain network refers to the time interval between each new block generated in the network. Different blockchain networks may have different generation block time settings, depending on the network design and consensus algorithm selection. The target time can be set by the user. The target time can be a specific time or the time required to generate a target number of blocks. For example, the target time can be 30 minutes, 1 hour, or the time required to generate 10 blocks.

[0038] Among them, the basic data of the blockchain network includes total power consumption data, total computing power data, number of nodes, number of blocks, total number of transactions in a block, network delay and transaction confirmation time; specifically, total power consumption data refers to the total energy consumption of all participating nodes in the entire blockchain network, including the power consumption required for mining, transaction verification and network maintenance. Total computing power data represents the total computing power of all participating nodes in the entire blockchain network, which is usually measured by hash rate, that is, the number of hash operations that can be performed per second. The number of nodes refers to the total number of active nodes in the blockchain network. Each node represents an independently running device or computer responsible for maintaining and processing data and transactions on the blockchain. The number of blocks represents the number of new blocks generated within a certain period of time. This value increases every time a new block is successfully created and added to the blockchain. The total number of transactions in a block refers to the total number of all valid transactions that have been confirmed and included in the block within a specific time range. The total number of transactions in a block can measure the activity level of transactions occurring on the entire network. Network delay refers to the time delay between the sender sending the information and the receiver receiving the information. Transaction confirmation time refers to the time it takes to complete a transaction from initiation to confirmation.

[0039] Among them, see Figure 3 , Figure 3 This is a schematic diagram of an architecture for obtaining the total number of transactions in a block provided by an embodiment of the present application. Figure 3 As shown in the figure, the specific processing process of each architecture is as follows: Transaction Pool: Initially, all pending transactions are stored in the transaction pool, which can come from users or other nodes in the blockchain network. Block Mining: Miners create new blocks through competition. Miners select some transactions from the transaction pool and pack these selected transactions into candidate blocks. Verifying Transactions: Before adding a candidate block to the chain, miners need to verify whether each transaction contained in the candidate block is legal. The verification process includes checking digital signatures, balances and other information to ensure that the transaction is valid. Consensus: The verified candidate blocks enter the consensus stage, in which participants negotiate and reach consensus. Different consensus algorithms have different rules to determine which candidate block will eventually become the next valid block. Determining Validity: In the last step, the nodes participating in the consensus process confirm and determine which transactions are included in the final generated valid block, and obtain the total number of transactions in the corresponding valid block by obtaining the number of confirmed transactions.

[0040] Among them, in order to facilitate the subsequent calculation of energy indicators and block difficulty, it is necessary to preprocess the basic data of the blockchain network. The preprocessing operations may include the following: converting the transaction confirmation time into seconds or other unified units, ensuring that the range coefficient and block difficulty are correct and valid values. Specifically, it can be checked whether the range coefficient is greater than zero, and the number of decimal places of the range coefficient can be limited by rounding.

[0041] S202, determining an actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay, and the transaction confirmation time.

[0042] Among them, the actual energy consumption index can comprehensively consider multiple factors such as power consumption, delay, transaction confirmation time, etc.

[0043] Among them, for a specific blockchain platform or protocol, there may be other relevant factors that can participate in the calculation of the actual energy consumption value table. For example, on Ethereum, gas fees can be considered as an indicator to measure transaction costs and network congestion.

[0044] In a possible implementation, determining the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay, and the transaction confirmation time includes:

[0045] The average power consumption data of the nodes of the blockchain network is determined according to the total power consumption data and the number of nodes; the average block time of the blockchain network is determined according to the target time and the number of blocks produced; the average number of block transactions of the blockchain network is determined according to the total number of block transactions and the number of blocks produced; the actual energy consumption index is determined according to the average power consumption data of the nodes, the average block time, the average number of block transactions, the network delay and the transaction confirmation time.

[0046] For example, the total power consumption data is 1000 watts, the number of nodes is 10, the target time is 60 minutes (3600 seconds), and the number of blocks is 6. Then the average power consumption data of each node can be calculated, average power consumption = total power consumption / number of nodes = 1000 watts / 10 = 100 watts / node, the average block time of the blockchain network, average block time = target time / number of blocks = 3600 seconds / 6 = 600 seconds / node.

[0047] It can be seen that in this example, the average power consumption data and average block time used to evaluate the energy consumption performance of the entire blockchain network are obtained by calculation, and then the actual energy consumption index is determined based on the average power consumption data of the nodes, the average block time, the average number of transactions in the blocks, the network delay, and the transaction confirmation time, which is conducive to improving the accuracy of the energy efficiency evaluation of the blockchain network.

[0048] In a possible implementation, determining the actual energy consumption index according to the average power consumption data of the node, the average block generation time, the average number of transactions in the block, the network delay, and the transaction confirmation time includes:

[0049] Obtain a first product of the average power consumption data of the node and the average block generation time of the block; obtain a first quotient of the first product and the average number of transactions in the block; obtain a second quotient of the network delay and the average number of transactions in the block; obtain a third quotient of the transaction confirmation time and the average block generation time of the block; obtain a first sum of the first quotient, the second quotient and the third quotient, the first sum being the actual energy consumption indicator.

[0050] Among them, the first quotient represents the ratio of the first product of the average power consumption data of the node and the average block time to the average number of transactions in the block. This ratio can be understood as the energy consumed in each processed transaction. A lower first quotient value indicates that the energy required for each transaction is relatively less, and vice versa. It means that the energy required for each transaction is relatively more. The second quotient represents the ratio of network delay to the average number of transactions in the block. This ratio reflects the waiting time and network load when processing a single transaction. A smaller second quotient value indicates that the system has high transmission efficiency, that is, it reduces the waiting time and improves the overall network performance. The third quotient represents the ratio of transaction confirmation time to the average block time. This ratio measures the ratio of the cost required to complete a complete transaction relative to the length of the block cycle (i.e. mining speed). A smaller third quotient value means that the system has better scalability and response speed.

[0051] Specifically, the calculation formula of the actual energy consumption index E (actual) is as follows:

[0052] E(actual)=P*T / N+L / N+C / T;

[0053] Among them, E (actual) is the actual energy consumption indicator, P is the average power consumption data of the node, T is the average block time, N is the average number of transactions in the block, L is the network delay, and C is the transaction confirmation time.

[0054] It can be seen that in this example, by calculating the first quotient, the second quotient and the third quotient and summing them up as the actual energy consumption indicator (i.e., the first sum), the impact of multiple factors such as node power consumption, block speed, network load and confirmation speed on the actual energy consumption can be comprehensively considered, which is conducive to the subsequent evaluation of system performance and optimization of power utilization to improve energy efficiency.

[0055] S203: Determine a target energy consumption index according to the total power consumption data and the total computing power data.

[0056] Among them, the calculation formula of the target energy consumption index E(target) is as follows:

[0057] E(target)=P total / H total ;

[0058] Among them, E(target) is the target energy consumption index, P total is the total power consumption data, H total is the total computing power data;

[0059] In another example, the target energy consumption index E(target) is calculated as follows:

[0060]

[0061] Among them, E(target) is the target energy consumption indicator, m is the number of nodes participating in the consensus, which refers to the number of nodes participating in the consensus process in a specific blockchain network, Pi is the power consumption of the i-th node, which indicates the energy or electricity consumed by the i-th participant in the network in performing computing tasks and mining, and Hi is the computing power of the i-th node, which indicates the computing power of the i-th participant in the network to perform proof-of-work computing tasks or mine new blocks.

[0062] Among them, computing power is usually used to measure the time required for a participant to complete a computing task within a certain period of time. The computing power is obtained by the number of hashes calculated per second, that is, (H / s). For example, there are participants C and D in the blockchain network, and they have different computing powers. The computing power of participant C is 10000H / s, and the computing power of participant D is 50000H / s.

[0063] In a possible implementation, before determining the target block difficulty according to the actual energy consumption index, the target energy consumption index and the adaptive coefficient, the method further includes:

[0064] The long short-term memory model is trained according to the actual energy consumption index and actual computing power data of the produced blocks of the blockchain network to obtain a trained long short-term memory model; the energy consumption index prediction value and computing power data prediction value of the unproduced blocks of the blockchain network are obtained according to the trained long short-term memory model; the adaptive coefficient is determined according to the energy consumption index prediction value, the computing power data prediction value, the target energy consumption index and the target computing power data.

[0065] Among them, the LSTM network model, namely the long short-term memory network model, is an important variant of the recurrent neural network (RNN). The core of the LSTM network model lies in its memory unit and gate structure. Each LSTM unit contains a memory cell C_t and three gate structures: forget gate f_t, input gate i_t and output gate o_t. Specifically, the forget gate determines which information is forgotten from the state of the previous moment; the input gate determines which new information at the current moment should be saved in the memory unit; and the output gate controls which information is output from the memory unit to the external state.

[0066] Among them, see Figure 4 , Figure 4 is an architecture diagram of a long short-term memory model provided in an embodiment of the present application, such as Figure 4 As shown in the figure, the left, middle and right parts have the same structure. Each part can be regarded as a cell unit A, which is mainly used to express the flow relationship between the input and output information of the current time step t, the previous time step t-1, and the next time step t+1. t-1 , X t , X t+1 Represents the input state values ​​of three adjacent time steps, h t-1 、h t 、h t+1 They represent the output state values ​​of three adjacent time steps respectively. The σ function is used to help regulate the value flowing through the network, compressing its input value between 0 and 1. The tanh function is used for activation, compressing and converting its input value to the interval (-1, 1).

[0067] Among them, taking the current time t as an example, the core structure can be divided into four parts, including the forget gate, input gate, cell state, and output gate. Forget gate structure: The output state h of the previous time step t-1 With the current time step input state X t After concatenation, it is switched on the left side through a fully connected layer and adjusted by the σ function to obtain f1(t), which represents how much information has been forgotten in the past and is called the forget gate value. Input gate structure: From the structure, it can be seen that it contains two inputs and one output. The first input is the output state h of the previous time step t-1 With the current time step input state X tAfter concatenation, the left side is replaced by a fully connected layer, and then adjusted by the σ function to obtain f2(t). The second input is the output state h of the previous time step. t-1 With the current time step input state X t After concatenation, the cell is switched on the left through a fully connected layer, and then f3(t) is obtained by the tanh function to represent the current unupdated state of the cell. Cell state update: The cell state C(t-1) of the previous time step is multiplied by the forget gate value f1(t) calculated at the current time step, and the result of the multiplication of the input gate f2(t) and f3(t) of the current time step is added to obtain the result C(t) of the cell update at the current time step. Output gate structure: From the structure, it can be seen that it contains two inputs and one output. The first input is the output state h of the previous time step. t-1 With the current time step input state X t After concatenation, the left side of the fully connected layer is replaced and activated by the σ function to obtain f4(t). The second input is the result of the cell update C(t) at the current time step. The output state h is t The intermediate value is obtained by the action of the tanh function, and the intermediate value is multiplied by f4(t) to obtain the output state h t , a portion of the input for the next time step.

[0068] The calculation formula of the adaptive coefficient K is as follows:

[0069] k=f(E(target),E(actua l),H);

[0070] Among them, f is a function based on machine learning or historical trends, which is used to predict future energy consumption and computing power changes and adaptively adjust the K value. E (target) is the target energy consumption indicator, which can be set according to the historical average. E (actual) is the actual energy consumption indicator, and H is the computing power data.

[0071] It can be seen that in this example, by training the long short-term memory model and based on the actual energy consumption indicators and computing power data, the energy consumption and computing power of the unproduced blocks of the blockchain network are predicted, and then the adaptive coefficient is determined by comparing the predicted results with the target energy consumption indicators and target computing power data. This will help to further accurately evaluate and optimize the energy efficiency of the blockchain network, improve overall performance, and reduce unnecessary waste of resources.

[0072] In a possible implementation, the adaptive coefficient is set according to the block time deviation. The specific steps are as follows:

[0073] A sliding window is defined, which contains the most recent n blocks, wherein the selection of an appropriate window size depends on network characteristics and requirements; when each new block is generated, the deviation between the block and the target block time is calculated, wherein the deviation can be obtained by the difference between the actual block time and the target block time; the deviation value of the current block is added to the sliding window, and the oldest deviation value is removed to keep the window size unchanged; the average value of all deviation values ​​in the sliding window is calculated as the current adaptive coefficient, specifically, all deviation values ​​are added and divided by the window size to obtain the adaptive coefficient; the adaptive coefficient is adjusted according to the comparison between the average deviation and the set threshold, if the average deviation exceeds the threshold, the adaptive coefficient is increased, if the average deviation is less than the threshold, the adaptive coefficient is reduced; the difficulty level or related parameters are adjusted based on the adjusted adaptive coefficient to achieve control of the block generation speed.

[0074] Exemplarily, a sliding window is defined, and the sliding window contains the 10 most recently generated blocks. When each new block is generated, the deviation between the block and the target block time is calculated. For example, if the target block time is 60 seconds, and the actual block time of a certain block is 55 seconds, the block time deviation is 5 seconds. The current block time deviation value is added to the sliding window, and the oldest deviation value is removed to keep the window size unchanged. The deviations of the first 9 blocks are [4, 6, -2, 3, 1, -5, 7, 0, -3] seconds, respectively. After adding the new 10 blocks, all the deviation values ​​in the sliding window are [6, -2, 3, 1, -5, 7, 0, -3, 5] seconds. Then calculate the average value of all the deviation values ​​in the sliding window as the current adaptive coefficient. In this example, the average value is calculated, that is, (6+(-2)+3+1+(-5)+7+0+(-3)+5) / 9=13 / 9≈1.44 seconds / block. Finally, the adaptive coefficient is adjusted based on the comparison between the average deviation and the set threshold. If the set threshold is 1 second, since the average deviation is greater than the threshold (1.44>1), the adaptive coefficient can be increased, and the difficulty level or related parameters can be adjusted based on the adjusted adaptive coefficient.

[0075] It can be seen that in this example, by setting the adaptive coefficient based on the sliding window average method and then dynamically adjusting the difficulty according to the actual situation, it is helpful to help the blockchain network adapt to the current block speed and mining activity level more accurately. At the same time, by calculating the deviation and adjusting the adaptive coefficient to maintain a stable block time, it is helpful to avoid problems such as excessive delays or congestion.

[0076] In a possible implementation, the trained long short-term memory model includes a first long short-term memory model and a second long short-term memory model, and the long short-term memory model is trained according to the actual energy consumption index and actual computing power data of the blocks produced by the blockchain network to obtain the trained long short-term memory model, including:

[0077] The actual energy consumption indicators of the blocks that have been produced of the blockchain network are used to form a time series data set to obtain a first data set; the actual computing power data of the blocks that have been produced of the blockchain network are used to form a time series data set to obtain a second data set; the long short-term memory model is trained according to the first data set to obtain a first long short-term memory model, and the first long short-term memory model is used to predict the predicted value of the energy consumption indicator of the unproduced blocks according to the actual energy consumption indicators of the produced blocks; the long short-term memory model is trained according to the second data set to obtain a second long short-term memory model, and the second long short-term memory model is used to predict the predicted value of the computing power data of the unproduced blocks according to the actual computing power data of the produced blocks.

[0078] Specifically, the steps for obtaining the adaptive coefficient K are as follows:

[0079] Step S1, collect the actual energy consumption index E(actua l)(t) and computing power data H(t) of the previous block to form a time series data set. Assuming there are n blocks, the constructed data set is as follows:

[0080]

[0081] Hashrate Data = {H (t-n) , ..., H (t-1)};

[0082] Among them, for the constructed energy efficiency dataset and computing power dataset, the server can perform preprocessing operations including data cleaning, sequence filling, and splitting the validation set. Among them, data cleaning is used to process missing values ​​or outliers in numerical data; since the long short-term memory model is a sequence-based model, the preprocessing operation of sequence filling can add markers to the end of shorter sequences so that all sequences input into the long short-term memory model have the same length.

[0083] Step S2, use the energy efficiency dataset Energy Data and the computing power dataset HashrateData of the previous n blocks to train two independent LSTM models, namely LSTM model 1 for predicting future energy efficiency E(pred) and LSTM model 2 for predicting future computing power H(pred).

[0084] The prediction formula is as follows:

[0085] E(pred)=LSTM1(Energy Data);

[0086] H(pred)=LSTM2(Hashrate Data);

[0087] Step S3, calculating the dynamic adjustment coefficient K.

[0088] It can be seen that in this example, by constructing a time series dataset, two independent long short-term memory models are trained for the energy consumption indicators and computing power data of the blockchain network respectively. The first model is used to predict the predicted value of the energy consumption indicator of the unproduced blocks based on the actual energy consumption indicator, and the second model is used to predict the predicted value of the computing power data of the unproduced blocks based on the actual computing power data, which is conducive to providing more accurate prediction results, helping to optimize resource allocation and evaluate system performance.

[0089] In a possible implementation, determining an adaptive coefficient according to the predicted value of the energy consumption index, the predicted value of the computing power data, the target energy consumption index, and the target computing power data includes:

[0090] Obtain the fourth quotient of the target energy consumption index and the predicted value of the energy consumption index; obtain the fifth quotient of the target computing power data and the predicted value of the computing power data; obtain the second product of the fourth quotient and the first weight coefficient; obtain the third product of the fifth quotient and the second weight coefficient; obtain the second sum of the second product and the third product, the second sum being the adaptive coefficient.

[0091] The first weight coefficient and the second weight coefficient are both constants greater than 0, and the first weight coefficient and the second weight coefficient can be set or changed by the user on the client. For example, the first weight coefficient is 0.5, and the second weight coefficient is 0.6.

[0092] Among them, the fourth quotient represents the proportional relationship or error degree between the target energy consumption index and the predicted energy consumption index, and the fifth quotient represents the proportional relationship or error degree between the target computing power data and the predicted computing power data.

[0093] Specifically, the result predicted by the LSTM model is substituted into the function f, and the formula for calculating the adaptive coefficient k is as follows:

[0094] k=a*E(target) / E(pred)+b*H(target) / H(pred);

[0095] Among them, a is the first weight coefficient and b is the second weight coefficient, E(target) is the target energy consumption index, E(pred) is the predicted value of the energy consumption index, H(target) is the target computing power data, which can be set based on historical data, and H(pred) is the predicted value of the computing power data.

[0096] It can be seen that in this example, the adaptive coefficient is obtained by calculating the difference between the target energy consumption index and the predicted value (the fourth quotient) and the difference between the target computing power data and the predicted value (the fifth quotient), and then combining the weight coefficient for weighted operation. This process can effectively reflect the deviation between the actual situation and the expected target, providing a scientific basis for subsequent optimization. At the same time, by dynamically adjusting the adaptive coefficient, the efficiency of blockchain network resource utilization can be continuously improved, the system performance and stability can be enhanced, thereby reducing energy consumption and improving mining efficiency.

[0097] S204, determining a target block generation difficulty according to the actual energy consumption index, the target energy consumption index, the actual block generation difficulty and the adaptive coefficient.

[0098] Among them, the actual block difficulty can be obtained according to the Bitcoin difficulty adjustment algorithm, which is mainly used to adjust the block generation speed to maintain the stability and security of the network. Bitcoin uses a time interval-based difficulty adjustment algorithm. Specifically, the difficulty is adjusted every 2016 blocks (approximately every two weeks), with the goal of generating a new block within a fixed time (such as every 10 minutes). Miners achieve this goal by constantly trying to find a hash value that meets specific conditions. Finally, based on the historical block generation time, the average block time is evaluated regularly (for example, every 2016 blocks). If the average block time is found to be shorter than the target, the difficulty is increased; otherwise, the difficulty is reduced.

[0099] Among them, the difficulty adjustment in the blockchain network is achieved through the following steps:

[0100] The calculation formula for block generation time is to count the sum of the block generation time of the latest n blocks. This time refers to the sum of the time intervals from the timestamp of block generation to the timestamp of the next block generation.

[0101] Calculate the expected duration. The expected duration refers to the total duration that should be spent on the latest n blocks, calculated based on the generation rate of one block every 10 minutes, that is, n×10 minutes.

[0102] Compare the time and adjust the difficulty. Compare the actual block time with the expected time and adjust the difficulty based on the ratio between the two. If the actual block time is shorter, increase the difficulty; if the actual block time is longer, reduce the difficulty.

[0103] Adjust the difficulty by setting a range coefficient value x. For example, it is required that the calculated hash value be less than x, that is, hash < x, indicating that the calculated hash must be between 0 and x. When the value of x is smaller, the range is smaller, and the smaller the range, the greater the difficulty.

[0104] Specifically, the calculation formula for the time interval-based difficulty adjustment algorithm of Bitcoin is as follows:

[0105] D new = D old *(C1 * C2 * 60) / R;

[0106] Where, D new is the newly adjusted block production difficulty, D old is the result of the previous difficulty adjustment, C1 is the number of blocks, generally 2016, that is, the difficulty is adjusted every 2016 blocks, C2 is the time taken to generate each block, generally 10 minutes, which needs to be multiplied by 60 to convert to seconds, and R is the actual time taken.

[0107] In a possible implementation, determining the target block production difficulty according to the actual energy consumption index, the target energy consumption index, the actual block production difficulty, and the adaptive coefficient includes:

[0108] Obtain the first difference between the target energy consumption index and the actual energy consumption index; obtain the sixth quotient of the adaptive coefficient and the target energy consumption index; obtain the fourth product of the first difference and the sixth quotient; obtain the third sum of the first constant and the fourth product; obtain the fifth product of the third sum and the actual block production difficulty, and the fifth product is the target block production difficulty.

[0109] Specifically, the calculation formula for the target block production difficulty is as follows:

[0110] D(new) = D(old)*(1 + (E(target) - E(actual)) * K / E(target));

[0111] Where, D(new) is the target block production difficulty, D(old) is the actual block production difficulty, E(target) is the target energy consumption index, E(actual) is the actual energy consumption index, and k is the adaptive coefficient.

[0112] It can be seen that in this example, by calculating the difference between the target energy consumption index and the actual energy consumption index, combining the adaptive coefficient and the block production difficulty, and performing a series of operations to obtain the final result to dynamically adjust the block production difficulty, the resource utilization efficiency of the blockchain system can be flexibly controlled, thereby improving the overall performance and sustainable development of the blockchain network.

[0113] In one possible implementation, the blockchain network includes an actual range factor for limiting the block hash range, and the method further includes:

[0114] The target range coefficient is determined according to the target block difficulty and the actual range coefficient, and the target range coefficient is the sixth product of the inverse of the target block difficulty and the actual range coefficient.

[0115] In the blockchain network, the range factor is the actual coefficient used to limit the effective range of the block hash value. It can control the difficulty of mining and affect the speed and security of new block generation.

[0116] Specifically, the target range coefficient is calculated as follows:

[0117] x(new)=(1 / D(new))*x(o ld);

[0118] Among them, x(new) is the target range coefficient, D(new) is the target block difficulty calculated in this scheme, and x(o ld) is the actual range coefficient. x(new) is obtained by

[0119] The method of limiting the limited range of the hash value of the new block by the range coefficient may be that the valid range of the hash value of the subsequent new block needs to be between 0-x(new), or, the limited range of the hash value of the subsequent new block needs to be between 0-the product of the target hash value and x(new), wherein the target hash value can be set or changed by the user.

[0120] For example, the blockchain network uses the SHA-256 algorithm as the hash function and specifies the target hash value and range coefficient.

[0121] Assume the target hash value is:

[0122] 00000000f7c8a25b2e8d227d5ff943cb6f45db9c3bc18e10e770716ea5868100;

[0123] This is a 64-bit string in hexadecimal. Assume the range factor is 100. The range factor defines the range of valid hash values. At this time, the valid hash value must be less than or equal to the result of multiplying the target hash value by the range factor. Therefore, the valid hash value must be less than or equal to: 00000000f7c8a25b2e8d227d5ff943cb6f45db9c3bc18e10e770716ea5868100*100, that is, 00000000647cf17357ca6be30cf63a8427187ed1504d6054ef592fe1385cb4.

[0124] It can be seen that in this example, the target range coefficient that is most suitable for the current situation is determined by comprehensively considering the target block difficulty and the actual range coefficient. This is conducive to helping the blockchain network better adapt to mining needs under different conditions and improve the stability and security of the blockchain system. At the same time, by calculating the target block difficulty and the actual range coefficient, the mining speed can be accurately controlled and the normal operation of the blockchain network can be maintained.

[0125] See also Figure 5 , Figure 5 is a structural diagram of a block difficulty adjustment device provided in an embodiment of the present application, such as Figure 5 As shown, the block difficulty adjustment device 500 includes:

[0126] An acquisition module 501 is used to acquire basic data of the blockchain network within a target time, wherein the basic data includes total power consumption data, total computing power data, number of nodes, number of blocks produced, total number of transactions in a block, network delay, and transaction confirmation time;

[0127] Processing module 502 is used to determine the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay and the transaction confirmation time; and to determine the target energy consumption index according to the total power consumption data and the total computing power data; and to determine the target block difficulty according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient.

[0128] In a possible implementation, in terms of determining the actual energy consumption index based on the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay and the transaction confirmation time, the processing module 502 is specifically used to: determine the average power consumption data of the nodes of the blockchain network based on the total power consumption data and the number of nodes; determine the average block production time of the blockchain network based on the target time and the number of blocks produced; determine the average number of block transactions in the blockchain network based on the total number of block transactions and the number of blocks produced; determine the actual energy consumption index based on the average power consumption data of the nodes, the average block production time, the average number of transactions in the block, the network delay and the transaction confirmation time.

[0129] In a possible implementation, before determining the target block difficulty according to the actual energy consumption indicator, the target energy consumption indicator and the adaptive coefficient, the processing module 502 is also used to: train the long short-term memory model according to the actual energy consumption indicator and the actual computing power data of the produced blocks of the blockchain network to obtain a trained long short-term memory model; obtain the energy consumption indicator prediction value and computing power data prediction value of the unproduced blocks of the blockchain network according to the trained long short-term memory model; determine the adaptive coefficient according to the energy consumption indicator prediction value, the computing power data prediction value, the target energy consumption indicator and the target computing power data.

[0130] In a possible implementation, the trained long short-term memory model includes a first long short-term memory model and a second long short-term memory model. In terms of training the long short-term memory model according to the actual energy consumption index and actual computing power data of the produced blocks of the blockchain network to obtain the trained long short-term memory model, the processing module 502 is specifically used to: construct a time series data set of the actual energy consumption index of the produced blocks of the blockchain network to obtain a first data set; construct a time series data set of the actual computing power data of the produced blocks of the blockchain network to obtain a second data set; train the long short-term memory model according to the first data set to obtain the first long short-term memory model, and the first long short-term memory model is used to predict the predicted value of the energy consumption index of the unproduced blocks according to the actual energy consumption index of the produced blocks; train the long short-term memory model according to the second data set to obtain the second long short-term memory model, and the second long short-term memory model is used to predict the predicted value of the computing power data of the unproduced blocks according to the actual computing power data of the produced blocks.

[0131] In one possible implementation, in terms of determining the adaptive coefficient based on the predicted value of the energy consumption index, the predicted value of the computing power data, the target energy consumption index and the target computing power data, the processing module 502 is specifically used to: obtain the fourth quotient of the target energy consumption index and the predicted value of the energy consumption index; obtain the fifth quotient of the target computing power data and the predicted value of the computing power data; obtain the second product of the fourth quotient and the first weight coefficient; obtain the third product of the fifth quotient and the second weight coefficient; obtain the second sum of the second product and the third product, the second sum being the adaptive coefficient.

[0132] In one possible implementation, in terms of determining the target block difficulty according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient, the processing module 502 is specifically used to: obtain a first difference between the target energy consumption index and the actual energy consumption index; obtain a sixth quotient of the adaptive coefficient and the target energy consumption index; obtain a fourth product of the first difference and the sixth quotient; obtain a third sum of the first constant and the fourth product; obtain a fifth product of the third sum and the actual block difficulty, and the fifth product is the target block difficulty.

[0133] In one possible implementation, the blockchain network includes an actual range coefficient for limiting the block hash range, and the processing module 502 is further used to: determine the target range coefficient according to the target block difficulty and the actual range coefficient, and the target range coefficient is the sixth product of the inverse of the target block difficulty and the actual range coefficient.

[0134] It is worth noting that the specific functional implementation of the block difficulty adjustment device 500 is shown in the above Figure 2 The description of the method for adjusting the difficulty of block generation is shown, for example, the acquisition module 501 is used to implement the relevant content of executing S201, and the processing module 502 is used to implement the relevant content of executing S202-S204. The various units or modules in the device for adjusting the difficulty of block generation 500 can be respectively or completely combined into one or several other units or modules to form, or one (some) of the units or modules can be further divided into multiple functionally smaller units or modules to form, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present invention. The above-mentioned units or modules are divided based on logical functions. In practical applications, the functions of one unit (or module) are implemented by multiple units (or modules), or the functions of multiple units (or modules) are implemented by one unit (or module).

[0135] Based on the description of the above method embodiments and related device embodiments, please refer to Figure 6 , an embodiment of the present invention also provides a structural diagram of a computer 600. Figure 6 The computer 600 shown includes a processor 601, a memory 602, a communication interface 603 and a bus 604. The processor 601, the memory 602 and the communication interface 603 are connected to each other through the bus 604.

[0136] Optionally, the memory 602 is a ROM, a static storage device, a dynamic storage device or a RAM.

[0137] The memory 602 can store programs. When the executable program code stored in the memory 602 is executed by the processor 601, the processor 601 and the communication interface 603 are used to execute Figure 2 The various steps of the method for adjusting the difficulty of producing blocks in the illustrated embodiment.

[0138] The processor 601 adopts a general-purpose CPU, a microprocessor, an application-specific integrated circuit ASIC, a GPU or one or more integrated circuits to execute relevant programs to execute the block difficulty adjustment method of the method embodiment of the present application.

[0139] Processor 601 can also be an integrated circuit chip with signal processing capabilities. In the implementation process, each step of the block difficulty adjustment method of the present application can be completed by the hardware integrated logic circuit or software instructions in the processor 601. Optionally, processor 601 is a general-purpose processor, DSP, ASIC, FPGA or other programmable logic device, discrete gate or transistor logic device, discrete hardware component. The processor can implement or execute the methods, steps and logic block diagrams disclosed in the embodiments of the present application. The general-purpose processor is a microprocessor or the processor is any conventional processor, etc. The steps of the method disclosed in the embodiments of the present application can be directly embodied as a hardware decoding processor to execute, or a combination of hardware and software modules in the decoding processor to execute. The optional software module is located in a random access memory, a flash memory, a read-only memory, a programmable read-only memory or an electrically erasable programmable memory, a register or other mature storage medium in the art. The storage medium is located in the memory 602, and the processor 601 reads the information in the memory 602, and combines its hardware to complete the functions required to be performed by the acquisition module 501 and the processing module 502 included in the block difficulty adjustment device 500 of an embodiment of the present application, or executes the block difficulty adjustment method of the method embodiment of the present application.

[0140] The communication interface 603 uses a transceiver or other related device such as, but not limited to, a transceiver.

[0141] The bus 604 may include a path for transmitting information between various components of the computer 600 (eg, the memory 602 , the processor 601 , and the communication interface 603 ).

[0142] It should be noted that although Figure 6 The computer 600 shown only shows a memory, a processor, and a communication interface, but in the specific implementation process, those skilled in the art should understand that the computer 600 also includes other devices necessary for normal operation. At the same time, based on specific needs, those skilled in the art should understand that the computer 600 may also include hardware devices that implement other additional functions. In addition, those skilled in the art should understand that the computer 600 may also include only the devices necessary to implement the embodiments of the present application, and does not necessarily include Figure 6 All devices shown in .

[0143] An embodiment of the present application provides a computer-readable storage medium, in which a computer program for electronic data exchange is stored. The computer program includes execution instructions, and the execution instructions are used to execute part or all of the steps of any one of the block difficulty adjustment methods described in the above block difficulty adjustment method embodiments. The above computer includes an electronic terminal device.

[0144] An embodiment of the present application provides a computer program product, wherein the computer program product includes a computer program, and the computer program can be operated to enable a computer to perform part or all of the steps of any one of the block difficulty adjustment methods recorded in the above method embodiments. The computer program product can be a software installation package.

[0145] It should be noted that, for the sake of simplicity, for any of the above-mentioned embodiments of the method for adjusting the difficulty of block production, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, 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 the specification are all preferred embodiments, and the actions involved are not necessarily required by this application.

[0146] The embodiments of the present application are described in detail above. Specific examples are used herein to illustrate the principle and implementation method of a method and device for adjusting the difficulty of producing a block of the present application. The description of the above embodiments is only used to help understand the method and its core idea of ​​the present application. At the same time, for those skilled in the art, according to the idea of ​​a method and device for adjusting the difficulty of producing a block of the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as limiting the present application.

[0147] The present application is described with reference to the flowcharts and / or block diagrams of the methods, hardware products, and computer program products of the embodiments of the present application. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0148] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 The memory may include: a flash disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, etc.

[0149] Although the present application is described herein in conjunction with various embodiments, in the process of implementing the claimed application, those skilled in the art may understand and implement other variations of the disclosed embodiments by viewing the drawings, the disclosure, and the appended claims. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "one" does not exclude multiple situations. Certain measures are recorded in different dependent claims, but this does not mean that these measures cannot be combined to produce good results.

[0150] Those skilled in the art can understand that all or part of the steps in the various methods of the above-mentioned method for adjusting the difficulty of block generation can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable memory, and the memory can include: a flash drive, a read-only memory (English: Read-Only Memory, abbreviated: ROM), a random access memory (English: Random Access Memory, abbreviated: RAM), a disk or an optical disk, etc.

[0151] It can be understood that any product that is controlled or configured to execute the processing method of the flowchart described in an embodiment of a block difficulty adjustment method of the present application, such as the device and computer program product of the above flowchart, belongs to the category of related products described in the present application.

[0152] Obviously, those skilled in the art can make various changes and modifications to the method and device for adjusting the difficulty of producing a block provided by the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application is also intended to include these modifications and variations.

Claims

1. A method for adjusting the difficulty of producing a block, characterized in that: The method comprises: Obtain basic data of the blockchain network within the target time, including total power consumption data, total computing power data, number of nodes, number of blocks produced, total number of transactions in the block, network delay, and transaction confirmation time; Determine the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay, and the transaction confirmation time; Determine a target energy consumption index according to the total power consumption data and the total computing power data; The target block difficulty is determined according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient.

2. The method according to claim 1, characterized in that The determining of the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay, and the transaction confirmation time includes: Determine the average power consumption data of the nodes of the blockchain network according to the total power consumption data and the number of nodes; Determine the average block time of the blockchain network according to the target time and the number of blocks produced; Determine the average transaction number of the block of the blockchain network according to the total transaction number of the block and the number of blocks produced; The actual energy consumption index is determined according to the average power consumption data of the node, the average block generation time, the average number of transactions in the block, the network delay and the transaction confirmation time.

3. The method according to claim 2, characterized in that The determining the actual energy consumption index according to the average power consumption data of the node, the average block generation time, the average number of transactions in the block, the network delay, and the transaction confirmation time includes: Obtaining a first product of the average power consumption data of the node and the average block generation time of the block; Obtaining a first quotient of the first product and the average number of transactions in the block; Obtaining a second quotient of the network delay and the average number of transactions in the block; Obtaining the third quotient of the transaction confirmation time and the average block generation time of the block; A first sum of the first quotient, the second quotient and the third quotient is obtained, where the first sum is the actual energy consumption indicator.

4. The method according to claim 1, characterized in that Before determining the target block difficulty according to the actual energy consumption index, the target energy consumption index and the adaptive coefficient, the method further includes: The long short-term memory model is trained according to the actual energy consumption index and actual computing power data of the blocks produced by the blockchain network to obtain a trained long short-term memory model; Obtain the predicted value of energy consumption index and computing power data of the unproduced blocks of the blockchain network according to the trained long short-term memory model; An adaptive coefficient is determined according to the predicted value of the energy consumption index, the predicted value of the computing power data, the target energy consumption index and the target computing power data.

5. The method according to claim 4, characterized in that The trained long short-term memory model includes a first long short-term memory model and a second long short-term memory model. The long short-term memory model is trained according to the actual energy consumption index and actual computing power data of the blocks produced by the blockchain network to obtain the trained long short-term memory model, including: The actual energy consumption indicators of the blocks produced by the blockchain network are used to form a time series data set to obtain a first data set; The actual computing power data of the produced blocks of the blockchain network are used to form a time series data set to obtain a second data set; Training a long short-term memory model according to the first data set to obtain a first long short-term memory model, wherein the first long short-term memory model is used to predict a predicted value of an energy consumption index of an unproduced block according to an actual energy consumption index of a produced block; The long short-term memory model is trained according to the second data set to obtain a second long short-term memory model, and the second long short-term memory model is used to predict the predicted value of the computing power data of the unproduced blocks according to the actual computing power data of the produced blocks.

6. The method according to claim 4, characterized in that The determining of the adaptive coefficient according to the predicted value of the energy consumption index, the predicted value of the computing power data, the target energy consumption index and the target computing power data includes: Obtaining a fourth quotient of the target energy consumption index and the predicted value of the energy consumption index; Obtaining a fifth quotient of the target computing power data and the predicted value of the computing power data; Obtaining a second product of the fourth quotient and the first weight coefficient; Obtaining a third product of the fifth quotient and the second weight coefficient; A second sum value of the second product and the third product is obtained, where the second sum value is the adaptive coefficient.

7. The method according to any one of claims 1 to 6, characterized in that: The determining the target block difficulty according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient includes: Obtaining a first difference between the target energy consumption index and the actual energy consumption index; Obtaining a sixth quotient of an adaptive coefficient and the target energy consumption index; Obtaining a fourth product of the first difference and the sixth quotient; Obtaining a third sum of the first constant and the fourth product; A fifth product of the third sum and the actual block difficulty is obtained, where the fifth product is the target block difficulty.

8. The method according to claim 7, characterized in that The blockchain network includes an actual range factor for limiting the block hash range, and the method further includes: The target range coefficient is determined according to the target block difficulty and the actual range coefficient, and the target range coefficient is the sixth product of the inverse of the target block difficulty and the actual range coefficient.

9. A block difficulty adjustment device, characterized in that: The device comprises: An acquisition module is used to acquire basic data of the blockchain network within the target time, including total power consumption data, total computing power data, number of nodes, number of blocks produced, total number of transactions in the block, network delay, and transaction confirmation time; A processing module is used to determine the actual energy consumption index according to the total power consumption data, the number of nodes, the number of blocks produced, the total number of transactions in the block, the network delay and the transaction confirmation time; and to determine the target energy consumption index according to the total power consumption data and the total computing power data; and to determine the target block difficulty according to the actual energy consumption index, the target energy consumption index, the actual block difficulty and the adaptive coefficient.

10. A computer, characterized in that: The computer comprises: A memory, a processor, and an executable program code stored in the memory and executable on the processor, wherein the processor executes the steps of the block difficulty adjustment method according to any one of claims 1 to 8 when executing the executable program code.