Regional chain security consensus method and device suitable for distributed power transaction

By screening high-reliability nodes and abnormal detection in distributed power trading systems, dynamically updating node credibility is solved, and a more efficient and secure consensus process is achieved.

CN119420524APending Publication Date: 2025-02-11ZHONGNENG FUSION SMART TECH CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411530922.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-10-30
Publication Date
2025-02-11

AI Technical Summary

Technical Problem

Existing blockchain technology cannot effectively provide security protection for key nodes in distributed power trading systems, resulting in security issues such as malicious delays and denial of service, increasing the communication cost of the ledger consensus process and reducing transaction confirmation efficiency.

Method used

A blockchain security consensus method suitable for distributed power transactions is proposed. By filtering high-reliability nodes according to the trustworthiness of nodes in the system, selecting the master node and the node participating in the consensus, and collecting the time series through the master node Behavioral data, use LSTM neural network for abnormal detection, dynamically update the node's trustworthiness to eliminate abnormal nodes.

Benefits of technology

It reduces the communication cost of the consensus process, improves transaction confirmation efficiency, enhances the security and stability of the system, and achieves a more efficient consensus process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119420524A_ABST
    Figure CN119420524A_ABST
Patent Text Reader

Abstract

The invention provides a regional chain security consensus method and device suitable for distributed power transaction, and relates to the technical field of regional chain consensus, distributed anomaly detection is carried out on each node behavior in a consensus process through a deep learning model, a credibility mechanism is introduced, credibility division is carried out on all nodes in a network, and a consensus result is obtained. Nodes with low credibility are removed in the consensus process, only the consensus result can be received, the communication cost of the consensus process is reduced, the system consensus efficiency is improved, and compared with an existing common block chain system, the method has a more efficient consensus process on the basis of guaranteeing distributed consistency, and rapid execution of power transaction business is facilitated.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of regional chain consensus technology, and in particular to a regional chain security consensus method and device suitable for distributed power trading. Background Art

[0002] As the country deepens the reform of information technology in the energy trading system, the distributed power trading system has been further developed. Different from the traditional centralized one-to-many power supply mode, where one power generation organization provides power to many power users, in the distributed power trading scenario, there are a large number of small, independent power generation equipment or power generation individuals, which jointly provide efficient power output to power users in the system.

[0003] However, the development of blockchain technology is relatively limited at this stage, and it is unable to provide effective security protection for each key node in the system network layer, which hinders the efficient operation of the existing consensus mechanism and poses security risks. For example, in the peer-to-peer communication of the power trading blockchain, the existence of abnormal nodes will lead to security issues such as malicious delays and denial of service, increase the communication cost of the ledger consensus process, and reduce the efficiency of transaction confirmation, thus affecting the reliability and stability of the entire distributed power trading system. Summary of the invention

[0004] The present application aims to solve one of the technical problems in the related art at least to some extent.

[0005] To this end, the first purpose of this application is to propose a regional chain security consensus method suitable for distributed power trading.

[0006] The second purpose of this application is to propose a regional chain security consensus device suitable for distributed power trading.

[0007] The third objective of the present application is to provide an electronic device.

[0008] A fourth objective of the present application is to provide a computer-readable storage medium.

[0009] A fifth object of the present application is to provide a computer program product.

[0010] To achieve the above objectives, the first embodiment of the present application proposes a regional chain security consensus method suitable for distributed power trading, including:

[0011] S1. In the distributed power trading system, each node is assigned an initial node credibility according to the order in which each node joins the blockchain network;

[0012] S2. Filter the high-credibility node array according to the credibility of the nodes, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus;

[0013] S3. When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data.

[0014] S4. The master node collects the time series behavior data in the consensus process, standardizes the time series behavior data, and calculates the correlation coefficient matrix and eigenvalues ​​to select the principal components whose cumulative variance contribution rate is greater than the preset ratio for analysis, and uses the anomaly detection model based on the LSTM neural network to detect abnormal nodes to obtain an abnormal node array;

[0015] S5. Traverse the abnormal node array, downwardly update the credibility of each abnormal node, return to step S2, and continue to execute the next round of consensus process.

[0016] The method of selecting a high-credibility node array according to the credibility of the nodes includes:

[0017] The credibility values ​​of all nodes in the blockchain are arranged in descending order as {CR1, CR2, ..., CR n}, where the number of all nodes in the blockchain is n;

[0018] Based on the lowest high-credibility node threshold, the nodes in the arranged array are screened to determine the high-credibility node array arr CR = {CR1, CR2, ..., CR i}, where CR i ≥CR low , CR low is the minimum high-trust node threshold.

[0019] The method randomly selects a high-credibility node from the high-credibility node array as the master node, and uses the remaining high-credibility nodes as all nodes participating in the consensus, including:

[0020] Choose a random number k,

[0021] Generate k random integers between 1 and i and store them in a set S;

[0022] For each integer in S, swap the number k with the number i-k+1;

[0023] Randomly select a number q from numbers 1 to ik and confirm that the master node is CR q ;

[0024] Determine that all nodes participating in the consensus are excluding CR q All other high-trust nodes except

[0025] When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data, including:

[0026] The client sends CR to the master node q Make a request<<REQUEST,o,t,c> >, where t is the timestamp, o is the operation type, and c is the client that initiated the request;

[0027] When the master node CR q After receiving the client request, send a pre-prepare message to all nodes participating in the consensus< <PRE PREPARE ,v,p,d>,m>, where v represents the view number, the view will change only when the credibility is updated, p represents the node number that sends the message, d represents the message digest, and m represents the original message data;

[0028] Each node participating in the consensus verifies the pre-prepare message. If the verification is successful, the current consensus node agrees to the request and sends a consensus preparation message to other consensus nodes, records the message in the local log, and starts receiving consensus preparation messages sent from other consensus nodes.

[0029] Within the preset time range, if the current consensus node receives more than The current consensus node enters the commit phase, sends a consensus commit message, and starts receiving consensus commit messages sent from other consensus nodes.

[0030] If the current consensus node receives more than The consensus submission message of other consensus nodes is inserted into the local log for comparison and verification with the consensus submission message sent by itself until the consensus submission message is received. The valid consensus submission message of the node, and the consensus of this consensus node has been reached in this round;

[0031] When all consensus nodes complete the consensus process, all nodes participating in the consensus execute the request and write the results to local data. Other low-credibility nodes that did not participate in the consensus do not participate in this round of consensus, but receive and synchronize the results from the high-credibility nodes participating in the consensus to complete the data writing.

[0032] When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data, including:

[0033] The client sends CR to the master node q Make a request<<REQUEST,o,t,c> >, where t is the timestamp, o is the operation type, and c is the client that initiated the request;

[0034] When the master node CR q After receiving the client request, send a pre-prepare message to all nodes participating in the consensus< <PRE PREPARE ,v,p,d>,m>, where v represents the view number, the view will change only when the credibility is updated, p represents the node number that sends the message, d represents the message digest, and m represents the original message data;

[0035] Each node participating in the consensus verifies the pre-prepare message. If the verification is successful, the current consensus node agrees to the request and sends a consensus preparation message to other consensus nodes, records the message in the local log, and starts receiving consensus preparation messages sent from other consensus nodes.

[0036] Within the preset time range, if the current consensus node receives more than The current consensus node enters the commit phase, sends a consensus commit message, and starts receiving consensus commit messages sent from other consensus nodes.

[0037] If the current consensus node receives more than The consensus submission message of other consensus nodes is inserted into the local log for comparison and verification with the consensus submission message sent by itself until the consensus submission message is received. The valid consensus submission message of the node, and the consensus of this consensus node has been reached in this round;

[0038] When all consensus nodes complete the consensus process, all nodes participating in the consensus execute the request and write the results to local data. Other low-credibility nodes that did not participate in the consensus do not participate in this round of consensus, but receive and synchronize the results from the high-credibility nodes participating in the consensus to complete the data writing.

[0039] If v in the pre-prepared message is inconsistent with the current view or d and m are repeated in the previous message or the message node CR is sent p If it is not in the high-trust node array, the verification fails and the client's request is rejected.

[0040] The master node collects the time series behavior data in the consensus process, standardizes the time series behavior data, and calculates the correlation coefficient matrix and eigenvalues ​​to select the principal component with a cumulative variance contribution rate greater than a preset ratio for analysis, and uses an anomaly detection model based on an LSTM neural network to detect abnormal nodes, and obtains an abnormal node array, including:

[0041] The master node collects the time series behavior data of all nodes participating in the consensus in the execution of the consensus process in real time. The time series behavior data includes the total upstream network speed, the total downstream network speed, the node CPU occupancy, the node memory occupancy, the node upstream network speed, the node downstream network speed, the node file system occupancy, and the number of node peer node connections;

[0042] The time series behavior data is standardized. For the time series behavior data X=(x1, x2, ..., x n ), where each dimension contains m sample data, then x j The sample mean of and standard deviation s j The calculation formula is:

[0043]

[0044] Among them, X is obtained after standardization to obtain an n-dimensional random variable Y = (y1, y2, ..., y n ), y j =(y 1j ,y 2j , ..., y nj ) T , where the standardized random variable y j The calculation formula is:

[0045] The correlation coefficient matrix is ​​calculated based on the standardized random variables. The calculation formula is:

[0046] R=(r ij ) n×n

[0047]

[0048] Wherein, R is the correlation coefficient matrix;

[0049] Calculate the eigenvalue λ corresponding to R i With the eigenvector μ i , arranged in descending orderλ1≥λ2≥…≥λ n ≥0, the eigenvalues ​​corresponding to the eigenvectors are μ1, μ2, ..., μ n , the corresponding principal components are Z1, Z2, ..., Zn ;

[0050] Calculate the variance contribution rate ω of the jth component based on the eigenvalue j And the cumulative variance contribution rate α of the first p components p , the expression is:

[0051]

[0052] Select α p K principal components greater than 80% are used to replace the original n-dimensional data for analysis;

[0053] According to the selected k principal components, the anomaly detection model based on LSTM neural network is used to detect anomalies in the consensus process data of each node, and the abnormal node array arr is output. abn .

[0054] Optionally, traversing the abnormal node array and downwardly updating the credibility of each abnormal node includes:

[0055] For abnormal node array arr abn , if the currently selected abnormal node is m, calculate the updated value CR of the abnormal node's credibility m ′=CR m (1-δ), where δ is the node credibility offset.

[0056] To achieve the above-mentioned purpose, the second embodiment of the present application proposes a regional chain security consensus device suitable for distributed power trading, including:

[0057] The credibility initialization module, in the distributed power trading system, is used to assign initial node credibility to each node according to the order in which each node joins the blockchain network;

[0058] The consensus node division module is used to screen the high-credibility node array according to the credibility of the nodes, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus;

[0059] The consensus execution module is used to send a pre-prepared message to all nodes participating in the consensus when the master node receives the consensus request from the client. Each consensus node verifies the message based on its consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result into local data.

[0060] A malicious behavior detection module is used to collect time series behavior data in the consensus process through the master node, standardize the time series behavior data, and calculate the correlation coefficient matrix and eigenvalues ​​to select the principal component with a cumulative variance contribution rate greater than a preset ratio for analysis, and use an anomaly detection model based on the LSTM neural network to detect abnormal nodes to obtain an abnormal node array;

[0061] The credibility adjustment and loop module is used to traverse the abnormal node array, downwardly update the credibility of each abnormal node, and continue to execute the next round of consensus process.

[0062] To achieve the above-mentioned purpose, the third aspect of the present application provides an electronic device, including: a processor, and a memory communicatively connected to the processor;

[0063] The memory stores computer-executable instructions;

[0064] The processor executes the computer-executable instructions stored in the memory to implement the method as described in any one of the first aspects.

[0065] To achieve the above-mentioned purpose, the fourth aspect embodiment of the present application proposes a computer-readable storage medium, in which computer-readable storage medium is stored computer execution instructions, and when the computer execution instructions are executed by a processor, they are used to implement the method as described in any one of the first aspects.

[0066] To achieve the above-mentioned purpose, the fifth aspect of the present application proposes a computer program product, which implements any method in the first aspect when executed by a processor.

[0067] The regional chain security consensus method, device, electronic device and storage medium provided by the present application are suitable for distributed power trading. The behavior of each node in the consensus process is subjected to distributed anomaly detection through a deep learning model, and a credibility mechanism is introduced to divide the credibility of all nodes in the network. Nodes with low credibility are eliminated during the consensus process and can only receive consensus results, thereby reducing the communication cost of the consensus process and improving the system consensus efficiency. Compared with the existing common blockchain systems, the present application has a more efficient consensus process on the basis of ensuring distributed consistency, which is conducive to the rapid execution of power trading business.

[0068] In addition, this application designs a malicious behavior detection algorithm for the blockchain consensus process based on time series anomaly detection, and efficiently identifies abnormal nodes in the system by building a deep learning model; based on the anomaly detection results, a credibility model and update algorithm are designed to ensure that the credibility of each node is dynamically updated before each round of consensus begins, thereby improving the activity of the consensus process and adapting to a changing network environment; a PBFT optimization algorithm based on the credibility model is designed to reduce the number of nodes participating in the consensus through a node partitioning mechanism, thereby improving the throughput of the blockchain system.

[0069] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS

[0070] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0071] Figure 1 A schematic diagram of a flow chart of a regional chain security consensus method applicable to distributed power trading provided in an embodiment of the present application;

[0072] Figure 2 A schematic diagram of a flow chart of a regional chain security consensus method applicable to distributed power trading provided in an embodiment of the present application;

[0073] Figure 3 A schematic diagram of the optimization process of training an anomaly detection model based on an LSTM neural network provided in an embodiment of the present application;

[0074] Figure 4 A schematic diagram of the structure of a regional chain security consensus device suitable for distributed power trading provided in an embodiment of the present application. DETAILED DESCRIPTION

[0075] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.

[0076] As the country deepens the reform of information technology in the energy trading system, the distributed power trading system has been further developed. Different from the traditional centralized one-to-many power supply mode, where one power generation organization provides power to many power users, in the distributed power trading scenario, there are a large number of small, independent power generation equipment or power generation individuals, which jointly provide efficient power output to power users in the system.

[0077] However, the development of blockchain technology is relatively limited at this stage, and it is unable to provide effective security protection for each key node in the system network layer, which hinders the efficient operation of the existing consensus mechanism and poses security risks. For example, in the peer-to-peer communication of the power trading blockchain, the existence of abnormal nodes will lead to security issues such as malicious delays and denial of service, increase the communication cost of the ledger consensus process, and reduce the efficiency of transaction confirmation, thus affecting the reliability and stability of the entire distributed power trading system.

[0078] To address this problem, the present application provides a regional chain security consensus method suitable for distributed power transactions. Figure 1 A flowchart of a regional chain security consensus method suitable for distributed power trading provided in an embodiment of the present application.

[0079] In addition, some relevant terms involved in this application are explained:

[0080] Distributed power trading: a power trading model based on distributed power generation. Different from traditional centralized power generation organizations, distributed power generation entities are small and decentralized single power generation equipment or power generation entities. Distributed power generation has the characteristics of small transmission losses, small environmental pollution, and high flexibility. In the present invention, distributed power trading refers to a power trading model that is different from the traditional centralized one-to-many architecture, that is, a large power generation organization provides power supply services to many electricity users, and uses blockchain as the underlying technology of distributed scenarios.

[0081] Abnormal nodes: In the distributed power trading scenario, abnormal nodes refer to those nodes that consciously or unconsciously disrupt the normal operation of the distributed system. They may deliberately delay the sending of consensus messages, conduct denial of service attacks, or maliciously join or exit the distributed network. Abnormal nodes may be manipulated by attackers, or they may be caused by node failures or other reasons. The emergence of abnormal nodes will seriously affect the reliability and security of the distributed power trading system, leading to problems such as reduced system performance, reduced transaction efficiency, and impaired user experience.

[0082] like Figure 1 As shown, the method comprises the following steps:

[0083] Step S1: In the distributed power trading system, each node is assigned an initial node credibility according to the order in which each node joins the blockchain network.

[0084] In the present application embodiment, Figure 2 As shown in the figure, before the consensus begins, if the credibility of each node in the system is not initialized, each node in the system is assigned an initial credibility CR according to the order in which it joins the blockchain network, which serves as the initial basis for the subsequent consensus process.

[0085] Step S2: Filter the high-credibility node array according to the credibility of the node, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus.

[0086] After the credibility is initialized in the system, the master node and the consensus nodes will be selected based on the credibility of each node. The remaining nodes will not participate in this round of consensus process due to their low credibility, but will synchronize data after the consensus is completed.

[0087] As a possible implementation method, the specific algorithm for consensus node division is as follows:

[0088] First, the credibility values ​​of all nodes in the blockchain are arranged in descending order as {CR1, CR2, ..., CR n}, where the number of all nodes in the blockchain is n;

[0089] Then, based on the lowest high-credibility node threshold, the arranged array is screened to determine the high-credibility node array arr CR = {CR1, CR2, ..., CR i}, where CR i ≥CR low , CR low is the minimum high-trust node threshold.

[0090] It should be noted that in order to avoid the regularity of the selection of the master node and the risk of malicious attacks, the master node in this application is randomly selected, and in order to avoid pseudo-randomness, this application adopts the following method to select the master node:

[0091] The first step is to select a random number k.

[0092] The second step is to generate k random integers between 1 and i and store them in a set S;

[0093] Step 3: For each integer in S, swap the number k with the number i-k+1.

[0094] Step 4: Randomly select a number q from the numbers 1 to ik and confirm that the master node is CRq;

[0095] Step 5: Determine all nodes participating in the consensus except CR q All other high-trust nodes except

[0096] It is understandable that ensuring that highly trusted nodes dominate consensus can improve the security and stability of the system.

[0097] This step realizes a distributed consensus process with anti-attack capabilities by sorting the credibility and randomly selecting the master node. In practical applications, the credibility of the node can also be adjusted in real time according to the transaction frequency and node performance, thereby further enhancing the robustness of the system. This application does not make additional explanations on this.

[0098] Step S3: When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data.

[0099] This step is used to execute the consensus mechanism and is divided into the following execution stages.

[0100] 1. Client request stage:

[0101] First, the client sends a CR to the primary node. q Make a request<<REQUEST,o,t,c> >, where t is the timestamp, o is the operation type, and c is the client that initiated the request. q After receiving the client request, a pre-preparation message is sent to all nodes participating in the consensus. These nodes receive the consensus pre-preparation phase message and start the consensus process.

[0102] 2. Consensus preparation stage:

[0103] Secondly, each node participating in the consensus prepares the message < <PRE PREPARE , v, p, d>, m> for verification, where v represents the view number. The view will only change when the credibility is updated. p represents the node number that sends the message, d represents the message digest, and m represents the original message data.

[0104] In the embodiment of the present application, if any of the following conditions is met, the verification fails and the client's request is rejected:

[0105] v in the prepare message is inconsistent with the current view;

[0106] d and m are repeated in previous messages;

[0107] Send message node CR p Not in the high confidence nodes array.

[0108] 3. Consensus preparation stage:

[0109] Then, if the verification is successful, the current consensus node agrees to the request and sends a consensus preparation message to other consensus nodes, records the message in the local log, and starts receiving consensus preparation messages sent from other consensus nodes. If the consensus preparation message of other consensus nodes is received, it means that the consensus preparation phase has been completed and the current consensus node enters the submission phase.

[0110] 4. Consensus submission phase:

[0111] The current consensus node sends a consensus commit message and starts receiving consensus commit messages from other consensus nodes. Finally, the current consensus node receives more than The consensus submission message of other consensus nodes is inserted into the local log for comparison and verification with the consensus submission message sent by itself until the consensus submission message is received. The valid consensus submission message of a node means that the consensus of this consensus node has been reached in this round.

[0112] 5. Execution request and result writing phase:

[0113] Finally, when all consensus nodes complete the consensus process, all nodes participating in the consensus execute the request and write the results to local data. Other low-credibility nodes that did not participate in the consensus do not participate in this round of consensus, but receive and synchronize the results from the high-credibility nodes participating in the consensus to complete the data writing.

[0114] This consensus mechanism combines the screening of highly trusted nodes with strict verification logic to ensure the security and stability of the system. Through multiple rounds of message delivery and verification, it improves the ability to resist malicious attacks and ensures the accuracy and consistency of data.

[0115] Step S4: The time series behavior data in the consensus process is collected through the master node, the time series behavior data is standardized, and the correlation coefficient matrix and eigenvalues ​​are calculated to select the principal components whose cumulative variance contribution rate is greater than the preset ratio for analysis, and the abnormal node detection model based on the LSTM neural network is used to detect abnormal nodes to obtain an abnormal node array.

[0116] This step is used to detect abnormal nodes during the consensus execution process.

[0117] First, the master node collects time series behavior data of all nodes participating in the consensus in real time during the consensus process. The time series behavior data includes total upstream network speed, total downstream network speed, node CPU occupancy, node memory occupancy, node upstream network speed, node downstream network speed, node file system occupancy, number of node peer node connections, etc.

[0118] Secondly, a mapping method is used to map the data points in the original high-dimensional space to the status space through the mapping relationship f: x->y (where x is the expression of the original data point and y is the low-dimensional expression of the data point after mapping), so as to reduce the number of random variables and obtain a set of "irrelevant" main variables. The anomaly detection model based on the LSTM neural network is used to detect anomalies in the collected consensus process data of each node. The algorithm flow is as follows:

[0119] The first step is to standardize the collected time series behavior data. For the time series behavior data X = (x1, x2, ..., x n ), where each dimension contains m sample data, then x j The sample mean of and standard deviation s j The calculation formula is:

[0120]

[0121] Among them, X is obtained after standardization to obtain an n-dimensional random variable Y = (y1, y2, ..., y n ), y j =(y 1j ,y 2j , ..., y nj ) T , where the standardized random variable y j The calculation formula is:

[0122] The second step is to calculate the correlation coefficient matrix based on the standardized random variables. The calculation formula is:

[0123] R=(r ij ) n×n

[0124]

[0125] Among them, R is the correlation coefficient matrix.

[0126] The third step is to calculate the eigenvalue λ corresponding to R i With the eigenvector μ i , arranged in descending orderλ1≥λ2≥…≥λ n ≥0, the eigenvalues ​​corresponding to the eigenvectors are μ1, μ2, ..., μ n , the corresponding principal components are Z1, Z2, ..., Z n .

[0127] The fourth step is to calculate the variance contribution rate ω of the jth component based on the eigenvalue j And the cumulative variance contribution rate α of the first p components p, the expression is:

[0128]

[0129] Then, in the distributed power trading scenario, select α p K principal components that are greater than 80% are used to replace the original n-dimensional data for analysis.

[0130] The fifth step is to detect anomalies in the collected consensus process data of each node based on the selected k principal components through the anomaly detection model based on the LSTM neural network, and output the abnormal node array arr abn .

[0131] In addition, the embodiment of the present application trains and optimizes the anomaly detection model based on the LSTM neural network through the following process: Figure 3 shown.

[0132] In the first step, the input layer divides the original time series data input to the prediction model into training sets F tr ={f1, f2, f3, ..., f p}, the length is p, and the length of the cutting window is set to L, then the length of the sliding window that can be used in the input layer is pL.

[0133] In the second step, when the time series data is input, the training set F tr According to the cutting window, L sliding windows are divided in sequence. Assume that the time series data after the original data is cut is I = {i1, i2, i3, ..., i L}, then the time series grouping corresponding to each sliding window contains pL data elements, and the distance between two adjacent time series data groups is equivalent to sliding forward or backward by the length of one data element.

[0134] In the third step, in the hidden layer, for each of the L consecutive input data sets, the hidden layer corresponding to the received data is also provided with L long short-term memory (LSTM) neuron cells. The I inputted by the input layer is calculated by the chain structure of the training layer and the output is recorded as O = {o1, o2, o3, ..., o L}, each item o of the output sequence i They are all calculated through the forward calculation method of the LSTM neuron cell interaction structure:

[0135] f t =σ(W f ·[h t-1 ,i t ]+b f )

[0136] x t =σ(W x ·[h t-1 ,i t ]+b x )

[0137]

[0138] o t =σ(W o ·[h t-1 ,i t ]+b o )

[0139]

[0140] Among them, σ() represents a fully connected layer with an activation function; tanh() represents the use of the tanh function as the activation function; h t-1 Represents the hidden state of the previous LSTM cell; i t Represents the input of the current LSTM cell; b f , b x , b C , b o Indicates the bias parameters of different function calculations; W f , W x , W c , W o Represents the weight parameters of different function calculations; f t represents the forget gate in the LSTM meta-cell; x t Represents the input gate in the LSTM meta-cell; Represents the candidate memory cell in the LSTM cell; C t Represents the memory cell in the LSTM cell; o t represents the output gate in the LSTM meta-cell; h t Represents the hidden state of the current LSTM meta-cell.

[0141] The overall expression can be written as:

[0142] o k =LSTM forward (i k , C k-1 , H k-1 )

[0143] Among them, H k-1 and C k-1 Represents the numerical output and cell state of an LSTM before the current neuron cell, i k Input layer input for the current meta-cell.

[0144] The fourth step is to calculate the loss function. The loss in the current state is expressed by calculating the mean square error value. The loss function in the prediction model training process can be finally expressed as:

[0145]

[0146] The fifth step is to iterate the model parameter values ​​to obtain the minimum value of 1oss. In the cyclic training process of the above prediction model, the ultimate goal of training is to obtain the parameter combination with the minimum loss value by continuously updating the parameters in the existing model.

[0147] In a possible embodiment of the present application, the Adam gradient optimization algorithm is used to optimize the current neural network, and the parameter value weight is continuously updated to obtain the optimal solution.

[0148] Step S5: traverse the array of abnormal nodes, downwardly update the credibility of each abnormal node, return to step S2, and continue to execute the next round of consensus process.

[0149] In the embodiment of the present application, for the abnormal node array arr abn , if the currently selected abnormal node is m, calculate the updated value CR of the abnormal node's credibility m ′=CR m (1-δ), where δ is the node credibility offset.

[0150] Then return to step S2, update and sort the credibility data of all nodes {CR1, CR2, ..., CR n}, and continue to the next round of consensus process.

[0151] In this embodiment, by collecting time series data and using the LSTM model to detect abnormal nodes, the credibility of the detected abnormal nodes is reduced. After the abnormal nodes are discovered, the possibility of their participation in the consensus is reduced. The node credibility is updated through continuous iteration, thereby ensuring the stability and security of the system.

[0152] In order to implement the above embodiments, the present application also proposes a regional chain security consensus device suitable for distributed power trading. Figure 4 This is a schematic diagram of the structure of a regional chain security consensus device suitable for distributed power trading provided in an embodiment of the present application. Figure 4 As shown, the device comprises:

[0153] The credibility initialization module 100 is used in the distributed power trading system to assign initial node credibility to each node according to the order in which each node joins the blockchain network;

[0154] The consensus node division module 200 is used to screen the high-credibility node array according to the credibility of the nodes, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus;

[0155] The consensus execution module 300 is used to send a pre-prepared message to all nodes participating in the consensus when the master node receives the consensus request from the client. Each consensus node verifies the message based on its consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result into local data.

[0156] Malicious behavior detection module 400, used to collect time series behavior data in the consensus process through the master node, standardize the time series behavior data, and calculate the correlation coefficient matrix and eigenvalues ​​to select the principal component with a cumulative variance contribution rate greater than a preset ratio for analysis, and use the anomaly detection model based on the LSTM neural network to detect abnormal nodes and obtain an abnormal node array;

[0157] The credibility adjustment and circulation module 500 is used to traverse the abnormal node array, downwardly adjust and update the credibility of each abnormal node, and continue to execute the next round of consensus process.

[0158] In order to implement the above embodiments, the present application also proposes an electronic device, comprising: a processor, and a memory communicatively connected to the processor; the memory stores computer-executable instructions; the processor executes the computer-executable instructions stored in the memory to implement the method provided by the above embodiments.

[0159] In order to implement the above embodiments, the present application also proposes a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the methods provided by the above embodiments.

[0160] In order to implement the above embodiments, the present application also proposes a computer program product, including a computer program, which implements the methods provided by the above embodiments when executed by a processor.

[0161] The collection, storage, use, processing, transmission, provision and disclosure of user personal information involved in this application are in compliance with relevant laws and regulations and do not violate public order and good morals.

[0162] It should be noted that personal information from users should be collected for legitimate and reasonable purposes and should not be shared or sold outside of these legitimate uses. In addition, such collection / sharing should be carried out after receiving the user's informed consent, including but not limited to notifying the user to read the user agreement / user notice and sign the agreement / authorization including authorization of relevant user information before the user uses the function. In addition, any necessary steps should be taken to protect and safeguard access to such personal information data and ensure that others who have access to personal information data comply with its privacy policy and procedures.

[0163] The present application is expected to provide an implementation scheme for users to selectively block the use or access of personal information data. That is, the present disclosure is expected to provide hardware and / or software to prevent or block access to such personal information data. Once the personal information data is no longer needed, the risk can be minimized by limiting data collection and deleting the data. In addition, when applicable, such personal information is de-identified to protect the privacy of the user.

[0164] In the description of the aforementioned embodiments, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.

[0165] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0166] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.

[0167] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.

[0168] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.

[0169] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.

[0170] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.

[0171] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.

Claims

1. A regional chain security consensus method suitable for distributed power trading, characterized in that: The following steps are involved: S1. In the distributed power trading system, each node is assigned an initial node credibility according to the order in which each node joins the blockchain network; S2. Filter the high-credibility node array according to the credibility of the nodes, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus; S3. When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data. S4. The master node collects the time series behavior data in the consensus process, standardizes the time series behavior data, and calculates the correlation coefficient matrix and eigenvalues ​​to select the principal components whose cumulative variance contribution rate is greater than the preset ratio for analysis, and uses the anomaly detection model based on the LSTM neural network to detect abnormal nodes to obtain an abnormal node array; S5. Traverse the abnormal node array, downwardly update the credibility of each abnormal node, return to step S2, and continue to execute the next round of consensus process.

2. The method according to claim 1, characterized in that The method of selecting a high-credibility node array according to the credibility of the nodes includes: The credibility values ​​of all nodes in the blockchain are arranged in descending order as {CR1, CR2, …, CR n }, where the number of all nodes in the blockchain is n; Based on the lowest high-credibility node threshold, the nodes in the arranged array are screened to determine the high-credibility node array arr CR = {CR1, CR2, ..., CR i }, where CR i ≥CR low , CR low is the minimum high-trust node threshold.

3. The method according to claim 2, characterized in that The method randomly selects a high-credibility node from the high-credibility node array as the master node, and uses the remaining high-credibility nodes as all nodes participating in the consensus, including: Choose a random number k, Generate k random integers between 1 and i and store them in a set S; For each integer in S, swap the number k with the number i-k+1; Randomly select a number q from numbers 1 to ik and confirm that the master node is CR q ; Determine that all nodes participating in the consensus are excluding CR q All other high-trust nodes except 4. The method according to claim 3, characterized in that When the master node receives the client consensus request, it sends a pre-prepared message to all nodes participating in the consensus. Each consensus node verifies the message based on consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result to local data, including: The client sends CR to the master node q Make a request<<REQUEST,o,t,c> >, where t is the timestamp, o is the operation type, and c is the client that initiated the request; When the master node CR q After receiving the client request, send a pre-prepare message to all nodes participating in the consensus< <PRE PREPARE ,v,p,d>,m>, where v represents the view number, the view will change only when the credibility is updated, p represents the node number that sends the message, d represents the message digest, and m represents the original message data; Each node participating in the consensus verifies the pre-preparation message. If the verification is successful, the current consensus node agrees to the request and sends a consensus preparation message to other consensus nodes, records the message in the local log, and starts receiving consensus preparation messages sent from other consensus nodes; Within the preset time range, if the current consensus node receives more than The current consensus node enters the commit phase, sends a consensus commit message, and starts receiving consensus commit messages sent from other consensus nodes. If the current consensus node receives more than The consensus submission message of other consensus nodes is inserted into the local log for comparison and verification with the consensus submission message sent by itself until the consensus submission message is received. The valid consensus submission message of the node, and the consensus of this consensus node has been reached in this round; When all consensus nodes complete the consensus process, all nodes participating in the consensus execute the request and write the results to local data. Other low-credibility nodes that did not participate in the consensus do not participate in this round of consensus, but receive and synchronize the results from the high-credibility nodes participating in the consensus to complete the data writing.

5. The method according to claim 4, characterized in that If v in the pre-prepared message is inconsistent with the current view or d and m are repeated in the previous message or the message node CR is sent p If it is not in the high-trust node array, the verification fails and the client's request is rejected.

6. The method according to claim 5, characterized in that The master node collects the time series behavior data in the consensus process, standardizes the time series behavior data, and calculates the correlation coefficient matrix and eigenvalues ​​to select the principal component with a cumulative variance contribution rate greater than a preset ratio for analysis, and uses an anomaly detection model based on an LSTM neural network to detect abnormal nodes, and obtains an abnormal node array, including: The master node collects the time series behavior data of all nodes participating in the consensus in the execution of the consensus process in real time. The time series behavior data includes the total upstream network speed, the total downstream network speed, the node CPU occupancy, the node memory occupancy, the node upstream network speed, the node downstream network speed, the node file system occupancy, and the number of node peer node connections; The time series behavior data is standardized. For the time series behavior data X=(x1, x2, ..., x n ), where each dimension contains m sample data, then x j The sample mean of and standard deviation s j The calculation formula is: Among them, X is obtained after standardization to obtain an n-dimensional random variable Y = (y1, y2, ..., y n ), y j =(y 1j ,y 2j , ..., y nj ) T , where the standardized random variable y j The calculation formula is: The correlation coefficient matrix is ​​calculated based on the standardized random variables. The calculation formula is: R=(r ij ) n×n Wherein, R is the correlation coefficient matrix; Calculate the eigenvalue λ corresponding to R i With the eigenvector μ i , arranged in descending orderλ1≥λ2≥…≥λ n ≥0, the eigenvalues ​​corresponding to the eigenvectors are μ1, μ2, ..., μ n , the corresponding principal components are Z1, Z2, ..., Z n ; Calculate the variance contribution rate ω of the jth component based on the eigenvalue j And the cumulative variance contribution rate α of the first p components p , the expression is: Select α p K principal components greater than 80% are used to replace the original n-dimensional data for analysis; According to the selected k principal components, the anomaly detection model based on LSTM neural network is used to detect anomalies in the consensus process data of each node, and the abnormal node array arr is output. abn .

7. The method according to claim 6, characterized in that The traversing the abnormal node array and downwardly updating the credibility of each abnormal node includes: For abnormal node array arr abn , if the currently selected abnormal node is m, calculate the updated value CR of the abnormal node's credibility m ′=CR m (1-δ), where δ is the node credibility offset.

8. A regional chain security consensus device suitable for distributed power trading, characterized in that: include: The credibility initialization module, in the distributed power trading system, is used to assign initial node credibility to each node according to the order in which each node joins the blockchain network; The consensus node division module is used to screen the high-credibility node array according to the credibility of the nodes, randomly select a high-credibility node from the high-credibility node array as the master node, and use the remaining high-credibility nodes as all nodes participating in the consensus; The consensus execution module is used to send a pre-prepared message to all nodes participating in the consensus when the master node receives the consensus request from the client. Each consensus node verifies the message based on its consistency and credibility. After the consensus is completed, all nodes participating in the consensus execute the request and write the result into local data. A malicious behavior detection module is used to collect time series behavior data in the consensus process through the master node, standardize the time series behavior data, and calculate the correlation coefficient matrix and eigenvalues ​​to select the principal component with a cumulative variance contribution rate greater than a preset ratio for analysis, and use an anomaly detection model based on the LSTM neural network to detect abnormal nodes to obtain an abnormal node array; The credibility adjustment and loop module is used to traverse the abnormal node array, downwardly update the credibility of each abnormal node, and continue to execute the next round of consensus process.

9. An electronic device, characterized in that: include: A processor, and a memory communicatively connected to the processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory to implement the method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 7 when executed by a processor.