Blockchain information management method, device, storage medium and electronic device
By introducing a data detection model into the blockchain network, the data to be saved is detected in the consensus process. If the rules are violated, the consensus process is terminated, which solves the problem of difficult deletion of illegal information in the blockchain and achieves efficient information governance.
Patent Information
- Application Number
- CN202111266354.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-28
- Publication Date
- 2025-05-02
- Estimated Expiration
- 2041-10-28
AI Technical Summary
The distributed and immutable characteristics of blockchain make it difficult to review and delete information, especially in blockchain networks where multiple nodes participate, it is difficult to delete illegal information after being put on the chain.
The data detection model is introduced in the blockchain network, and by detecting the data to be saved during the consensus process. If the detection results indicate that the data is illegal, the consensus process will be terminated to prevent illegal information from being chained. The data detection model is obtained based on violation and compliance data training.
It effectively avoids illegal information on the link, reduces resource waste, and saves labor costs. By conducting detection and governance at the consensus level, the efficiency of information governance is improved.
Smart Images

Figure CN114036224B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and specifically, to a blockchain information governance method, device, storage medium and electronic device. Background Art
[0002] As an emerging technology, blockchain technology has the characteristics of distributed ledger, decentralization and non-tamperability, which makes the information stored on the blockchain permanently preserved. This method is not only convenient for users to retrieve, but also ensures the security and availability of information.
[0003] However, the distributed and tamper-proof characteristics of blockchain also make it difficult to review information as easily as in traditional centralized platform systems. The tamper-proof characteristics make it difficult to delete illegal information once it is uploaded to the chain, and this problem is particularly serious in blockchain networks with many participating nodes. Summary of the invention
[0004] The purpose of the present disclosure is to provide a blockchain information governance method, device, storage medium and electronic device to solve the above-mentioned related technical problems.
[0005] In order to achieve the above-mentioned purpose, according to the first aspect of the embodiment of the present disclosure, a blockchain information governance method is provided, which is applied to a target node in a blockchain network, wherein the target node is any node participating in the consensus in the blockchain network, and the method comprises:
[0006] Receiving a data upload request, wherein the data upload request includes data to be saved;
[0007] In the process of reaching consensus on the data to be saved, the data to be saved is detected by a data detection model to obtain a detection result of the data to be saved;
[0008] When the detection result indicates that the data to be saved violates a rule, terminating the consensus process for the data to be saved;
[0009] The data detection model is trained based on illegal data and compliant data.
[0010] Optionally, terminating the consensus process for the data to be saved includes:
[0011] When the consensus method is the proof-of-work algorithm, stop generating random numbers; or,
[0012] When the consensus method is the raft algorithm, stop participating in the leader election within the preset time.
[0013] Optionally, the following steps are repeated until the model converges to obtain the data detection model:
[0014] Acquire sample data, where the sample data includes historical data to be saved received by multiple nodes participating in consensus in the blockchain network;
[0015] Adjusting the activation function of the model according to the state parameters of the blockchain network;
[0016] Using the sample data as input of the model to obtain an output result of the model;
[0017] Calculate the loss value according to the output result of the model;
[0018] The weight values in the model are adjusted according to the loss value.
[0019] Optionally, the state parameter of the blockchain network includes a length value of the blockchain.
[0020] Optionally, adjusting the activation function of the model according to the state parameters of the blockchain network includes:
[0021] Calculating a ratio of a length value of the blockchain to a number value of neurons in the model to obtain a first ratio;
[0022] When the first ratio is less than a first threshold, using a first activation function as an activation function of the model;
[0023] When the first ratio is greater than a first threshold, a second activation function is used as the activation function of the model, and a change trend of the second activation function is smoother than a change trend of the first activation function.
[0024] Optionally, the first activation function f1(x) is:
[0025]
[0026] The second activation function f2(x) is:
[0027]
[0028] Among them, num1 is a preset value, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0029] Optionally, the state parameter of the blockchain network further includes the number of participating nodes in the blockchain network, and adjusting the activation function of the model according to the state parameter of the blockchain network includes:
[0030] Calculate the product of the length value of the blockchain and the number value of the participating nodes to obtain a first product;
[0031] Calculating a ratio of the first product to the number of neurons in the model to obtain a second ratio;
[0032] When the second ratio is less than a second threshold, using the first activation function as the activation function of the model;
[0033] When the second ratio is greater than a second threshold, a third activation function is used as the activation function of the model, and a change trend of the third activation function is smoother than a change trend of the first activation function.
[0034] Optionally, the third activation function f3(x) is:
[0035]
[0036] Among them, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0037] Optionally, it also includes:
[0038] During multiple trainings of the model, adjusting activation parameters based on state parameters of the blockchain network; and
[0039] Selecting a target neuron from the neurons of the model according to the activation parameter;
[0040] In this training, the target neuron is set to an inactive state.
[0041] Optionally, the state parameters of the blockchain network include a length value of the blockchain and a number value of participating nodes in the blockchain network, and adjusting the activation parameters based on the state parameters of the blockchain network includes:
[0042] When the length value of the blockchain is less than a third threshold, the activation parameter is a preset activation parameter;
[0043] When the length of the blockchain is greater than the third threshold, the activation parameter is calculated by the following calculation formula:
[0044]
[0045] Wherein, p is the activation parameter, p * is the preset activation parameter, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, num(peer) is the number of nodes participating in the blockchain, * is the number of initial participating nodes in the blockchain network.
[0046] According to a second aspect of an embodiment of the present disclosure, a blockchain information governance device is provided, which is applied to a target node in a blockchain network, wherein the target node is any node participating in consensus in the blockchain network, and the device includes:
[0047] A receiving module, used to receive a data uplink request, wherein the data uplink request includes data to be saved;
[0048] A data detection module, used to detect the data to be saved by using a data detection model during the process of reaching consensus on the data to be saved, so as to obtain a detection result of the data to be saved;
[0049] An execution module, configured to terminate a consensus process for the data to be saved if the detection result indicates that the data to be saved is in violation of a rule;
[0050] The data detection model is trained based on illegal data and compliant data.
[0051] Optionally, the execution module is used to:
[0052] When the consensus method is the proof-of-work algorithm, stop generating random numbers; or,
[0053] When the consensus method is the raft algorithm, stop participating in the leader election within the preset time.
[0054] Optionally, the device further includes a model training module, which is used to repeatedly perform the following steps until the model converges to obtain the data detection model, and the model training module includes:
[0055] An acquisition submodule, used to acquire sample data, wherein the sample data includes historical data to be saved received by multiple nodes participating in the consensus in the blockchain network;
[0056] A parameter adjustment submodule, used to adjust the activation function of the model according to the state parameters of the blockchain network;
[0057] An input submodule, used to use the sample data as the input of the model to obtain the output result of the model;
[0058] A calculation submodule, used to calculate the loss value according to the output result of the model;
[0059] The weight adjustment submodule is used to adjust the weight value in the model according to the loss value.
[0060] Optionally, the state parameter of the blockchain network includes a length value of the blockchain.
[0061] Optionally, the parameter adjustment submodule includes:
[0062] A first calculation subunit is used to calculate the ratio of the length value of the blockchain to the number of neurons in the model to obtain a first ratio;
[0063] a first model setting subunit, configured to use a first activation function as an activation function of the model when the first ratio is less than a first threshold;
[0064] The second model setting subunit is used to use a second activation function as the activation function of the model when the first ratio is greater than a first threshold, and the change trend of the second activation function is smoother than that of the first activation function.
[0065] Optionally, the first activation function f1(x) is:
[0066]
[0067] The second activation function f2(x) is:
[0068]
[0069] Among them, num1 is a preset value, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0070] Optionally, the state parameter of the blockchain network also includes the number of participating nodes in the blockchain network, and the parameter adjustment submodule includes:
[0071] A second calculation subunit is used to calculate the product of the length value of the blockchain and the number value of the participating nodes to obtain a first product;
[0072] A third calculation subunit is used to calculate the ratio of the first product to the number of neurons in the model to obtain a second ratio;
[0073] a third model setting subunit, configured to use the first activation function as the activation function of the model when the second ratio is less than a second threshold;
[0074] The fourth model setting subunit is used to use a third activation function as the activation function of the model when the second ratio is greater than a second threshold, and the change trend of the third activation function is smoother than the change trend of the first activation function.
[0075] Optionally, the third activation function f3(x) is:
[0076]
[0077] Among them, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0078] Optionally, the device further comprises:
[0079] An activation parameter adjustment module, configured to adjust activation parameters based on state parameters of the blockchain network during multiple trainings of the model; and
[0080] A neuron selection module, used for selecting a target neuron from the neurons of the model according to the activation parameter;
[0081] The neuron setting module is used to set the target neuron to an inactive state in this training.
[0082] Optionally, the state parameter of the blockchain network includes a length value of the blockchain and a number value of participating nodes in the blockchain network, and the activation parameter adjustment module is used to:
[0083] When the length value of the blockchain is less than a third threshold, setting the activation parameter to a preset activation parameter;
[0084] When the length of the blockchain is greater than the third threshold, the activation parameter is calculated by the following calculation formula:
[0085]
[0086] Wherein, p is the activation parameter, p * is the preset activation parameter, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, num(peer) is the number of nodes participating in the blockchain, * is the number of initial participating nodes in the blockchain network.
[0087] According to a third aspect of an embodiment of the present disclosure, there is provided a non-temporary computer-readable storage medium on which a computer program is stored, and when the program is executed by a processor, the steps of any one of the methods described in the first aspect are implemented.
[0088] According to a fourth aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0089] a memory having a computer program stored thereon;
[0090] A processor is used to execute the computer program in the memory to implement the steps of any one of the methods described in the first aspect above.
[0091] In the above technical solution, after receiving the request to upload data to the chain, the nodes participating in the consensus in the blockchain network can detect the data to be saved through the data detection model during the consensus stage. In the case where the detection result indicates that the data to be saved is illegal, the nodes participating in the consensus can terminate the consensus process for the data to be saved, thereby avoiding the illegal information from being uploaded to the chain. In this way, detection and governance can be performed before the information is uploaded to the chain. In addition, the above technical solution detects illegal data at the consensus layer, which can save labor costs compared to the method of detecting at the application layer by calling the data detection smart contract (contract calls require manual review).
[0092] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0093] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:
[0094] Figure 1 It is a flowchart of a blockchain information governance method shown in an exemplary embodiment of the present disclosure.
[0095] Figure 2 It is a schematic diagram of a model training step shown in an exemplary embodiment of the present disclosure.
[0096] Figure 3 It is a schematic diagram of a model training step shown in an exemplary embodiment of the present disclosure.
[0097] Figure 4 It is a schematic diagram of a model training step shown in an exemplary embodiment of the present disclosure.
[0098] Figure 5 It is a schematic diagram of a neural network shown in an exemplary embodiment of the present disclosure.
[0099] Figure 6 It is a block diagram of a blockchain information governance device shown in an exemplary embodiment of the present disclosure.
[0100] Figure 7 It is a block diagram of an electronic device shown in an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0101] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.
[0102] Before introducing the blockchain information governance method, device, storage medium and electronic device disclosed in the present invention, the application scenarios of the present invention are first introduced. The various embodiments provided in the present invention can be used to govern blockchain network information, thereby reducing the risk of illegal information being uploaded to the chain.
[0103] In relevant scenarios, illegal information can be governed through smart contracts. For example, an information supervision smart contract can be deployed in the blockchain network, so that other business contracts can call the information supervision smart contract to govern illegal information. However, with this information governance method, the information supervision smart contract needs to be coupled with the business contract, that is, it is necessary to call the information supervision smart contract to perform the information detection process before each ledger operation, thereby increasing the calling cost of the smart contract.
[0104] Moreover, this information governance method is inflexible. Since the main body of the blockchain system is relatively decentralized and the deployment of smart contracts can be initiated by any participating node, in order to determine the fact that the information supervision smart contract is called (for example, the node may maliciously not perform information detection), it is also necessary to manually review the call of the information supervision smart contract, which ultimately leads to increased operation and maintenance costs.
[0105] To this end, the present disclosure provides a blockchain information governance method, which is applied to a target node in a blockchain network, wherein the target node is any node participating in consensus in the blockchain network. Figure 1 This is a flowchart of a blockchain information governance method shown in the present disclosure, referring to Figure 1 , the method comprising:
[0106] In step 11, a data uplink request is received, where the data uplink request includes data to be saved.
[0107] Here, the data on-chain request may be presented in the form of a transaction, for example. For example, after a transaction client generates a new transaction, the transaction may be broadcast to the blockchain network, thereby requesting that the transaction data be recorded and saved.
[0108] In step 12, in the process of reaching consensus on the data to be saved, the data to be saved is detected by a data detection model to obtain a detection result of the data to be saved. The data detection model is trained based on the illegal data and the compliant data.
[0109] For example, an information detection model can be set at the consensus layer of the blockchain network. In this way, each node participating in the consensus (hereinafter referred to as the consensus node) can call the information detection model to detect the data to be uploaded to the chain during the consensus process of the data to be uploaded to the chain.
[0110] Here, taking the public chain network as an example, the difference between the data detection process in this embodiment and the data detection process based on smart contracts in related scenarios is explained. In the scenario of data detection based on smart contracts, after the client generates a new transaction, the transaction can be broadcast on the blockchain network. In this way, each consensus node in the blockchain network can package the information in the transaction into a block of the node after receiving the transaction. The consensus node can also strive for the right to record accounts by proof of work (i.e., exhaustively generating random numbers that meet the requirements of the proof of work algorithm). Then, the consensus node that obtains the right to record accounts can call the information detection smart contract to detect the information in the block packaged by the node, and after the detection passes, a new block can be generated and broadcast. In this way, as the new block spreads, the transaction data is saved in the blockchain. It should be noted that even if the consensus node that obtains the right to record accounts detects data anomalies, the consensus process of the entire network has been completed and the consensus overhead has been generated, so this method may also have the problem of resource waste.
[0111] In this embodiment, after the client generates a new transaction, it can broadcast the transaction on the blockchain network. In this way, after receiving the transaction, each consensus node in the blockchain network can call the information detection model to detect the transaction data to be uploaded. When the detection passes, each consensus node can reach a consensus through the proof-of-work algorithm and save the transaction data to the blockchain.
[0112] In step 13, when the detection result indicates that the data to be saved is in violation of the rules, the consensus process for the data to be saved is terminated.
[0113] The violation of the data to be saved may refer to the data to be saved including preset violation information, sensitive data, etc. When the violation of the data to be saved is detected, the consensus node may terminate the consensus process for the data to be saved, thereby reducing resource waste.
[0114] For example, in some implementation scenarios, each consensus node in the blockchain network completes consensus through a proof-of-work algorithm. In this case, when the consensus node detects that the data to be saved violates the rules, it can stop the random number generation process. In this way, since the data to be saved cannot be consensused, it can prevent the data to be saved from being saved in the blockchain.
[0115] In some implementation scenarios, each consensus node in the blockchain network reaches consensus through the raft algorithm. In this case, when the consensus node detects that the data to be saved violates the rules, it can stop participating in the election of the leader within a preset time. In this way, due to the absence of the leader, the data to be saved cannot be consensused, so the data to be saved can be prevented from being saved in the blockchain. Of course, for the normal operation of the blockchain network, the preset time can also be set according to the application requirements so that other transaction data can be processed and saved normally, and the present disclosure does not limit this.
[0116] It is worth noting that in the above embodiment, when the consensus node determines that the data to be saved violates the rules, it can terminate the consensus process for the data to be saved. In other words, the detection result of the consensus node affects the processing strategy of the consensus node itself, and other consensus nodes can continue the consensus process.
[0117] For example, in a related alliance chain scenario, for a proposal of a target transaction, each consensus node can endorse the transaction proposal, and generate endorsement authentication information after the endorsement verification is passed. The endorsement authentication information may include the signature of the consensus node. In this way, when the transaction proposal has a threshold number of endorsements (such as more than 50% of the number of consensus nodes), it can be determined that the transaction proposal has completed the consensus, and then the target transaction can be submitted, and the information of the target transaction can be saved in the blockchain. When a consensus node detects that the transaction proposal violates the rules, it can refuse to generate the endorsement authentication information. Moreover, based on the version consistency of the blockchain nodes, the verification process of the transaction proposal by other consensus nodes is consistent, so other consensus nodes cannot generate endorsement authentication information. In this way, due to the insufficient number of endorsements, the transaction proposal cannot proceed, and the data of the target transaction cannot be saved in the blockchain.
[0118] In this way, it is possible to prevent individual consensus nodes from doing evil, causing legitimate information to fail to pass verification, and thus causing blockchain system failures.
[0119] In addition, please refer to the description of the relevant technology for the execution process of the proof of work algorithm and the raft algorithm. For the sake of brevity, this disclosure will not elaborate on it here. Moreover, in some implementation scenarios, the blockchain network may also adopt other consensus algorithms (such as the Proof of Stake algorithm). In this case, the nodes participating in the consensus may also terminate the consensus algorithm when determining that the data to be saved is in violation of the rules. This disclosure does not limit the type of consensus algorithm.
[0120] In the above technical solution, after receiving the request to upload data to the chain, the nodes participating in the consensus in the blockchain network can detect the data to be saved through the data detection model during the consensus stage. In the case where the detection result indicates that the data to be saved is illegal, the nodes participating in the consensus can terminate the consensus process for the data to be saved, thereby avoiding the illegal information from being uploaded to the chain. In other words, the above technical solution can review information through each consensus node and will not affect the execution logic of the consensus node itself. At the same time, this method is compatible with multiple consensus algorithms such as proof of work and raft, and can perform detection and governance before information is uploaded to the chain.
[0121] In addition, the above technical solution detects illegal data at the consensus layer. Compared with the detection method at the application layer by calling data detection smart contracts (contract calls require manual review), it can also reduce the cost of contract calls and save labor costs.
[0122] Next, the training process of the data detection model disclosed in the present invention is explained. Figure 2 It is a schematic diagram of a model training step shown in the present disclosure. In some implementation scenarios, the following steps can be repeatedly performed until the model converges to obtain the data detection model:
[0123] S21, obtaining sample data.
[0124] The sample data includes historical data to be saved received by multiple nodes participating in the consensus in the blockchain network. It should be understood that the historical data to be saved received by the participating nodes may include compliance data and non-compliance data. In specific implementation, a certain proportion of data can be extracted from the historical data to be saved received by multiple nodes participating in the consensus as the sample data. In addition, feature extraction (such as part-of-speech features, term features) can also be performed on the historical data to be saved to facilitate subsequent processing.
[0125] Of course, in some implementation scenarios, the sample data may also include preset target data, such as manually constructed training data, etc., and the present disclosure does not impose any limitation on this.
[0126] S22, adjust the activation function of the model according to the state parameters of the blockchain network.
[0127] The identification of illegal information belongs to the category of natural language processing, so in some implementation scenarios, the data detection model can be constructed based on a recurrent neural network. Compared with traditional neural networks, in a recurrent neural network, the "historical information" of neurons at the previous moment can be connected to neurons at the next moment through weights, which makes the recurrent neural network have memory.
[0128] In order to avoid the gradient vanishing phenomenon in the recurrent neural network during the training process, in this embodiment, the activation function of the model can be dynamically adjusted according to the state parameters of the blockchain network, thereby adjusting the saturation area of the neuron.
[0129] For example, in some implementation scenarios, the state parameter of the blockchain network may include the length value of the blockchain. In this case, refer to Figure 3 A schematic diagram of a model training step is shown, wherein adjusting the activation function of the model (S22) according to the state parameters of the blockchain network includes:
[0130] S221, calculating the ratio of the length value of the blockchain to the number of neurons in the model to obtain a first ratio.
[0131] S222: When the first ratio is less than a first threshold, use the first activation function as an activation function of the model.
[0132] Among them, the first threshold can be set according to application requirements. In this embodiment, for example, the first threshold can be set to e. It should be understood that when the first ratio is less than the first threshold, it can be determined that the blockchain network and the model are in a relatively initial state. At this time, the participating nodes receive less historical data to be saved, and the number of sample data and the number of iterations of the model are also less. Therefore, in some implementation scenarios, the first activation function f1(x) can be set to:
[0133]
[0134] It should be understood that when the sample data is small and the number of model iterations is small, the probability of gradient vanishing is low. Therefore, the first activation function can be used to speed up the convergence of the model.
[0135] S223: When the first ratio is greater than a first threshold, use a second activation function as an activation function of the model, wherein a change trend of the second activation function is smoother than a change trend of the first activation function.
[0136] For example, the second activation function f2(x) may be:
[0137]
[0138] Among them, num1 is a preset value, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0139] It should be understood that when there is a large amount of sample data and a large number of model iterations, the gradient may vanish. Therefore, when the first ratio is greater than the first threshold, that is, when there is a large amount of sample data and a large number of model iterations, an activation function with a relatively slow change speed can be set to prevent the model from having a dead zone and avoid the problem of gradient vanishing.
[0140] S23, using the sample data as the input of the model to obtain the output result of the model.
[0141] S24, calculating a loss value according to the output result of the model. Here, for example, a cross entropy loss function may be used to calculate the loss value.
[0142] S25, adjusting the weight values in the model according to the loss value. For example, the weight values of neurons in each layer of the model can be adjusted based on the loss value by back propagation calculation.
[0143] The above technical solution can realize dynamic adjustment of the activation function of the model by combining the state parameters of the blockchain network. In this way, when there are few sample data and few model iterations, the activation function can be adjusted to improve the convergence speed of the model. When there are many sample data and many model iterations, the activation function can be adjusted to prevent the phenomenon of gradient disappearance. In other words, the above technical solution can improve the training effect of the model, and thus help improve the detection accuracy of the data detection model for abnormal data.
[0144] In some implementation scenarios, the state parameter of the blockchain network includes the number of participating nodes in the blockchain network and the length of the blockchain. Figure 4 A schematic diagram of the steps of model training shown in FIG. Figure 2 Based on the state parameters of the blockchain network, adjusting the activation function of the model (S22) includes:
[0145] S224, calculating the product of the length value of the blockchain and the number of participating nodes to obtain a first product.
[0146] S225, calculating the ratio of the first product to the number of neurons in the model to obtain a second ratio.
[0147] S226: When the second ratio is less than a second threshold, use the first activation function as the activation function of the model.
[0148] Among them, the second threshold can be set according to application requirements. In this embodiment, for example, the second threshold can be set to e (the second threshold can be the same as or different from the first threshold). It should be understood that when the second ratio is less than the second threshold, it can be determined that the blockchain network and the model are in a relatively initial state. At this time, the participating nodes receive less historical data to be saved, and the number of sample data and the number of iterations of the model are also less. Therefore, in some implementation scenarios, the first activation function f1(x) can be set to:
[0149]
[0150] It should be understood that when the sample data is small and the number of model iterations is small, the probability of gradient vanishing is low. Therefore, the first activation function can be used to speed up the convergence of the model.
[0151] S227: When the second ratio is greater than a second threshold, use a third activation function as the activation function of the model, wherein a change trend of the third activation function is smoother than a change trend of the first activation function.
[0152] It should be understood that when there is a large amount of sample data and a large number of model iterations, the gradient may vanish. Therefore, when the second ratio is greater than the second threshold, that is, when there is a large amount of sample data and a large number of model iterations, an activation function with a relatively slow change speed can be set to prevent the model from having a dead zone and avoid the problem of gradient vanishing.
[0153] For example, the third activation function f3(x) may be:
[0154]
[0155] Among them, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0156] The above technical solution can realize dynamic adjustment of the activation function of the model by combining the number of participating nodes in the blockchain network and the length of the blockchain. In this way, when there are few sample data and few model iterations, the activation function can be adjusted to improve the convergence speed of the model. When there are many sample data and many model iterations, the activation function can be adjusted to prevent the phenomenon of gradient disappearance. In other words, the above technical solution can improve the training effect of the model, and thus help improve the detection accuracy of the data detection model for abnormal data.
[0157] It is worth noting that when there is less sample data, speeding up the convergence of the model may also cause the model to overfit, that is, the model performs better in the training data but worse in the test data.
[0158] To this end, in a possible implementation, the activation parameters may also be adjusted based on the state parameters of the blockchain network during multiple trainings of the model.
[0159] For example, the state parameter of the blockchain network may include the length value of the blockchain and the number of participating nodes in the blockchain network. In this case, adjusting the activation parameter based on the state parameter of the blockchain network includes:
[0160] When the length value of the blockchain is less than the third threshold, the activation parameter is a preset activation parameter. The third threshold can be set according to application requirements. As an example, the third threshold can be set to 1000. The preset activation parameter can also be set according to application requirements, and the present disclosure does not limit this.
[0161] When the length of the blockchain is greater than the third threshold, the activation parameter is calculated by the following calculation formula:
[0162]
[0163] Wherein, p is the activation parameter, p * is the preset activation parameter, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, num(peer) is the number of nodes participating in the blockchain, * is the number of initial participating nodes in the blockchain network.
[0164] In this way, a target neuron can be selected from the neurons of the model according to the activation parameter, and in this training, the target neuron can be set to an inactive state.
[0165] Figure 5 5A is a schematic diagram of a neural network shown in the present disclosure, wherein each neuron is connected in sequence to form a neural network. By determining the activation parameters and selecting neurons according to the activation parameters, for example, the following can be obtained: Figure 5 The neural network described in B.
[0166] In specific implementation, for example, the above process can be implemented based on the dropout technology. In this way, by randomly discarding the activation of some neurons during training, the model's dependence on local features can be reduced (because local features may be discarded), thereby improving the robustness of the model and enhancing the model's ability to identify abnormal data.
[0167] By adopting the above technical solution, during the training process of the model, the probability p of neuron discarding can be dynamically adjusted according to the state parameters of the blockchain network. When the number of participating nodes is small and the length of the blockchain is short (less historical data), discarding occurs with a higher probability to avoid overfitting. When the number of participating nodes is large and the length of the blockchain is long, discarding occurs with a lower probability, thereby improving the model's recognition accuracy of abnormal data.
[0168] Based on the same inventive concept, the present disclosure also provides a blockchain information governance device, which is applied to a target node in a blockchain network, and the target node is any node participating in the consensus in the blockchain network. Figure 6 600 is a block diagram of a blockchain information governance device shown in the present disclosure, and the device 600 includes:
[0169] A receiving module 601 is used to receive a data uplink request, where the data uplink request includes data to be saved;
[0170] The data detection module 602 is used to detect the data to be saved by using a data detection model during the process of reaching consensus on the data to be saved, so as to obtain a detection result of the data to be saved;
[0171] An execution module 603 is configured to terminate a consensus process for the data to be saved when the detection result indicates that the data to be saved is in violation of a rule;
[0172] The data detection model is trained based on illegal data and compliant data.
[0173] In the above technical solution, after receiving the request to upload data to the chain, the nodes participating in the consensus in the blockchain network can detect the data to be saved through the data detection model during the consensus stage. In the case where the detection result indicates that the data to be saved is illegal, the nodes participating in the consensus can terminate the consensus process for the data to be saved, thereby avoiding the illegal information from being uploaded to the chain. In this way, detection and governance can be performed before the information is uploaded to the chain. In addition, the above technical solution detects illegal data at the consensus layer, which can save labor costs compared to the method of detecting at the application layer by calling the data detection smart contract (contract calls require manual review).
[0174] Optionally, the execution module 603 is used to:
[0175] When the consensus method is the proof-of-work algorithm, stop generating random numbers; or,
[0176] When the consensus method is the raft algorithm, stop participating in the leader election within the preset time.
[0177] Optionally, the device 600 further includes a model training module, which is used to repeatedly perform the following steps until the model converges to obtain the data detection model, and the model training module includes:
[0178] An acquisition submodule, used to acquire sample data, wherein the sample data includes historical data to be saved received by multiple nodes participating in the consensus in the blockchain network;
[0179] A parameter adjustment submodule, used to adjust the activation function of the model according to the state parameters of the blockchain network;
[0180] An input submodule, used to use the sample data as the input of the model to obtain the output result of the model;
[0181] A calculation submodule, used to calculate the loss value according to the output result of the model;
[0182] The weight adjustment submodule is used to adjust the weight value in the model according to the loss value.
[0183] Optionally, the state parameter of the blockchain network includes a length value of the blockchain.
[0184] Optionally, the parameter adjustment submodule includes:
[0185] A first calculation subunit is used to calculate the ratio of the length value of the blockchain to the number of neurons in the model to obtain a first ratio;
[0186] a first model setting subunit, configured to use a first activation function as an activation function of the model when the first ratio is less than a first threshold;
[0187] The second model setting subunit is used to use a second activation function as the activation function of the model when the first ratio is greater than a first threshold, and the change trend of the second activation function is smoother than that of the first activation function.
[0188] Optionally, the first activation function f1(x) is:
[0189]
[0190] The second activation function f2(x) is:
[0191]
[0192] Among them, num1 is a preset value, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0193] Optionally, the state parameter of the blockchain network also includes the number of participating nodes in the blockchain network, and the parameter adjustment submodule includes:
[0194] A second calculation subunit is used to calculate the product of the length value of the blockchain and the number value of the participating nodes to obtain a first product;
[0195] A third calculation subunit is used to calculate the ratio of the first product to the number of neurons in the model to obtain a second ratio;
[0196] a third model setting subunit, configured to use the first activation function as the activation function of the model when the second ratio is less than a second threshold;
[0197] The fourth model setting subunit is used to use a third activation function as the activation function of the model when the second ratio is greater than a second threshold, and the change trend of the third activation function is smoother than the change trend of the first activation function.
[0198] Optionally, the third activation function f3(x) is:
[0199]
[0200] Among them, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, and num(neurons) is the number of neurons in the model.
[0201] Optionally, the device 600 further includes:
[0202] An activation parameter adjustment module, configured to adjust activation parameters based on state parameters of the blockchain network during multiple trainings of the model; and
[0203] A neuron selection module, used for selecting a target neuron from the neurons of the model according to the activation parameter;
[0204] The neuron setting module is used to set the target neuron to an inactive state in this training.
[0205] Optionally, the state parameter of the blockchain network includes a length value of the blockchain and a number value of participating nodes in the blockchain network, and the activation parameter adjustment module is used to:
[0206] When the length value of the blockchain is less than a third threshold, setting the activation parameter to a preset activation parameter;
[0207] When the length of the blockchain is greater than the third threshold, the activation parameter is calculated by the following calculation formula:
[0208]
[0209] Wherein, p is the activation parameter, p * is the preset activation parameter, num(peer) is the number of participating nodes, len(block) is the length of the blockchain, num(peer) is the number of nodes participating in the blockchain, * is the number of initial participating nodes in the blockchain network.
[0210] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0211] The present disclosure also provides a non-temporary computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the blockchain information governance method provided by the present disclosure.
[0212] The present disclosure also provides an electronic device, comprising:
[0213] a memory having a computer program stored thereon;
[0214] A processor is used to execute the computer program in the memory to implement the steps of the blockchain information governance method provided by the present disclosure.
[0215] Figure 7 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Figure 7 As shown, the electronic device 700 may include: a processor 701 and a memory 702. The electronic device 700 may also include one or more of a multimedia component 703, an input / output (I / O) interface 704, and a communication component 705.
[0216] Among them, the processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned blockchain information governance method. The memory 702 is used to store various types of data to support the operation of the electronic device 700, which may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as blockchain ledger data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, disk or optical disk. The multimedia component 703 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone for receiving external audio signals. The received audio signal may be further stored in the memory 702 or sent through the communication component 705. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the other interface modules may be keyboards, mice, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.
[0217] In an exemplary embodiment, the electronic device 700 can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned blockchain information governance method.
[0218] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned blockchain information governance method are implemented. For example, the computer-readable storage medium can be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions can be executed by the processor 701 of the electronic device 700 to complete the above-mentioned blockchain information governance method.
[0219] In another exemplary embodiment, a computer program product is also provided, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned blockchain information governance method when executed by the programmable device.
[0220] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.
[0221] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.
[0222] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.
Claims
1. A blockchain information governance method, characterized in that: Applied to a target node in a blockchain network, the target node is any node participating in consensus in the blockchain network, the method comprises: Receiving a data upload request, wherein the data upload request includes data to be saved; In the process of reaching consensus on the data to be saved, the data to be saved is detected by using a data detection model to obtain a detection result of the data to be saved; When the detection result indicates that the data to be saved violates a rule, terminating the consensus process for the data to be saved; Wherein, the data detection model is trained based on the violation data and the compliance data; Repeat the following steps until the model converges to obtain the data detection model: Acquire sample data, where the sample data includes historical data to be saved received by multiple nodes participating in consensus in the blockchain network; Adjusting the activation function of the model according to the state parameters of the blockchain network; Using the sample data as input of the model to obtain an output result of the model; Calculate the loss value according to the output result of the model; Adjusting the weight values in the model according to the loss value; In a case where the state parameter of the blockchain network includes the length value of the blockchain, adjusting the activation function of the model according to the state parameter of the blockchain network includes: Calculating a ratio of a length value of the blockchain to a number value of neurons in the model to obtain a first ratio; When the first ratio is less than a first threshold, using a first activation function as an activation function of the model; When the first ratio is greater than a first threshold, a second activation function is used as the activation function of the model, and a change trend of the second activation function is smoother than a change trend of the first activation function.
2. The method according to claim 1, characterized in that The terminating the consensus process for the data to be saved includes: When the consensus method is the proof-of-work algorithm, stop generating random numbers; or, When the consensus method is the raft algorithm, stop participating in the leader election within the preset time.
3. The method according to claim 1, characterized in that The first activation function for: The second activation function for: in, is the default value, is the length of the blockchain, is the number of neurons in the model.
4. The method according to claim 1, characterized in that: In a case where the state parameter of the blockchain network includes a length value of the blockchain and a number value of participating nodes in the blockchain network, adjusting the activation function of the model according to the state parameter of the blockchain network includes: Calculate the product of the length value of the blockchain and the number value of the participating nodes to obtain a first product; Calculating a ratio of the first product to the number of neurons in the model to obtain a second ratio; When the second ratio is less than a second threshold, using the first activation function as the activation function of the model; When the second ratio is greater than a second threshold, a third activation function is used as the activation function of the model, and a change trend of the third activation function is smoother than a change trend of the first activation function.
5. The method according to claim 4, characterized in that The third activation function for: in, is the number of participating nodes, is the length of the blockchain, is the number of neurons in the model.
6. The method according to claim 1, characterized in that Also includes: During multiple trainings of the model, adjusting activation parameters based on state parameters of the blockchain network; and Selecting a target neuron from the neurons of the model according to the activation parameter; In this training, the target neuron is set to an inactive state.
7. The method according to claim 6, characterized in that In a case where the state parameter of the blockchain network includes a length value of the blockchain and a number value of participating nodes in the blockchain network, adjusting the activation parameter based on the state parameter of the blockchain network includes: When the length value of the blockchain is less than a third threshold, the activation parameter is a preset activation parameter; When the length of the blockchain is greater than the third threshold, the activation parameter is calculated by the following calculation formula: Wherein, p is the activation parameter, is the preset activation parameter, is the number of participating nodes, is the length of the blockchain, is the number of initial participating nodes in the blockchain network.
8. A blockchain information management device, characterized in that: Applied to a target node in a blockchain network, the target node is any node participating in consensus in the blockchain network, and the device includes: A receiving module, used to receive a data uplink request, wherein the data uplink request includes data to be saved; A data detection module, used to detect the data to be saved by using a data detection model during the process of reaching consensus on the data to be saved, so as to obtain a detection result of the data to be saved; An execution module, configured to terminate a consensus process for the data to be saved if the detection result indicates that the data to be saved is in violation of a rule; Wherein, the data detection model is trained based on the violation data and the compliance data; The model training module is used to repeatedly execute the training steps until the model converges to obtain the data detection model. The model training module includes: An acquisition submodule, used to acquire sample data, wherein the sample data includes historical data to be saved received by multiple nodes participating in the consensus in the blockchain network; A parameter adjustment submodule, used to adjust the activation function of the model according to the state parameters of the blockchain network; An input submodule, used to use the sample data as the input of the model to obtain the output result of the model; A calculation submodule, used to calculate the loss value according to the output result of the model; A weight adjustment submodule, used to adjust the weight value in the model according to the loss value; The state parameter of the blockchain network includes the length value of the blockchain, and the parameter adjustment submodule includes: A first calculation subunit is used to calculate the ratio of the length value of the blockchain to the number of neurons in the model to obtain a first ratio; a first model setting subunit, configured to use a first activation function as an activation function of the model when the first ratio is less than a first threshold; The second model setting subunit is used to use a second activation function as the activation function of the model when the first ratio is greater than a first threshold, and the change trend of the second activation function is smoother than that of the first activation function.
9. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the steps of the method described in any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: a memory having a computer program stored thereon; A processor, configured to execute the computer program in the memory to implement the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Blockchain transaction information processing method and system, electronic equipment and storage medium
CN112333160A