Test method and device of block chain system, electronic equipment and storage medium
By simulating evil scenarios in the blockchain system and testing the consensus processing logic, the problem of multiple evil nodes affecting the consensus results has been solved, and the attack response capabilities and operational stability of the blockchain system have been improved.
Patent Information
- Application Number
- CN202310401901.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-06
- Publication Date
- 2024-10-15
AI Technical Summary
In the blockchain system, multiple evil nodes will affect the consensus results, causing the system to run abnormally. It is difficult to effectively test and optimize the consensus processing logic to deal with attacks with existing technology.
By obtaining the scenario simulation information of the node, calling the interface program of the target evil scenario, the node simulates the evil scenario during the consensus process, and determines the test results of the consensus processing logic based on the running logs of the node and other nodes, thereby realizing the control of the blockchain system. Testing of consensus processing logic for evil scenarios.
It can detect abnormalities in the consensus processing logic in the blockchain system in advance, optimize and improve the system's ability to respond to attacks in a timely manner, verify the system's response and recovery capabilities to malicious attacks, and improve operational stability and reliability.
Smart Images

Figure CN118779208A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and more specifically, to a testing method, device, electronic device and storage medium for a blockchain system. Background Art
[0002] In the blockchain system, the consensus process is processed based on the Byzantine consensus fault tolerance mechanism. In practice, if there are many malicious nodes in the blockchain system, it will affect the consensus result and thus affect the normal operation of the blockchain system. In order to ensure that the blockchain system can effectively respond to malicious nodes, it is necessary to test the consensus processing logic in the blockchain system. Summary of the invention
[0003] In view of the above problems, the embodiments of the present application propose a testing method, device, electronic device and storage medium for a blockchain system to test the consensus processing logic in the blockchain system.
[0004] According to one aspect of an embodiment of the present application, a testing method for a blockchain system is provided, which is applied to a node in the blockchain system, and the method includes: obtaining scenario simulation information of the node; the scenario simulation information includes a target scenario identifier corresponding to a target malicious scenario to be simulated; the target malicious scenario refers to a scenario in which the normal processing logic of the target link is attacked during a consensus process; during a consensus process, an interface program corresponding to the target malicious scenario is called according to the target scenario identifier, so that the node simulates the target malicious scenario in the target link during the consensus process; and according to an operation log of the node during the simulation of the target malicious scenario and an operation log of at least one other node in the blockchain system, a test result of the consensus processing logic of the blockchain system for the target malicious scenario is determined.
[0005] According to one aspect of an embodiment of the present application, a testing device for a blockchain system is provided, which is applied to a node in the blockchain system, and the device includes: an acquisition module, used to acquire scenario simulation information of the node, the scenario simulation information including a target scenario identifier corresponding to a target malicious scenario to be simulated, and the target malicious scenario refers to a scenario in which the normal processing logic of the target link is attacked during a consensus process; a calling module, used to call an interface program corresponding to the target malicious scenario according to the target scenario identifier during a consensus process, so that the node simulates the target malicious scenario in the target link during the consensus process; a test result determination module, used to determine the test result of the consensus processing logic of the blockchain system for the target malicious scenario according to the operation log of the node and the operation log of at least one other node in the blockchain system during the simulation of the target malicious scenario.
[0006] According to one aspect of an embodiment of the present application, an electronic device is provided, including: a processor; a memory, wherein computer-readable instructions are stored on the memory, and when the computer-readable instructions are executed by the processor, the testing method of the blockchain system as described above is implemented.
[0007] According to one aspect of an embodiment of the present application, a computer-readable storage medium is provided, on which computer-readable instructions are stored. When the computer-readable instructions are executed by a processor, the testing method of the blockchain system as described above is implemented.
[0008] According to one aspect of an embodiment of the present application, a computer program product is provided, including computer instructions, which, when executed by a processor, implement the above-mentioned testing method for the blockchain system.
[0009] In this application, according to the scenario simulation information configured for the node, the interface program corresponding to the target malicious scenario is called to make the node simulate the target malicious scenario. After that, the operation log of the node itself in the process of simulating the target malicious scenario and the operation log of other nodes in the blockchain system in the process of simulating the target malicious scenario are used to determine the test results of the consensus processing logic of the blockchain system for the target malicious scenario. Since the operation logs of other nodes in the blockchain system in the process of simulating the target malicious scenario are generated in the process of processing according to the consensus processing logic set for the malicious situation, the operation logs of other nodes in the process of simulating the target malicious scenario reflect the operations performed by other nodes in the process of simulating the target malicious scenario. Then, the consensus processing logic for the target malicious scenario in the consensus mechanism can be determined according to the operations performed by other nodes in the process of simulating the target malicious scenario, that is, the test results of the consensus processing logic for the target malicious scenario are obtained. Thus, the test of the consensus processing logic for the malicious scenario in the blockchain system is realized. This makes it easy to find out in advance whether there are abnormalities in the consensus processing logic in the malicious scenario in the blockchain system, and to optimize the weak consensus processing logic in time, thereby improving the ability of the blockchain system to respond to attacks. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] The drawings herein are incorporated into the specification and constitute a part of the specification, illustrate embodiments consistent with the present application, and together with the specification are used to explain the principles of the present application. Obviously, the drawings described below are only some embodiments of the present application, and for ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.
[0011] Figure 1 It is a schematic diagram of a blockchain system according to an embodiment of the present application.
[0012] Figure 2 The structural diagram of the blockchain is shown as an example.
[0013] Figure 3 The flowchart of generating each block in the blockchain is shown as an example.
[0014] Figure 4 It is a schematic diagram of an application scenario of the present application according to an embodiment of the present application.
[0015] Figure 5 It is a flowchart of a testing method of a blockchain system according to an embodiment of the present application.
[0016] Figure 6 The consensus process of the Byzantine fault-tolerant consensus mechanism is shown as an example.
[0017] Figure 7 It is an architecture diagram of a blockchain system according to a specific embodiment of the present application.
[0018] Figure 8 It is a schematic diagram of the contents of a configured attack strategy according to an embodiment of the present application.
[0019] Fig. 9 This is a schematic diagram of functions supported by a node management module according to an embodiment of the present application.
[0020] Fig.10 This is a schematic diagram of the interaction between nodes in a blockchain system according to an embodiment of the present application.
[0021] Fig.11 It is a flowchart of a testing method of a blockchain system according to a specific embodiment of the present application.
[0022] Fig.12 It is a block diagram of a testing device for a blockchain system according to an embodiment of the present application.
[0023] Fig.13 A schematic diagram of the structure of a computer system suitable for implementing an electronic device of an embodiment of the present application is shown. DETAILED DESCRIPTION
[0024] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in a variety of forms and should not be construed as limited to the examples set forth herein; rather, these embodiments are provided so that this application will be more comprehensive and complete and fully convey the concept of the example embodiments to those skilled in the art.
[0025] It should be noted that the "multiple" mentioned in this article refers to two or more. "And / or" describes the association relationship of the associated objects, indicating that there can be three relationships. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.
[0026] Before describing the solution of the present application in detail, the terms involved in the present application are explained as follows:
[0027] Blockchain: is a shared, immutable ledger designed to facilitate the recording of transactions and assets in business networks. Assets can be tangible (such as houses, cars, cash, land) or intangible (such as intellectual property, patents, copyrights, brands). Almost anything of value can be recorded and traded on a blockchain network, reducing risks and costs in all aspects.
[0028] BFT (Byzantine Fault Tolerance) is a fault-tolerant technology in the field of distributed computing. Byzantine fault tolerance comes from the Byzantine Generals Problem. The Byzantine Generals Problem is a model of the real world. Due to hardware errors, network congestion or interruptions, and malicious attacks, computers and networks may behave unexpectedly. Byzantine fault tolerance technology is designed to handle abnormal behaviors that exist in reality and meet the specification requirements of the problem to be solved. The blockchain network environment conforms to the Byzantine Generals Problem model, with normal nodes (i.e. loyal Byzantine generals), faulty servers, and saboteurs' servers (rebellious Byzantine generals).
[0029] Consensus mechanism: It is a series of processes and rules generated to implement distributed consistency protocols. When nodes distributed in different regions negotiate and interact according to this set of rules, they can always reach a consistent decision on one or some issues, thereby achieving consistency among different nodes in the distributed system. The core of the consensus algorithm is to form a consensus on the network status among normal nodes.
[0030] COINBASE transaction: also known as generation transaction, it refers to the first transaction on each block in the blockchain. Normally, there is only one generation transaction in a block.
[0031] Figure 1 is a schematic diagram of a blockchain system according to an embodiment of the present application. Figure 1As shown, the blockchain system 100 refers to a system for sharing data between nodes, and the blockchain system may include multiple nodes 101, and the multiple nodes 101 may refer to each client in the blockchain system. Each node 101 can receive input information when performing normal work, and maintain the shared data in the blockchain system based on the received input information. In order to ensure the information intercommunication within the blockchain system, there may be an information connection between each node in the blockchain system, and information can be transmitted between nodes through the above information connection. For example, when any node in the blockchain system receives input information, other nodes in the blockchain system obtain the input information according to the consensus algorithm, and store the input information as data in the shared data, so that the data stored on all nodes in the blockchain system are consistent.
[0032] Each node in the blockchain system has a corresponding node identifier, and each node in the blockchain system can store the node identifiers of other nodes in the blockchain system, so that the generated blocks can be broadcast to other nodes in the blockchain system according to the node identifiers of other nodes. Each node can maintain a node identifier list as shown in the following table, and store the node name and node identifier in the node identifier list accordingly. Among them, the node identifier can be an IP (Internet Protocol, a protocol for interconnecting networks) address and any other information that can be used to identify the node. Table 1 only uses the IP address as an example for illustration.
[0033] Table 1
[0034] Node Name Node ID Node 1 117.114.XXX.XXX Node 2 117.116.XXX.XXX … … Node N 119.123.XXX.XXX
[0035] Each node in the blockchain system stores an identical blockchain. The blockchain consists of multiple blocks. Figure 2 The schematic diagram of the structure of the blockchain is shown as an example. Figure 2 As shown, the blockchain includes multiple blocks. The first block in the blockchain is called the genesis block. The genesis block includes a block header and a block body. The block header stores input information feature values, version numbers, timestamps, and difficulty values, and the block body stores input information. The next block of the genesis block takes the genesis block as a parent block. The next block also includes a block header and a block body. The block header stores input information feature values of the current block, block header feature values, version numbers, timestamps, and difficulty values of the parent block, and so on, so that the block data stored in each block in the blockchain is associated with the block data stored in the parent block, thereby ensuring the security of the input information in the block.
[0036] Figure 3 The following is an example of the flow chart for generating each block in the blockchain. Figure 3As shown in the figure, when generating each block in the blockchain, the node where the blockchain is located verifies the input information when receiving it. After the verification is completed, the input information is stored in the memory pool and the hash tree used to record the input information is updated. After that, the update timestamp is updated to the time when the input information is received, and different random numbers are tried, and the eigenvalue calculation is performed multiple times so that the calculated eigenvalue can satisfy the following formula:
[0037] SHA256(SHA256(version+prev_hash+merkle_root+ntime+nbits+x)) <TARGET
[0038] Among them, SHA256 is the eigenvalue algorithm used to calculate the eigenvalue; version (version number) is the version information of the relevant block protocol in the blockchain; prev_hash is the block header eigenvalue of the parent block of the current block; merkle_root is the eigenvalue of the input information; ntime is the update time of the update timestamp; nbits is the current difficulty, which is a fixed value within a period of time and is determined again after exceeding the fixed time period; x is a random number; TARGET is the eigenvalue threshold, which can be determined based on nbits.
[0039] In this way, when the random number that satisfies the above formula is calculated, the information can be stored accordingly, the block header and block body can be generated, and the current block can be obtained. Subsequently, the node where the blockchain is located sends the newly generated block to other nodes in the blockchain system according to the node identification of other nodes in the blockchain system. Other nodes verify the newly generated block and add the newly generated block to the blockchain stored in them after completing the verification.
[0040] Figure 4 is a schematic diagram of an application scenario of the present application according to an embodiment of the present application, such as Figure 4 As shown, the application scenario includes: an attack system 410 and a blockchain system 100, wherein the attack system 410 includes at least an attack server 411, and the attack server 411 provides an interface program corresponding to each malicious scenario for each node in the blockchain system 100 to call, so that the node simulates the malicious scenario. It is understandable that the attack code corresponding to each malicious scenario is stored in the attack server 411. In some embodiments, the attack system 410 may also include a terminal 412, which provides a user interface for interacting with the user, and the user can write the attack code corresponding to the malicious scenario in the user interface, and then the terminal sends the attack code corresponding to the malicious scenario to the attack server, so that the attack server performs interface encapsulation according to the attack code corresponding to the malicious scenario. Furthermore, the user can also modify the attack code corresponding to the malicious scenario in the user interface.
[0041] In some embodiments, the attack server 411 may be built with a Gomonkey (go unit test) framework, which is a stubbing framework of golang, and aims to allow users to complete stubbing at a low cost in unit testing, so as to focus on the development of business functions. It rewrites the executable file in assembly language at runtime, and jumps the implementation of the target function or method to the stubbing implementation.
[0042] Figure 5 This is a flowchart of a testing method for a blockchain system according to an embodiment of the present application. The method can be executed by a node in the blockchain system. The node in the blockchain system can be an electronic device with certain processing capabilities, such as a server or a terminal. More specifically, the method can be executed by a node in the blockchain system, or it can be implemented by multiple nodes interacting with each other. Figure 5 As shown, the method includes the following steps 510 to 530, which are described in detail as follows:
[0043] Step 510, obtaining scenario simulation information of the node, wherein the scenario simulation information includes a target scenario identifier corresponding to a target malicious scenario to be simulated, wherein the target malicious scenario refers to a scenario in which the normal processing logic of the target link is attacked during the consensus process.
[0044] Among them, the scene simulation information of the node can be configured and determined by the user in the scene configuration interface of the node, and the scene configuration interface at least includes a scene selection option for selecting a malicious scene, so that the user can select the malicious scene to be simulated for the node. In this application, the malicious scene to be simulated indicated by the scene simulation information is referred to as the target malicious scene. For a node, the target malicious scene in the scene simulation information can be one or more, which can be configured according to actual needs.
[0045] Each node in the blockchain system has an equal right to record data to the blockchain. The consensus mechanism is used in the blockchain system to ensure the accuracy of the data, so that all nodes can reach a consensus on the data and prevent malicious nodes from submitting false data. The BFT consensus mechanism is a commonly used consensus mechanism in the blockchain system. In the blockchain system based on the BFT consensus mechanism, it supports tolerance of malicious nodes, but in this blockchain system, the maximum number of malicious nodes tolerated is no more than 1 / 3 of the total number of nodes.
[0046] Figure 6 The consensus process of the Byzantine fault-tolerant consensus mechanism is shown as follows: Figure 6As mentioned above, the consensus process of the Byzantine fault-tolerant consensus mechanism includes four steps: proposal, voting, pre-commit and commit. Figure 6 The example shows four nodes in the blockchain system, namely node A1, node A2, node A3 and node A4; among them, node A1 and node A2 are malicious nodes. In this application, if node A1 and node A2 simulate the pre-configured malicious scenario, node A1 and node A2 will be malicious nodes. For node A1, it can generate an abnormal proposal and send it to node A2 in the proposal stage, and send the accurate proposal to node A3 and node A4; in the voting stage, node A2 can generate abnormal votes.
[0047] During the operation, if node A2 receives an abnormal proposal, if the proposal is verified to be an abnormal proposal, an operation log of the proposal error will be generated. At the same time, due to the forwarding mechanism, node A2 will receive normal proposals forwarded by other nodes, which will not affect the overall consensus process of the blockchain system.
[0048] After receiving a normal proposal, node A2 can verify that the proposal is a normal proposal. Since node A2 is a malicious node, after receiving the normal proposal, node A2 will generate an abnormal vote and send it to node A1, node A3 and node A4. After receiving the abnormal vote sent by node A2, if node A1, node A3 and node A4 determine that the vote fails through verification, the corresponding operation log will be generated and recorded.
[0049] Since each node still receives 3 normal votes (the number of normal votes is greater than the total number of votes in the blockchain system), it can enter the pre-submission phase normally. The execution process of the pre-submission phase is similar to the voting phase. Assuming that node A2 generates an abnormal vote, other nodes receive the abnormal vote of node A2, and the voting verification fails and the running log of the voting error is recorded. Other nodes still receive 3 normal votes (greater than 2 / 3), and can enter the submission phase normally, and the consensus process is successfully completed.
[0050] Depend on Figure 6As can be seen from the above description, each node in the blockchain system will implement a unified series of processes and rules for transactions in the blockchain based on the Byzantine fault-tolerant consensus mechanism. In other words, for each node in the blockchain system, the processing logic of each link under the Byzantine fault-tolerant consensus mechanism is pre-set. In this application, the processing logic configured for each link under the Byzantine fault-tolerant consensus mechanism is called the normal processing logic of the link. For example, in the proposal link, the node will sign the proposal with its own node ID. In this process, the processing logic of the node signing the proposal with its own node ID is the normal processing logic of the link; for another example, when it is agreed that multiple nodes initiate proposals in sequence, the processing logic of each node initiating the proposal in the agreed order is the normal processing logic of the link; for another example, the Byzantine fault-tolerant consensus mechanism is set to enter the pre-submission stage when the same votes accounting for 2 / 3 of the number of nodes are received in the voting stage, and this processing logic is also the normal processing logic.
[0051] Among them, the division of links in the consensus mechanism can be based on Figure 6 The division is shown as shown. Of course, in other embodiments, the division granularity of the links in the consensus mechanism may be larger or smaller, which is not specifically limited here.
[0052] Step 520: In the consensus process, the interface program corresponding to the target malicious scenario is called according to the target scenario identifier, so that the node simulates the target malicious scenario in the target link of the consensus process.
[0053] The node's interface layer can provide interface programs corresponding to each malicious scenario. Each node in the blockchain system is connected to the attack server in communication. Therefore, based on the target scenario identifier of the target malicious scenario, the interface program corresponding to the target malicious scenario can be determined at the node's interface layer, and then the interface program corresponding to the target malicious scenario can be called.
[0054] In one embodiment of the present application, in the process of simulating the target malicious scenario, in the target link of the consensus mechanism, the node does not execute the normal processing logic of the target link, but calls the interface program corresponding to the target malicious scenario, and then executes the attack processing logic configured for the target malicious scenario, that is, executes the attack code corresponding to the target malicious scenario. In the process of the node simulating the target malicious scenario, the node becomes a malicious node in the blockchain system, or a malicious node.
[0055] In the process of the node calling the interface program corresponding to the target malicious scenario, the node corresponds to the malicious node in the blockchain system. The processing logic implemented by the node calling the interface program corresponding to the target malicious scenario is not the normal processing logic of this link, but is processed according to the processing logic of the attack code of the target malicious scenario.
[0056] For example, in the above example, a normal processing logic in the proposal phase is that the node signs the proposal using its own node ID. If the attack scenario implements the attack processing logic, the node signs the proposal using a node ID other than its own. A node ID other than its own can be, for example, the node ID of another node, such as an arbitrarily constructed string that does not meet the requirements and is used to represent the node ID. Figure 6 As shown in the figure, the division of links in the consensus mechanism, the target malicious scenario can be to instruct attacks in the voting link, proposal link, pre-submission link, submission link, etc.
[0057] Step 530, determining a test result of the consensus processing logic of the blockchain system for the target malicious scenario based on the operation log of the node and the operation log of at least one other node in the blockchain system during the simulation of the target malicious scenario.
[0058] When a node simulates a malicious scenario, the node records its own operation log in real time. The operation log may indicate the operations performed by the node in the process of simulating the malicious scenario, the results of the operations, etc.
[0059] Under the constraints of the consensus mechanism in the blockchain system, the nodes are constantly interacting with each other. For example, node A1 initiates a proposal to other nodes, and the node that receives the proposal verifies the proposal and votes on the proposal if the verification is passed. The operation logs of other nodes in the blockchain system during the process of the node simulating the target malicious scenario can reflect the operations and operation nodes performed by the corresponding nodes during the process of the node simulating the target malicious scenario, such as verifying the content of the proposal, verifying the signature of the proposal, and generating an alarm log if the proposal verification fails. Therefore, the operation logs of other nodes in the blockchain system during the process of the node simulating the target malicious scenario can reflect the responses of other nodes to the nodes simulating the target malicious scenario during the process of the node simulating the target malicious scenario, or the operations performed by other nodes on the malicious nodes.
[0060] It can be understood that the operation performed by the node (assuming it is node A2) when node A1 does evil (for example, when node A1 simulates a malicious scenario) is the result of processing based on the consensus processing logic deployed in the node for the malicious situation. Therefore, in the present application, the test result of the consensus processing logic of the blockchain system for the target malicious scenario is determined based on the operation log of the node itself in the process of simulating the target malicious scenario and the operation logs of other nodes in the blockchain system during the process of the node simulating the target malicious scenario.
[0061] As described above, the operation log of the node itself during the process of simulating the target malicious scenario indicates the operations performed by the node. The operation logs of other nodes in the blockchain system during the process of the node simulating the target malicious scenario indicate the operations performed by other nodes during the process of the node simulating the target malicious scenario, that is, indicate the responses of other nodes to the operations performed by the node simulating the target malicious scenario. Therefore, the expected response operations of other nodes when the node simulates the target malicious scenario can be pre-set. Thereafter, whether the node successfully simulates the target malicious scenario is determined based on the operations performed by the node itself simulating the target malicious scenario. When it is determined that the node successfully simulates the target malicious scenario, the execution operations of other nodes are compared with the expected response operations corresponding to the target malicious scenario. If the execution operations of other nodes are consistent with the expected response operations corresponding to the target malicious scenario, it indicates that the consensus processing logic of the blockchain system for the target malicious scenario is effective; if they are inconsistent, it indicates that the consensus processing logic of the blockchain system for the target malicious scenario has not achieved the expected response operations.
[0062] When it is determined that the consensus processing logic of the blockchain system for the target malicious scenario does not achieve the expected response operation, it may be that there is an abnormality in the consensus processing logic deployed on each node in the blockchain system. Afterwards, the code corresponding to the consensus processing logic can be modified accordingly until the test determines that the consensus processing logic of the blockchain system for the target malicious scenario can achieve the expected response operation.
[0063] In some embodiments, the type of each node in the blockchain system can be pre-configured, wherein the type of the node is used to indicate whether the node is a master node or a slave node, and it is set that the slave node reports the slave node's own operation log to the master node according to a preset reporting period. On this basis, the solution of the present application can be applied to the master node. In this embodiment, before step 530, the method also includes: receiving the operation log reported by each slave node. In this way, the master node then analyzes its own operation log and the operation log of the slave node to determine the test result of the consensus processing logic of the target malicious scenario.
[0064] When the nodes in the blockchain system are divided into master nodes and slave nodes, during a test, the master node can simulate a malicious scenario, or the slave node can simulate a malicious scenario, or both the master node and the slave node can simulate a malicious scenario. In other words, during a test of the consensus processing logic, the number of nodes simulating malicious scenarios can be one or more, which can be set according to actual needs.
[0065] In this application, according to the scenario simulation information configured for the node, the target malicious scenario corresponding interface is called to make the node simulate the target malicious scenario. After that, the operation log of the node itself in the process of simulating the target malicious scenario and the operation log of other nodes in the blockchain system in the process of simulating the target malicious scenario are used to determine the test results of the consensus processing logic of the blockchain system for the target malicious scenario. Since the operation logs of other nodes in the blockchain system in the process of simulating the target malicious scenario are generated in the process of other nodes processing according to the set consensus processing logic, the operation logs of other nodes in the process of simulating the target malicious scenario reflect the operations performed by other nodes in the process of simulating the target malicious scenario. Then, the consensus processing logic for the target malicious scenario in the consensus mechanism can be determined according to the operations performed by other nodes in the process of simulating the target malicious scenario, that is, the test results of the consensus processing logic for the target malicious scenario are obtained. Thus, the test of the consensus processing logic in the blockchain system is realized. This makes it easy to find out in advance whether there are abnormalities in the consensus processing logic in the malicious scenario in the blockchain system, and to optimize the weak consensus processing logic in time, thereby improving the ability of the blockchain system to respond to attacks.
[0066] Moreover, this can verify the blockchain system's response and recovery capabilities to malicious attacks, and can promote the adjustment of malicious scenarios through feedback to move on to the next round of attacks. Multiple tests like this can improve the operational stability and reliability of the blockchain system.
[0067] In some embodiments, the target link is the voting link, and the target malicious scenario can be the first malicious scenario or the second malicious scenario. The first malicious scenario is a scenario in which voting is performed for abnormal voting content in the voting link; the second malicious scenario is a scenario in which an abnormal signature is used to sign a vote in the voting link; the abnormal signature is determined by signing with an abnormal signature party identifier, or constructing an abnormal signature string, or signing with an abnormal signature algorithm.
[0068] In the normal processing flow, when a node receives a proposal and verifies that the proposal is a normal proposal, it initiates a vote on the normal proposal. The normal proposal is the voting content targeted by the vote. Abnormal voting content means that the object of the current vote is not the normal proposal currently targeted. For example, if node A1 currently needs to vote on proposal B, but node A1 is currently voting on proposal C, then in the current situation, for node A1, proposal C is an abnormal voting content.
[0069] In some embodiments, in view of the different ways of determining abnormal voting content in the first malicious scenario, the first malicious scenario can be subdivided into three sub-malicious scenarios, namely sub-malicious scenario I, sub-malicious scenario II and sub-malicious scenario III. For sub-malicious scenario I, the abnormal voting content may be randomly constructed content, rather than the content actually targeted by the current vote. For sub-malicious scenario II, the content targeted by the vote may be set to empty, so that the content targeted by the vote is also abnormal voting content. For sub-malicious scenario III, when the verification determines that the received voting content (such as a proposal) is wrong, a vote is still initiated for the received voting content, and the content targeted by this vote is the abnormal voting content. In the normal processing logic, if the node fails the verification of the received voting content, it will not initiate a vote for the voting content.
[0070] When the first malicious scenario is subdivided into sub-malicious scenario I, sub-malicious scenario II and sub-malicious scenario III as above, corresponding interface programs are provided for sub-malicious scenario I, sub-malicious scenario II and sub-malicious scenario III for each node to call.
[0071] As described above, for the abnormal signature in the second malicious scenario, it can be signed using the abnormal signature party identifier, or an abnormal signature string can be constructed, or the signature can be determined using an abnormal signature algorithm. On this basis, the second malicious scenario can be further divided into an abnormal signer malicious scenario (in this malicious scenario, the abnormal signature is determined by signing using an abnormal signature identifier), an abnormal signature malicious scenario (in this malicious scenario, the abnormal signature is a constructed abnormal signature string) and an abnormal signature algorithm scenario (in this malicious scenario, the abnormal signature is obtained by signing using an abnormal signature algorithm).
[0072] In a blockchain system, under normal circumstances, before a node sends a vote, it needs to sign with its own node ID, so that the voting recipient can verify which node the vote comes from based on the received vote. In the scenario where the abnormal signer does evil, the node ID used by the node to sign is not its own node ID. According to the different ways of identifying the source of the abnormal signature, the abnormal signer's evil scenario can be further subdivided into three sub-evil scenarios, namely, abnormal signer evil scenario I, abnormal signer evil scenario II, and abnormal signer evil scenario III. In the case where the node (assuming node A1) simulates the abnormal signer's evil scenario I, node A1 uses the node ID of other nodes to sign instead of the node ID of node A1 itself. In the case where the node (assuming node A1) simulates the abnormal signer's evil scenario II, node A1 uses a node ID that does not exist at all to sign, that is, the node ID used for signing is legal (for example, it meets the character length requirement), but it is not the node ID of the node in the blockchain system where node A1 is located. In the case of scenario III where a node (assuming node A1) simulates the malicious behavior of an abnormal signer, node A1 uses an illegal string to sign, that is, in this case, the string used for signing does not meet the format requirements of the node ID, for example, the node ID is 32 characters, but a string of length 10 is used for signing. In the case where a node simulates the malicious behavior of an abnormal signer, the consensus processing logic for verifying abnormal signers in the consensus mechanism can be verified to be valid based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0073] In the abnormal signature malicious scenario, the signature added to the vote is not an accurate signature. Furthermore, the abnormal signature malicious scenario can be further subdivided into abnormal signature malicious scenario I and abnormal signature malicious scenario II. In the case of the node simulating the abnormal signer malicious scenario I, the format of the signature added to the vote by the node is different from the required format; in the case of the node simulating the abnormal signer malicious scenario II, the signature content of the signature added to the vote by the node is incorrect; for example, for a proposal K1, the signature string obtained by signing is string B1; for proposal K2, the signature string obtained by signing is string B2. Now node A1 needs to vote for proposal K1. In the case of node A1 simulating abnormal signature malicious scenario II, node A1 can use string B2 as the signature for voting on proposal K1. In the case of the node simulating the abnormal signature malicious scenario, the consensus processing logic for verifying abnormal signatures in the consensus mechanism can be verified to be valid based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0074] In the case of a node simulating an abnormal signature algorithm scenario, the node uses a signature algorithm other than the signature algorithm required by the consensus mechanism for signing. In other words, the signature algorithm used by the node is not the signature algorithm required by the consensus mechanism. For example, if the signature algorithm required by the consensus mechanism is the Digital Signature Algorithm (DSA), and the node uses the Elliptic Curve Digital Signature Algorithm (ECDSA) for signing when simulating an abnormal signature algorithm scenario. In the case of a node simulating an abnormal signature algorithm scenario, the consensus processing logic for verifying the abnormal signature algorithm in the consensus mechanism can be verified to be valid based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0075] In some embodiments, the target link is the proposal link; the target malicious scenario is one of the third malicious scenario, the fourth malicious scenario, the fifth malicious scenario and the sixth malicious scenario; the third malicious scenario is a scenario in which different proposals are sent to at least two different other nodes in the proposal link; the fourth malicious scenario is a scenario in which a proposal is initiated at a time other than the node's own proposal; the fifth malicious scenario is a scenario in which an abnormal proposal hash value is constructed for the proposal; the sixth malicious scenario refers to a scenario in which duplicate transactions are added to the proposal.
[0076] When a node simulates the third malicious scenario, the node sends a proposal to each of the other nodes in the blockchain system, but the proposals received by at least two different other nodes are different, that is, the node sends different proposals to at least two different other nodes. For example, the blockchain system includes 10 nodes, namely nodes A1 to A10. When node A1 simulates the third malicious scenario, node A1 sends proposal B1 to nodes A2 to A4, node A1 sends proposal B2 to nodes A5 to A7, and node A1 sends proposal B3 to nodes A8 to A10. Then, in one round of voting, for proposal B1, at most 3 identical votes are received. In fact, proposal B1 needs to enter the next stage only when the number of voting nodes accounts for 2 / 3 of the total number of nodes. However, in this round of voting, proposal B1 does not meet the requirements for entering the next stage, so after the timeout period is reached, the next node will initiate the proposal. When the node simulates the third malicious scenario, the validity of the consensus processing logic for sending different proposals to the node in the consensus mechanism can be verified based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0077] Under normal circumstances, multiple nodes make proposals in sequence, for example, node B makes a proposal after node A makes a proposal, and node C makes a proposal after node B makes a proposal. In the case where the node simulates the fourth malicious scenario, the node may initiate a proposal at any time, for example, it may initiate a proposal at the time when other nodes should initiate a proposal. In the case where the node (assuming node A1) simulates the fourth malicious scenario, node A1 may initiate a proposal at the time when node A2 should initiate a proposal. In this way, for another node A3 in the blockchain system, it will receive two proposals at the same time, from node A1 and node A2 respectively. Under normal circumstances, node A3 determines that the proposal should be initiated by node A2 at the current moment according to the proposal initiation order agreed upon by the consensus mechanism. Therefore, node A3 will determine that the proposal from node A1 is an invalid proposal, and then print a warning message indicating that the proposal from node A1 at the current moment is an invalid proposal in the log. In the case where the node simulates the fourth malicious scenario, the consensus processing logic for the malicious scenario of the node initiating a proposal at any time in the consensus mechanism can be verified based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0078] In the blockchain system, the process of a node initiating a proposal is as follows: the node packages a batch of transactions in the transaction pool, then calculates the hash value of this batch of transactions, and then initiates a proposal based on the hash value of this batch of transactions. The calculated hash value of the batch of transactions is the proposal hash value of the proposal. When the node simulates the fifth malicious scenario, the node assigns an incorrect hash value to the current proposal, that is, an abnormal proposal hash value is used as the proposal hash value of the current proposal. The abnormal proposal hash value is not the hash value corresponding to the batch of transactions in the proposal.
[0079] When the node simulates the fifth malicious scenario, if the proposal is sent to other nodes, the node that receives the proposal will verify it based on the abnormal proposal hash value. In this way, it will be determined that the proposal hash value does not match the transaction in the proposal, and then it will be determined that the received proposal is an incorrect proposal, and then a warning message will be printed in the corresponding log. When the node simulates the fifth malicious scenario, the consensus processing logic for verifying the proposal hash value in the consensus mechanism can be tested based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0080] As described above, the proposal is obtained by packaging a batch of transactions in the transaction pool. Under normal circumstances, there are no duplicate transactions in the transaction pool, and there are no duplicate transactions in the proposal. When the node simulates the sixth malicious scenario, the node will add duplicate transactions to the proposal; after the proposal with duplicate transactions is sent to other nodes, under normal circumstances, other nodes will verify the transactions in the received proposal. If the verification determines that the proposal includes duplicate transactions, the node will print a warning message in the log to prompt that the proposal includes duplicate transactions. When the node simulates the sixth malicious scenario, the consensus processing logic for verifying duplicate transactions in the block in the consensus mechanism can be tested based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0081] In some embodiments, the target malicious scenario is one of the seventh malicious scenario, the eighth malicious scenario, the ninth malicious scenario, the tenth malicious scenario and the eleventh malicious scenario; the seventh malicious scenario refers to the scenario of forging blocks in the blockchain; the eighth malicious scenario refers to the scenario of entering the next link in advance without confirming that the consensus has been passed; the ninth malicious scenario refers to the scenario where the node initiates a timeout vote when the votes of other nodes do not exceed the time threshold; the tenth malicious scenario refers to the scenario of adding multiple generation transactions to the block; the eleventh malicious scenario refers to the scenario of adding generation transactions signed by non-proposal nodes to the block.
[0082] When the node simulates the seventh malicious scenario, the node will forge a new block based on the existing block height. Under normal circumstances, if the node that forges the block broadcasts the block information of the forged block to other nodes, other nodes can verify the block and determine that the current block is a forged block. On this basis, other nodes will print a prompt log and discard the forged block accordingly. When the node simulates the seventh malicious scenario, the consensus processing logic for verifying forged blocks in the consensus mechanism can be tested based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0083] In the case where the node simulates the eighth malicious scenario, after the node initiates a vote for a proposal, it enters the next stage (the next stage is to initiate a vote for another proposal) without receiving the same votes from 2 / 3 of the total number of nodes. In this case, since other nodes have not entered the next stage, it is equivalent to other nodes receiving two instructions to vote on the proposal in one voting time period. Therefore, other nodes will determine that the voting test for the later initiated proposal has failed and generate a corresponding operation log. In the case where the node simulates the eighth malicious scenario, the consensus processing logic for entering the next stage in the consensus mechanism can be verified to be valid based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0084] When a node (assuming node A1) simulates the ninth malicious scenario, node A1 will initiate a timeout vote if the voting time of the previous proposal does not reach the time threshold. For example, under normal circumstances, after node A2 initiates a vote on a proposal, node A1 initiates a vote on another proposal. When node A1 simulates the ninth malicious scenario, during the time period when node A2 initiates a vote but does not exceed the time threshold (i.e., the timeout time threshold), node A1 prompts that it has not received the vote from node A2, and has reached the timeout time threshold, and initiates a timeout vote. Under normal circumstances, after receiving the timeout vote initiated by node A1, other nodes (such as node A3 and node A4) verify that node A2 has not timed out, and then will not vote on the proposal for which the timeout vote initiated by node A1 is targeted. When a node simulates the ninth malicious scenario, the consensus processing logic of the timeout verification in the consensus mechanism can be verified to be valid based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0085] As described above, there is only one generation transaction (i.e., COINBASE transaction) in a block. When a node simulates the tenth malicious scenario, the node will put multiple generation transactions in the block. On this basis, other nodes will normally verify the block to determine that the block includes multiple generation transactions, and then generate a corresponding operation log indicating that the block includes multiple generation transactions. When a node simulates the tenth malicious scenario, the consensus processing logic for verifying duplicate generation transactions in the consensus mechanism can be verified based on the node's own operation log and the operation log of at least one other node in the blockchain system.
[0086] The generation transaction in the block is also signed, and it is the signature of the proposal node. In the case where the node simulates the eleventh malicious scenario, the node will add a generation transaction including the user's signature to the block. In this way, under normal circumstances, other nodes can verify that the generation transaction is not signed by the proposal node based on the signature carried by the generation transaction, and then generate the corresponding operation log to prompt that the signature carried in the generation transaction is not the signature of the proposal node. In the case of a node simulating the eleventh malicious scenario, the consensus processing logic for verifying the signature of the generation transaction in the consensus mechanism can be verified based on the node's own operation log and the operation log of at least one other node in the blockchain system. Whether it is valid. In a specific embodiment, the above-mentioned tenth malicious scenario and eleventh malicious scenario can be collectively referred to as abnormal transaction malicious scenarios.
[0087] In some embodiments, the scenario simulation information also includes a simulation end condition; after step 520, the method also includes: if the simulation end condition is reached, stop calling the interface program corresponding to the target malicious scenario, and process according to the normal processing logic corresponding to the target link.
[0088] The simulation end condition can be configured according to actual needs. For example, the simulation end condition can be the end time of the set simulation time period. In this embodiment, when the simulation end condition is reached, the interface program corresponding to the target malicious scenario is stopped from being called, and the normal processing logic corresponding to the target link is used for processing. In other words, when the simulation end condition is reached, if the node does not need to simulate other malicious scenarios, the node is re-used as a normal node in the blockchain system. Therefore, based on the solution of this embodiment, the nodes in the blockchain system can switch between the two roles of normal node and malicious node according to the needs of the malicious scenario simulation.
[0089] In some embodiments, when the node determines that it needs to call the interface program corresponding to the target evil scenario, the code related to the consensus process deployed in the node itself can be re-encapsulated with the interface program corresponding to the target evil scenario, so as to replace the function corresponding to the normal processing logic corresponding to the target link in the code related to the consensus process with the function in the interface program corresponding to the target evil scenario. In this way, when the node simulates the target evil scenario, the node will not execute the function corresponding to the normal processing logic corresponding to the target link, but execute the function encapsulated in the interface program corresponding to the target evil scenario. In this embodiment, due to the access to the interface program corresponding to the target evil scenario, the function in the normal processing logic under the target link is replaced by the function in the interface program corresponding to the target scenario. In this way, in the process of calling the interface program corresponding to the target evil scenario, the function in the normal processing logic under the target link is not affected. Moreover, when the simulation end condition is reached, the interface program corresponding to the target evil scenario can be stopped from being called, and the normal processing logic corresponding to the target link is processed. In this way, it is equivalent to packaging based on the existing code for attack simulation, which ensures the security and pluggability of the code corresponding to the normal processing logic under the target link.
[0090] In some embodiments, the scenario simulation information also includes a simulation start condition, that is, for a node, if the simulation start condition in the scenario simulation information of the node is met, the interface program for calling the target malicious scenario indicated by the scenario simulation information is started to simulate the target malicious scenario; and when the simulation end condition is met, the interface program for calling the target malicious scenario is stopped.
[0091] The simulation start condition can be set according to actual needs. For example, the simulation start condition can be the start time of the set simulation time period, the simulation start condition can also be the simulation end condition of the previous node, etc. In a specific embodiment, the user can customize the simulation start condition corresponding to each malicious scenario of the configuration node.
[0092] In some embodiments, after step 410, the method further includes the following steps C1 and C2, which are described in detail as follows: Step C1, determining the malicious result of the target malicious scenario based on the operation log of the node itself in the process of simulating the target malicious scenario; Step C2, determining the test result of the interface program corresponding to the target malicious scenario based on the malicious result of the target malicious scenario and the expected malicious result set for the target malicious scenario.
[0093] As described above, the operation log of the node itself during the process of simulating the target malicious scenario can indicate the operations performed by the node during the process of simulating the target malicious scenario and the operation results, where the operation results are the malicious results of the node simulating the target malicious scenario.
[0094] In the present application, the test result of the interface program corresponding to the target malicious scenario is used to indicate whether the malicious result of the target malicious scenario is consistent with the expected malicious result set for the target malicious scenario. According to the malicious result of the target malicious scenario and the expected malicious result set for the target malicious scenario, it can be determined whether the actual attack effect of the target malicious scenario is consistent with the expected malicious result. If they are consistent, it indicates that the attack code corresponding to the target malicious scenario is accurate; otherwise, if they are inconsistent, it indicates that there is an abnormality in the attack code corresponding to the target malicious scenario.
[0095] In some embodiments, after step C2, the method further includes: if the test result of the interface program corresponding to the target malicious scenario indicates that the malicious result of the target malicious scenario is inconsistent with the corresponding expected malicious result, then generating modification prompt information, the modification prompt information is used to indicate that the attack code of the interface program corresponding to the target malicious scenario is modified. In this way, based on the prompt information, the attack code corresponding to the target malicious scenario can be modified to ensure that the actual malicious result of the modified target malicious scenario is consistent with the expected malicious result.
[0096] Figure 7 is an architecture diagram of a blockchain system according to a specific embodiment of the present application. Figure 7 As shown in Figure 1, different nodes in the blockchain system establish communication connections through the network. Figure 7 As shown in the figure, each node in the blockchain system includes 7 functional modules, namely: service layer module, policy management module, node management module, log management module, interface layer module, data analysis module, and attack implementation module.
[0097] Furthermore, the service layer module of the node further includes: HTTP (Hyper Text Transfer Protocol) component, initialization component, configuration update component and data display component. Among them, the HTTP component is used to start the HTTP service to process user requests and supports setting detection IP and port information. User requests can be requests to attack the normal processing logic of a certain link in the consensus process, requests to specify the attack time corresponding to the malicious scenario, requests to modify the order of node simulation malicious scenarios, etc. The initialization component is responsible for the initialization operation of all modules. The configuration update component is used to update the running configuration of other components according to the user request after receiving the user request. The running configuration includes the order of simulating malicious scenarios, the simulation end conditions of malicious scenarios, the simulation start conditions of malicious scenarios, etc. The data display component is used to intuitively display the user's operation records during the execution process, the node's malicious scenario simulation records, the execution results of the malicious scenario, and the comparison with the expected malicious results in the form of pictures, tables, and texts.
[0098] Figure 8 is a schematic diagram showing the contents of an attack strategy configured for a node according to an embodiment of the present application, Figure 8 The configuration contents of attack strategy-1 and attack strategy-y are shown in FIG. Figure 8 As shown, the attack strategy can configure the nodes targeted by the attack strategy, malicious scenarios, simulation start conditions, simulation end conditions, and running status. The policy management module can support the creation, modification, and deletion of attack strategies. Each attack strategy can target one or more nodes, and each node can set malicious scenarios, simulation start conditions, and simulation end conditions separately. Furthermore, the policy management module also supports starting and stopping attack strategies, and supports viewing the running status of attack strategies. The running status of attack strategies, such as which nodes among the nodes targeted by the attack strategy are simulating malicious scenarios, the number of nodes simulating malicious scenarios, etc.
[0099] Fig. 9 is a schematic diagram showing functions supported by a node management module according to an embodiment of the present application, such as Fig. 9 As shown, the node management module supports adding, deleting nodes, modifying node information, etc. Node information mainly includes name, IP, port, TLS (Transport Layer Security) certificate, node type (including master node, slave node), and strategy list (i.e., attack strategy list). Nodes belonging to slave nodes in the blockchain system will send their own operation logs to the master node. The slave node can synchronize its own operation log to the master node through the TLS protocol. The slave node can report the operation log to the master node according to the preset reporting period. The reporting period can be set according to actual needs, for example, the reporting period is 500ms; the master node can detect the status of each slave node according to the preset detection period. The detection period is, for example, 1s, which can be set according to actual needs and is not specifically limited here.
[0100] The interface layer module is used to access the interface programs corresponding to each malicious scenario provided by the attack server, such as the interface programs corresponding to the first to eleventh malicious scenarios listed above.
[0101] The log module can store information related to the operation of the node, including: user operation information of the node, scenario information of the malicious scenario simulated by the node, execution result information of the malicious scenario simulated by the node, user operation information reported by the slave node, scenario information of the simulated malicious scenario, attack execution results, and normal execution results.
[0102] The attack implementation module is the specific implementation of the malicious scenario. Developers or testers need to define the attack logic of the malicious scenario according to the interface layer. For example, if there is abnormal voting content, the code for modifying the voting content needs to be implemented according to the interface. When the user enables abnormal voting content in the 'Policy Management Module', whenever the blockchain process executes the voting logic, the custom code for modifying the voting content will be called to generate malicious votes and complete the attack.
[0103] The data analysis module is used to analyze the various operation logs stored in the log module according to the attack strategy, and store the analysis results for display by the display module. The analysis results will include: attack type, trigger frequency, the match between the malicious results and the expected results, the CPU, memory, disk I / O, and network I / O usage of the attack process node, etc.
[0104] Fig.10 is a schematic diagram of the interaction between nodes in a blockchain system according to an embodiment of the present application, such as Fig.10 As shown in the figure, during the operation of the blockchain system, each node will record the generated operation log to the local database. After that, the node management module in the slave node will synchronize the operation log in the local database to the master node at regular intervals. TLS transmission is used during the synchronization process to ensure data security.
[0105] Fig.11 is a flowchart of a testing method for a blockchain system according to a specific embodiment of the present application, such as Fig.11 As shown, including:
[0106] Step 1110, preparation process; specifically includes introducing an interface program corresponding to the malicious scenario into the blockchain system, and writing an attack code corresponding to the malicious scenario.
[0107] Step 1120, configure each node; specifically, configure the configuration of each node in the blockchain system (such as the number of consensus nodes, the interval between consensus nodes generating blocks, the maximum number of transactions in a block, the transaction length of a block, etc.), and configure whether the attack strategy in the node is enabled, the port, the log level (log level such as WARN (warning) level, ERROR (error) level, PANIC (panic) level), TLS certificate, etc. The configured log level facilitates subsequent statistics by log level.
[0108] Step 1130, start the test blockchain system.
[0109] Step 1140: configure attack strategies, such as configuring nodes targeted by each attack strategy, malicious scenarios to be simulated by the nodes, etc.
[0110] Step 1150, simulating a malicious scenario.
[0111] Step 1160, upload the operation log from the node. The slave node can report the operation log to the master node according to the preset reporting cycle, and the master node also records its own operation log. During the operation of the master node, the logs of various log levels in the operation log are compared with the expected malicious results.
[0112] Step 1170, data analysis, report generation.
[0113] Step 1180, determining the malicious result. In step 1180, the malicious result can be manually confirmed again based on the content in the report.
[0114] Step 1190, determine whether it is consistent with expectations; if it is consistent, then end; if it is not consistent, modify the attack code or modify the code corresponding to the consensus process, and then return to execute step 1120. Specifically, if it is determined that the consensus processing logic in the blockchain system is inconsistent with expectations, modify the code corresponding to the consensus process; if it is determined that the malicious result corresponding to the target malicious scenario is inconsistent with the expected malicious result, modify the attack code corresponding to the target malicious scenario.
[0115] Repeating the above process and subjecting the blockchain system to multiple rounds of testing can verify the effectiveness of the consensus processing logic in the blockchain system. If the test does not meet the requirements, modify the attack code corresponding to the malicious scenario, or modify the code corresponding to the consensus processing logic. In this way, after multiple rounds of testing, the consensus processing logic in the blockchain system can be verified for its ability to handle and recover from node malicious behavior, so that the blockchain system has a higher ability to deal with attacks.
[0116] In a specific embodiment, the Attack Server is connected to the startup program and the Attack Interface in the blockchain system. The Attack Server is started by connecting to the program that starts the consensus process in the blockchain system to perform malicious attacks (i.e., calling the interface program corresponding to the malicious scenario to simulate the malicious scenario). After the Attack Server is initialized, it calls the Attack Interface to inject various malicious scenarios, and simulates malicious scenarios such as abnormal voting and abnormal signatures by changing the operation of the program.
[0117] This solution has certain versatility and assemblability, and can be applied to various BFT consensus algorithm go language blockchain systems to improve the blockchain system's ability to respond to attacks, and can find out as early as possible whether there are problems with the consensus processing logic for malicious scenarios in the consensus process, so as to modify and optimize as soon as possible to avoid large losses in the actual production environment. Moreover, based on the method of this application, the malicious scenarios inside the node can be effectively simulated, which can solve the problem of the inability to artificially simulate the internal malicious scenarios of the node in the related technology, and enrich the testing methods of the blockchain system.
[0118] The following describes an apparatus embodiment of the present application, which can be used to execute the method in the above-mentioned embodiment of the present application. For details not disclosed in the apparatus embodiment of the present application, please refer to the above-mentioned method embodiment of the present application.
[0119] Fig.12 is a block diagram of a test device for a blockchain system according to an embodiment of the present application. The test device for the blockchain system can be configured at a node in the blockchain system, such as Fig.12 As shown, the testing device of the blockchain system includes: an acquisition module 1210, which is used to obtain scenario simulation information of the node, and the scenario simulation information includes a target scenario identifier corresponding to the target malicious scenario to be simulated, and the target malicious scenario refers to a scenario in which the normal processing logic of the target link is attacked during the consensus process; a calling module 1220, which is used to call the interface program corresponding to the target malicious scenario according to the target scenario identifier during the consensus process, so that the node simulates the target malicious scenario in the target link during the consensus process; a test result determination module 1230, which is used to determine the test result of the consensus processing logic of the blockchain system for the target malicious scenario according to the operation log of the node and the operation log of at least one other node in the blockchain system during the simulation of the target malicious scenario.
[0120] In some embodiments, the scenario simulation information also includes a simulation end condition; the testing device of the blockchain system also includes: a stop calling module, which is used to stop calling the interface program corresponding to the target malicious scenario if the simulation end condition is reached, and process it according to the normal processing logic corresponding to the target link.
[0121] In some embodiments, the testing device of the blockchain system also includes: a malicious result determination module, which is used to determine the malicious result of the target malicious scenario based on the operation log of the node in the process of simulating the target malicious scenario; an interface test result determination module, which is used to determine the test result of the interface program corresponding to the target malicious scenario based on the malicious result of the target malicious scenario and the expected malicious result set for the target malicious scenario.
[0122] In some embodiments, the target link is the voting link; the target malicious scenario is the first malicious scenario or the second malicious scenario; the first malicious scenario is a scenario in which abnormal voting content is voted for in the voting link; the second malicious scenario is a scenario in which an abnormal signature is used to sign a vote in the voting link; wherein the abnormal signature is determined by signing with an abnormal signature party identifier, or constructing an abnormal signature string, or signing with an abnormal signature algorithm.
[0123] In some embodiments, the target link is the proposal link; the target malicious scenario is one of the third malicious scenario, the fourth malicious scenario, the fifth malicious scenario and the sixth malicious scenario; the third malicious scenario is a scenario in which different proposals are sent to at least two different other nodes in the proposal link; the fourth malicious scenario is a scenario in which a proposal is initiated at a time other than the node's own proposal; the fifth malicious scenario is a scenario in which an abnormal proposal hash value is constructed for the proposal; the sixth malicious scenario refers to a scenario in which duplicate transactions are added to the proposal.
[0124] In some embodiments, the target malicious scenario is one of the seventh malicious scenario, the eighth malicious scenario, the ninth malicious scenario, the tenth malicious scenario and the eleventh malicious scenario; the seventh malicious scenario refers to the scenario of forging blocks in the blockchain; the eighth malicious scenario refers to the scenario of entering the next link in advance without confirming that the consensus has been passed; the ninth malicious scenario refers to the scenario where the node initiates a timeout vote when the votes of other nodes do not exceed the time threshold; the tenth malicious scenario refers to the scenario of adding multiple generation transactions to the block; the eleventh malicious scenario refers to the scenario of adding generation transactions signed by non-proposal nodes to the block.
[0125] In some embodiments, the testing device of the blockchain system also includes: a prompt information generation module, which is used to generate modification prompt information if the test result of the interface corresponding to the target malicious scenario indicates that the malicious result of the target malicious scenario is inconsistent with the corresponding expected malicious result, and the modification prompt information is used to indicate that the attack code of the interface corresponding to the target malicious scenario is modified.
[0126] Fig.13 The structure diagram of the computer system suitable for implementing the electronic device of the embodiment of the present application is shown. It should be noted that: Fig.13 The computer system 1300 of the electronic device shown is only an example and should not bring any limitation to the functions and scope of use of the embodiments of the present application. The electronic device can be a node in the blockchain system, used to execute the testing method of the blockchain system provided in the present application.
[0127] like Fig.13As shown, the computer system 1300 includes a central processing unit (CPU) 1301, which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM) 1302 or the program loaded from the storage part 1308 to the random access memory (RAM) 1303, such as executing the method in the above embodiment. In RAM 1303, various programs and data required for system operation are also stored. CPU 1301, ROM 1302 and RAM 1303 are connected to each other through bus 1304. Input / output (I / O) interface 1305 is also connected to bus 1304.
[0128] The following components are connected to the I / O interface 1305: an input section 1306 including a keyboard, a mouse, etc.; an output section 1307 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage section 1308 including a hard disk, etc.; and a communication section 1309 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication section 1309 performs communication processing via a network such as the Internet. A drive 1310 is also connected to the I / O interface 1305 as needed. A removable medium 1311, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1310 as needed so that a computer program read therefrom is installed into the storage section 1308 as needed.
[0129] In particular, according to an embodiment of the present application, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present application includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network through a communication section 1309, and / or installed from a removable medium 1311. When the computer program is executed by a central processing unit (CPU) 1301, various functions defined in the system of the present application are executed.
[0130] It should be noted that the computer-readable medium shown in the embodiment of the present application may be a computer-readable signal medium or a computer-readable storage medium or any combination of the above two. The computer-readable storage medium may be, for example, - but not limited to - an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or device, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present application, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by an instruction execution system, device or device or used in combination with it. In the present application, a computer-readable signal medium may include a data signal propagated in a baseband or as part of a carrier wave, wherein a computer-readable program code is carried. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than computer-readable storage media, which may send, propagate, or transmit programs for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0131] The flowchart and block diagram in the accompanying drawings illustrate the possible architecture, functions and operations of the system, method and computer program product according to various embodiments of the present application. Wherein, each box in the flowchart or block diagram can represent a module, a program segment, or a part of the code, and the above-mentioned module, program segment, or a part of the code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flowchart, and the combination of boxes in the block diagram or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0132] The units involved in the embodiments described in this application may be implemented by software or hardware, and the units described may also be set in a processor. The names of these units do not, in some cases, constitute limitations on the units themselves.
[0133] As another aspect, the present application further provides a computer-readable storage medium, which may be included in the electronic device described in the above embodiments; or may exist independently without being assembled into the electronic device. The above computer-readable storage medium carries computer-readable instructions, and when the computer-readable storage instructions are executed by a processor, the method in any of the above embodiments is implemented.
[0134] According to one aspect of the embodiments of the present application, a computer program product or a computer program is provided, the computer program product or the computer program includes computer instructions, the computer instructions are stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium, and the processor executes the computer instructions, so that the computer device executes the method in any of the above embodiments.
[0135] It should be noted that, although several modules or units of the equipment for action execution are mentioned in the above detailed description, this division is not mandatory. In fact, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. On the contrary, the features and functions of one module or unit described above can be further divided into being embodied by multiple modules or units.
[0136] Through the description of the above implementation methods, it is easy for those skilled in the art to understand that the example implementation methods described here can be implemented by software or by combining software with necessary hardware. Therefore, the technical solution according to the implementation methods of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash drive, a mobile hard disk, etc.) or on a network, and includes several instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to execute the method according to the implementation methods of the present application.
[0137] Those skilled in the art will readily appreciate other embodiments of the present application after considering the specification and practicing the embodiments disclosed herein. The present application is intended to cover any variations, uses or adaptations of the present application, which follow the general principles of the present application and include common knowledge or customary technical means in the art that are not disclosed in the present application.
[0138] It should be understood that the present application is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present application is limited only by the appended claims.
Claims
1. A testing method for a blockchain system, characterized in that: Applied to a node in a blockchain system, the method comprises: Obtaining scenario simulation information of the node, the scenario simulation information including a target scenario identifier corresponding to a target malicious scenario to be simulated, the target malicious scenario being a scenario in which the normal processing logic of the target link is attacked during the consensus process; In the consensus process, the interface program corresponding to the target malicious scenario is called according to the target scenario identifier, so that the node simulates the target malicious scenario in the target link of the consensus process; According to the operation log of the node and the operation log of at least one other node in the blockchain system during the simulation of the target malicious scenario, the test result of the consensus processing logic of the blockchain system for the target malicious scenario is determined.
2. The method according to claim 1, characterized in that The scenario simulation information also includes simulation end conditions; After calling the interface program corresponding to the target malicious scenario according to the target scenario identifier during the consensus process so that the node simulates the target malicious scenario in the target link of the consensus process, the method further includes: If the simulation end condition is reached, stop calling the interface program corresponding to the target malicious scenario, and process according to the normal processing logic corresponding to the target link.
3. The method according to claim 1, characterized in that After calling the interface program corresponding to the target malicious scenario according to the target scenario identifier during the consensus process so that the node simulates the target malicious scenario in the target link of the consensus process, the method further includes: Determining a malicious result of the target malicious scenario according to the operation log of the node in the process of simulating the target malicious scenario; According to the malicious result of the target malicious scenario and the expected malicious result set for the target malicious scenario, the test result of the interface program corresponding to the target malicious scenario is determined.
4. The method according to claim 1, characterized in that: The target link is the voting link; The target malicious scenario is the first malicious scenario or the second malicious scenario; The first malicious scenario is a scenario in which voting is performed on abnormal voting content during the voting phase; The second malicious scenario is a scenario in which an abnormal signature is used to sign a vote during the voting process; wherein the abnormal signature is determined by signing with an abnormal signing party identifier, or constructing an abnormal signature string, or signing with an abnormal signature algorithm.
5. The method according to claim 1, characterized in that The target link is the proposal link; The target malicious scenario is one of the third malicious scenario, the fourth malicious scenario, the fifth malicious scenario and the sixth malicious scenario; The third malicious scenario is a scenario where different proposals are sent to at least two different other nodes during the proposal phase; The fourth malicious scenario is a scenario where a proposal is initiated at a time other than the node's own proposal time; The fifth malicious scenario is to construct an abnormal proposal hash value for the proposal; The sixth malicious scenario refers to a scenario in which duplicate transactions are added to a proposal.
6. The method according to claim 1, characterized in that The target malicious scene is one of the seventh malicious scene, the eighth malicious scene, the ninth malicious scene, the tenth malicious scene and the eleventh malicious scene; The seventh malicious scenario refers to the scenario of forging blocks in the blockchain; The eighth malicious scenario refers to the scenario of entering the next stage in advance without confirming that consensus has been passed; The ninth malicious scenario refers to a scenario where a node initiates a timeout vote when the votes of other nodes do not exceed the time threshold; The tenth malicious scenario refers to adding multiple generation transactions to a block; The eleventh malicious scenario refers to the scenario of adding a generated transaction signed by a non-proposing node to a block.
7. The method according to claim 3, characterized in that After determining the test result of the interface program corresponding to the target malicious scenario according to the malicious result of the target malicious scenario and the expected malicious result set for the target malicious scenario, the method further includes: If the test result of the interface program corresponding to the target malicious scenario indicates that the malicious result of the target malicious scenario does not match the corresponding expected malicious result, a modification prompt information is generated, and the modification prompt information is used to instruct to modify the attack code of the interface program corresponding to the target malicious scenario.
8. A testing device for a blockchain system, characterized in that: Applied to a node in a blockchain system, the device comprises: An acquisition module, used to acquire scenario simulation information of the node, wherein the scenario simulation information includes a target scenario identifier corresponding to a target malicious scenario to be simulated; the target malicious scenario refers to a scenario in which the normal processing logic of the target link is attacked during the consensus process; A calling module, used to call the interface program corresponding to the target malicious scenario according to the target scenario identifier during the consensus process, so that the node simulates the target malicious scenario in the target link of the consensus process; A test result determination module is used to determine the test result of the consensus processing logic of the blockchain system for the target malicious scenario based on the operation log of the node and the operation log of at least one other node in the blockchain system during the simulation of the target malicious scenario.
9. An electronic device, characterized in that: include: processor; A memory having computer-readable instructions stored thereon, wherein when the computer-readable instructions are executed by the processor, the method according to any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium having computer-readable instructions stored thereon, characterized in that: When the computer-readable instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.
Citation Information
Cited By
Main and standby CPE system, CPE main and standby implementation method and communication equipment
CN119561661A
Consensus network health real-time detection method based on behavior divergence device
CN119696910A
A consensus network health real-time detection method based on a behavior diverter
CN119696910B
