Data processing method and device and computer readable storage medium
By injecting abnormal code into the blockchain network and simulating evil nodes and executing test cases, the efficiency and accuracy of detection of evil consensus nodes in the blockchain network are solved, and efficient and automated detection capabilities are achieved.
Patent Information
- Application Number
- CN202310671439.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-07
- Publication Date
- 2024-12-10
AI Technical Summary
The existing technology is difficult to efficiently and accurately detect the existence of consensus nodes in blockchain networks, and the existing methods have problems such as security risks and large workload and poor accuracy.
By obtaining the consensus node information of the blockchain network, injecting abnormal code, simulating evil nodes, generating executable files, sending them to the consensus network, and executable cases are executed to detect the evil ability of the blockchain network, and achieving automated detection.
It improves the efficiency and accuracy of blockchain network detection of consensus nodes for evil deeds, reduces manual intervention, is more applicable and has a high degree of automation.
Smart Images

Figure CN119109604A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and in particular to a data processing method, device, and computer-readable storage medium. Background Art
[0002] The blockchain network mainly includes four components: P2P network, cryptography, consensus mechanism, and smart contract. Based on these four technologies, the blockchain has decentralization, openness, information immutability, autonomy, and anonymity, so it is widely used in the financial field. However, as a public network, the autonomy of the blockchain network mainly depends on the honesty of most nodes. When there are malicious consensus nodes in the blockchain network, the transaction data of the blockchain network may be tampered with, thereby affecting the consensus state. In order to ensure that the blockchain network has the ability to detect the existence of malicious consensus nodes, it is necessary to perform anomaly testing on the blockchain network. The existing technology generally filters the data protocol and modifies the transaction data to achieve anomaly testing on the blockchain network. In this process, the blockchain protocol data needs to be understood in advance, and there are security risks in the process of network unpacking, subpackaging, grouping and packaging, which is labor-intensive and has poor accuracy. Therefore, how to efficiently and accurately detect whether the blockchain network has the ability to detect malicious consensus nodes has become a technical problem that needs to be solved urgently. Summary of the invention
[0003] The embodiments of the present application provide a data processing method, device, and computer-readable storage medium that can efficiently detect the blockchain network's detection capability for malicious consensus nodes.
[0004] The present application provides a data processing method, which includes:
[0005] Obtain blockchain parameters for the consensus network in the blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3;
[0006] Obtain the insertion location point in the underlying logic code in the blockchain network, obtain the abnormal code used to simulate the abnormal event of the blockchain, and inject the abnormal code into the insertion location point in the underlying logic code;
[0007] Determine S simulated malicious consensus nodes from the M consensus nodes, and obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information; S is a positive integer less than or equal to M;
[0008] Generate an executable file for the abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capabilities indicated by the executable file;
[0009] The test case used to execute the blockchain business is sent to the blockchain network, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network.
[0010] The embodiment of the present application provides a data processing method, which is executed by a consensus node in a blockchain network, and the consensus node belongs to a consensus network including M consensus nodes in the blockchain network; the method includes:
[0011] The consensus node receives the malicious node information and executable files for abnormal codes sent by the test server;
[0012] If the malicious node information contains the node information of the consensus node, the malicious capability indicated by the executable file is configured;
[0013] A test case for executing a blockchain business sent by a test server is received, and the test case is jointly executed by the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, so as to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the server from M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
[0014] An embodiment of the present application provides a data processing device, including:
[0015] A first acquisition module is used to acquire blockchain parameters for a consensus network in a blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3;
[0016] The first processing module is used to obtain a plug-in location point in the underlying logic code in the blockchain network, obtain an abnormal code for simulating an abnormal event of the blockchain, and inject the abnormal code into the plug-in location point in the underlying logic code;
[0017] The malicious consensus node determination module is used to determine S simulated malicious consensus nodes from M consensus nodes, and obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information; S is a positive integer less than or equal to M;
[0018] The first generation module is used to generate an executable file for abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capability indicated by the executable file;
[0019] The first test module is used to send test cases for executing blockchain business to the blockchain network, so that the blockchain network executes the test cases through the underlying logic code containing abnormal code and the consensus network containing S simulated malicious consensus nodes to obtain test results for the blockchain network.
[0020] Among them, the above-mentioned malicious consensus node determination module includes:
[0021] A first acquisition unit is used to acquire an abnormal consensus scenario type, where the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network;
[0022] The first processing unit is used to determine the number S based on the M consensus nodes and the abnormal consensus scenario type, select S consensus nodes from the M consensus nodes as simulated malicious consensus nodes, and obtain node information of the S simulated malicious consensus nodes from the blockchain parameters as malicious node information.
[0023] The first generation module includes:
[0024] A compilation unit is used to precompile the abnormal code to obtain an intermediate file code, and to perform binary compilation on the intermediate file code to obtain an executable file;
[0025] The second processing unit is used to send the executable files to the M consensus nodes respectively based on the node addresses included in the node information of the M consensus nodes.
[0026] Wherein, the above-mentioned data processing device further includes:
[0027] The second generation module is used to generate an exception trigger request for the consensus network, where the exception trigger request is used to trigger S simulated malicious consensus nodes in the consensus network to execute abnormal codes based on executable files;
[0028] The first sending module is used to send an exception trigger request to each simulated malicious consensus node included in the M consensus nodes based on the node information of the M consensus nodes, so that each simulated malicious consensus node in the M consensus nodes runs the executable file based on the exception trigger request to obtain the malicious capability indicated by the executable file; the consensus node has the ability to identify that it belongs to a simulated malicious consensus node through the malicious node information.
[0029] Wherein, the above-mentioned data processing device further includes:
[0030] A detection log generation module is used to generate a detection log based on the test results for the blockchain network. The detection log includes malicious node information of S simulated malicious consensus nodes and the test results for the blockchain network;
[0031] The third processing module is used to clear the intermediate file code, notify the blockchain network to restore the S simulated malicious consensus nodes to normal consensus nodes, package the detection logs into blocks, and send the blocks to the blockchain network, so that the blockchain network can process the blocks on the blockchain through M normal consensus nodes.
[0032] Wherein, the above-mentioned data processing device further includes:
[0033] A fourth processing module is used to match the test results for the blockchain network with the abnormal consensus scenario type;
[0034] The first test module is used to determine that the blockchain network does not have the ability to detect malicious consensus nodes when the proportion of simulated malicious consensus nodes indicated by the abnormal consensus scenario type is greater than the proportion threshold and the test result is a successful blockchain business execution result.
[0035] On the one hand, an embodiment of the present application provides a data processing device, which is applied to a consensus node in a blockchain network, and the consensus node belongs to a consensus network including M consensus nodes in the blockchain network; the data processing device includes:
[0036] The second acquisition module is used to receive the malicious node information and the executable file for the abnormal code sent by the test server;
[0037] The second processing module is used to configure the malicious capability indicated by the executable file when the malicious node information includes the node information of the consensus node;
[0038] The second test module is used to receive a test case for executing a blockchain business sent by a test server, and to execute the test case together with the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the test server from the M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
[0039] The executable file includes an exception identifier; the second processing module includes:
[0040] A third processing unit is used to determine that the consensus node itself is a simulated malicious consensus node when the consensus node detects that the malicious node information includes the node information of the consensus node;
[0041] The fourth processing unit is used to trigger the execution of the executable file based on the simulated malicious consensus node to which the consensus node belongs when the consensus node detects that the executable file includes an exception identifier, or when the consensus node receives an exception trigger request sent by the test server, to obtain the malicious capability indicated by the executable file.
[0042] Wherein, the above-mentioned second test module includes:
[0043] A fifth processing unit is used to receive a test case for executing a blockchain service sent by the test server, and obtain a first transaction block associated with the test case, where the first transaction block includes block information associated with the test case;
[0044] A sixth processing unit, configured to trigger modification of block information in the first transaction block based on the underlying logic code and executable file containing the abnormal code in the blockchain network to obtain a second transaction block;
[0045] The detection unit is used to broadcast the second transaction block to the consensus network until a consensus result for the first transaction block is obtained, and determine a test result for the blockchain network based on the consensus result.
[0046] An embodiment of the present application provides a computer device, the computer device comprising: a processor, a memory, and a network interface;
[0047] The processor is connected to the memory and the network interface, wherein the network interface is used to provide data communication function, the memory is used to store program code, and the processor is used to call the program code to execute the method provided in the embodiment of the present application.
[0048] An embodiment of the present application provides a computer-readable storage medium, which stores a computer program. The computer program includes program instructions. When a processor executes the program instructions, a method provided in the embodiment of the present application is executed.
[0049] On the one hand, an embodiment of the present application provides a computer program product or a computer program, which includes computer instructions, and 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 the embodiment of the present application.
[0050] In an embodiment of the present application, the test server can obtain the insertion position point in the underlying logic code, and inject the abnormal code used to simulate the abnormal event of the blockchain into the insertion position point; the test server can obtain the blockchain parameters of the consensus network, determine S simulated malicious consensus nodes and malicious node information; further, the test server generates an executable file for the abnormal code, and sends the malicious node information and the executable file to the consensus network; the consensus node receives the malicious node information and the executable file for the abnormal code sent by the test server, and configures the malicious capability indicated by the executable file; further, the test server sends the test case to the blockchain network, and the consensus node receives the test case, and executes the test case together through the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing the simulated malicious consensus node, and obtains the test result for the blockchain network. Using the embodiment of the present application, the test server can inject the abnormal code at the insertion position point in the blockchain network, and the blockchain network can automatically run the abnormal code when running the test case, so that the simulated malicious consensus node has the ability to do evil. By simulating malicious consensus nodes and abnormal codes to conduct abnormal tests on the blockchain network, it is possible to efficiently detect whether the blockchain network has the ability to detect malicious consensus nodes. It has a high degree of automation and does not require human intervention, making it more applicable. BRIEF DESCRIPTION OF THE DRAWINGS
[0051] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0052] Figure 1 It is a schematic diagram of the system architecture of the data processing method provided in the embodiment of the present application;
[0053] Figure 2 It is a flow chart of a data processing method provided in an embodiment of the present application;
[0054] Figure 3 It is a data flow diagram of the data processing method provided in an embodiment of the present application;
[0055] Figure 4 is another flow chart of the data processing method provided in the embodiment of the present application;
[0056] Figure 5 is another data processing flow chart of the data processing method provided in an embodiment of the present application;
[0057] Figure 6 is another flow chart of the data processing method provided in the embodiment of the present application;
[0058] Figure 7 is an interactive schematic diagram of a data processing method provided in an embodiment of the present application;
[0059] Figure 8 is a structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0060] Fig. 9 is another structural schematic diagram of a data processing device provided in an embodiment of the present application;
[0061] Fig.10 is a structural schematic diagram of a computer device provided in an embodiment of the present application;
[0062] Fig.11 It is another structural schematic diagram of the computer device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0063] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0064] In order to better understand the technical solution of the present disclosure, the related technologies involved in the present disclosure are further introduced in detail below.
[0065] 1. Blockchain: In a narrow sense, blockchain is a chain data structure with blocks as the basic unit. The digital summary is used in the block to verify the transaction history previously obtained, which is suitable for the needs of tamper-proof and scalability in the distributed accounting scenario; in a broad sense, blockchain also refers to the distributed accounting technology implemented by the blockchain structure, including distributed consensus, privacy and security protection, peer-to-peer communication technology, network protocols, smart contracts, etc. The goal of the blockchain is to realize a distributed data record book, which only allows additions but not deletions. The basic structure of the underlying ledger is a linear linked list. The linked list is composed of "blocks" connected in series, and the hash value of the previous block is recorded in the subsequent block. Whether each block (and the transactions in the block) is legal can be quickly verified by calculating the hash value. If a node in the network proposes to add a new block, it must reach a consensus on the block through the consensus mechanism.
[0066] 2. Blockchain nodes: The blockchain network divides nodes into consensus nodes (also called core nodes) and synchronization nodes (which can include data nodes and light nodes). Among them, the consensus node is responsible for the consensus business of the entire blockchain network; the synchronization node is responsible for synchronizing the ledger information of the consensus node, that is, synchronizing the latest block data. Whether it is a consensus node or a synchronization node, its internal structure includes network communication components, because the blockchain network is essentially a peer-to-peer (P2P) network, and it needs to communicate with other nodes in the blockchain network through P2P components. The resources and services in the blockchain network are scattered on various nodes, and the transmission of information and the implementation of services are directly carried out between nodes without the intervention of intermediate links or centralized servers (third parties).
[0067] 3. Peer to Peer (P2P): A peer-to-peer network in which nodes can be either clients or servers. That is, each computer in the network can act as a requester of network services and respond to requests from other computers to provide resources, services and content.
[0068] 4. Accounting node: Accounting node, also known as block node, Leader node. In the blockchain, in each packaging cycle, the accounting node is required to package several transaction lists into a block structure and broadcast it to other nodes for consensus. The accounting node is the node that generates blocks and initiates proposals.
[0069] 5. Byzantine Fault Tolerance (BFT) is a fault-tolerant technology in the field of distributed computing. Byzantine Fault Tolerance originates from the Byzantine Generals Problem. The Byzantine Generals Problem is a modeling of the real world. Due to hardware errors, network congestion or interruptions, and malicious attacks, computers and networks may exhibit unpredictable behaviors. 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. For example, when a blockchain network contains (3S+1) consensus nodes, according to Byzantine Fault Tolerance, the blockchain network can tolerate Byzantine errors in up to S consensus nodes in the entire blockchain network without affecting the correct consensus.
[0070] 6. Proposal: At the beginning of the blockchain life cycle, the accounting node scans the transaction pool of the current node. When the transaction pool list is not empty, it triggers the generation of a block proposal. The proposal message includes block height, block header, merkle root, transaction information, etc. After the proposal message is broadcast to other nodes, the BFT Byzantine consensus is completed.
[0071] 7. Failpoint: Errors or abnormal behaviors can be injected into the code to simulate error handling in various complex systems to improve the system's fault tolerance, correctness, and stability. For example, by obtaining a fault point (such as a plug-in location) in the blockchain network, the abnormal code used for abnormal testing can be injected into the fault point to simulate blockchain anomalies and realize anomaly detection of the blockchain network.
[0072] The solution provided in the embodiment of this application relates to the field of blockchain technology. Figures 1 to 11 The system structure to which the method provided in the embodiments of the present application is applicable, and the method and device provided in the embodiments of the present application are illustrated.
[0073] See also Figure 1 , Figure 1 Schematic diagram of the system architecture of the data processing method provided in the embodiment of the present application. Figure 1 As shown, the system may include a blockchain network 100a, a test server 100b, and a terminal device cluster. The blockchain network 100a may include: blockchain nodes 10a, blockchain nodes 10b, blockchain nodes 10c, and blockchain nodes 10d. It is understood that the blockchain network 100a may include one or more blockchain nodes, and the embodiment of the present application does not limit the number of blockchain nodes. It is understood that in the blockchain network 100a, the blockchain nodes 10a, the blockchain nodes 10b, and the blockchain nodes 10d may form a consensus network, or the blockchain nodes 10a, the blockchain nodes 10b, the blockchain nodes 10d, and the blockchain nodes 10f ( Figure 1 The consensus network can be composed of any blockchain nodes in the blockchain network 100a. It is understandable that in the blockchain network 100a, the blockchain nodes 10a, 10b, and 10d can all exchange data through the network connection with the blockchain node 10c. It should be understood that each blockchain node in the blockchain network 100a (for example, blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d) can be used to maintain the same blockchain (for example, Figure 1 In the blockchain 10e shown in the figure, any two blockchain nodes in the blockchain network 100a can form a peer-to-peer network, and the peer-to-peer network can adopt the P2P protocol, wherein the P2P protocol is an application layer protocol running on the Transmission Control Protocol (TCP). In a distributed system, any device such as a server, a terminal device, etc. can join and become a blockchain node.
[0074] Among them, it is understandable that Figure 1 The blockchain nodes 10a, 10b, 10c, and 10d shown may have a one-to-one correspondence with the corresponding roles (i.e., entity objects in the corresponding business scenarios) that need to be connected to the blockchain network 100a. The business scenarios here may specifically include electronic bill scenarios, social scenarios, resource issuance scenarios, payment scenarios, etc. At this time, the business data information in the corresponding business scenarios may specifically include electronic bill information in the electronic bill scenario, data interaction information in the social scenario, resource issuance information in the resource issuance scenario, asset circulation records in the payment scenario, etc. The specific contents of the business data information in the corresponding business scenarios will not be listed one by one here.
[0075] It is understandable that the above system may include one or more test servers, and the number of test servers is not limited here. Figure 1 The test server 100b shown can be connected to the blockchain network 100a through a network connection so as to be able to exchange data through the network connection with the blockchain network 100a. The test server 100b can be a backend server corresponding to an application that has a business function associated with the blockchain network 100a and the blockchain network in any terminal device in the terminal device cluster.
[0076] The terminal device cluster may include terminal device 100c, terminal device 100d, terminal device 100e, ..., terminal device 100f. It is understandable that the terminal device cluster may include one or more terminal devices, and the embodiment of the present application does not limit the number of terminal devices. Among them, there may be a network connection between the terminal device clusters, for example, there is a network connection between the terminal device 100c and the terminal device 100d. At the same time, any terminal device in the terminal device cluster may have a network connection with the test server 100b, for example, there is a network connection between the terminal device 100f and the test server 100b. At the same time, any terminal device in the terminal device cluster may have a network connection with the blockchain network 100a, for example, there is a network connection between the terminal device 100d and the blockchain network 100a. Among them, the above-mentioned network connection does not limit the connection method, and can be directly or indirectly connected through a wired network, or directly or indirectly connected through a wireless network, or through other methods, which are not limited by the present application.
[0077] It should be understood that Figure 1 Each terminal device in the terminal device cluster shown in FIG. 1 may be installed with an application client. When the application client runs in each terminal device, it may be respectively connected to the above-mentioned Figure 1Data is exchanged between the test servers 100b shown. Among them, the application client can be an application client with blockchain data processing, such as a digital asset application, a blockchain application, etc. Among them, the application client can be an independent client, or it can be an embedded sub-client integrated in a client (such as a test client, a blockchain application client, etc.), which is not limited here. Taking the blockchain application as an example, the test server 100b can be a collection of multiple servers including a background server and a data processing server corresponding to the blockchain application. Therefore, the test server 100b can transmit data with each terminal device equipped with the blockchain application. For example, each terminal device can upload the blockchain parameters for the consensus network in the blockchain network 100a to the test server 100b through the blockchain application, and then the test server 100b can send the node information and executable files of the simulated malicious consensus node to other terminal devices or transmit them to the blockchain network 100a.
[0078] The data processing method provided in the embodiment of the present application can be executed by a computer device (or device for short) such as a terminal device or a server. The description of the server, terminal device, computer device, device, etc. mentioned in the embodiment of the present application can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server providing basic cloud computing services such as cloud database, cloud service, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform. The terminal device can be a smart phone, a tablet computer, a laptop computer, a desktop computer, a handheld computer, a mobile Internet device (mobile internet device, referred to as MID), a wearable device (such as a smart watch, a smart bracelet, etc.), a smart computer, a smart car, etc., which can run the above-mentioned application of the smart terminal. Among them, the test server 100b can establish a communication connection with each terminal device in the terminal cluster, and a communication connection can also be established between each terminal device in the terminal cluster. In other words, the test server 100b can establish a communication connection with each terminal device in the terminal device 100c, the terminal device 100d, the terminal device 100e, ..., the terminal device 100n. For example, a communication connection can be established between the terminal device 100c and the test server 100b. A communication connection can be established between the terminal device 100c and the terminal device 100d, and a communication connection can also be established between the terminal device 100c and the terminal device 100e. Among them, the above-mentioned communication connection does not limit the connection method, and can be directly or indirectly connected through a wired communication method, or directly or indirectly connected through a wireless communication method, etc. The specific connection can be determined according to the actual application scenario, and this application does not limit it here.
[0079] It should be understood that the implementation process of the data processing method provided in the embodiment of the present application can be performed in the test server, can also be performed in the terminal device, and can also be performed interactively in the terminal device and the test server, which is not limited here, wherein the terminal device can be the above-mentioned Figure 1 Any terminal device in the terminal device cluster of the corresponding embodiment. To facilitate subsequent understanding and description, the embodiment of the present application can be Figure 1 Select a terminal device from the terminal device cluster shown as the target terminal device, for example, terminal device 100c is used as the target terminal device. Terminal device 100c may be loaded with a blockchain application, and the test server may be the above Figure 1 The test server 100b of the corresponding embodiment and the blockchain network 100a can exchange data with the test server 100b through the terminal device 100c. The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0080] It is understandable that in the specific implementation of this application, related data such as user information is involved. When the embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.
[0081] It is understandable that Figure 1 Each terminal device in the terminal cluster shown in FIG. 1 can be installed with a blockchain application client (hereinafter referred to as blockchain application). When the blockchain application runs in each terminal device, it can be respectively connected to the above-mentioned Figure 1The test server 100b shown in the figure performs data interaction, so that the test server 100b can receive business data from each terminal device, and the above business data can be the blockchain parameters for the consensus network in the blockchain network 100a from the blockchain application. The blockchain application can be a client for blockchain data processing, that is, the blockchain network 100a can send the blockchain parameters for the consensus network in the blockchain network 100a to the test server 100b through the terminal device. The test server 100b obtains the node information of the M consensus nodes included in the blockchain parameters through the terminal device. The test server 100b can obtain the insertion position point in the underlying logic code in the blockchain network 100a, and obtain the abnormal code for simulating blockchain abnormal events. The test server 100b can determine the number of simulated malicious consensus nodes and the malicious node information of the simulated malicious consensus nodes, and send the malicious node information and the executable file for the abnormal code to the consensus network in the blockchain network 100a through the terminal device. It can be understood that the test server 100b can inject the abnormal code used to simulate the abnormal event of the blockchain into the plug-in position point in the underlying logic code, thereby enabling the simulated malicious consensus node in the consensus network to obtain the ability to do evil, and execute the test case for executing the blockchain business through the underlying logic code containing the abnormal code and the simulated malicious consensus node in the consensus network to obtain the test result for the blockchain network 100a. By adopting this application, the abnormal code can be automatically compiled to enable the simulated malicious consensus node to have the ability to do evil, and the test case can also be automatically executed to automatically simulate the impact of the malicious consensus node on the blockchain network consensus, with high automation and accuracy, and strong applicability.
[0082] For further information, see Figure 2 , Figure 2 1 is a flow chart of a data processing method provided in an embodiment of the present application. For ease of understanding, the present application embodiment is described by taking a test server as an example. For example, the test server may be the above Figure 1 The test server 100b of the corresponding embodiment. Figure 2 In the data processing method shown, each step of data processing can be executed by the test server, such as Figure 2 As shown, the data processing method may at least include the following steps S101 to S105.
[0083] Step S101, obtaining blockchain parameters for a consensus network in a blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3.
[0084] In some feasible implementations, the data processing method provided in the embodiments of the present application can test the detection capability of the blockchain network for malicious consensus nodes to determine whether the blockchain network has the detection capability to detect malicious consensus nodes. It can be understood that a blockchain product needs to go through at least two stages of development and abnormality testing before it goes online, that is, determining the functions of the blockchain product according to user needs and market development trends, and performing abnormality testing on the blockchain product to repair blockchain product vulnerabilities. Please refer to Figure 3 , Figure 3 It is a data flow diagram of the data processing method provided by the embodiment of the present application. First, the developer develops a blockchain product based on factors such as market demand and market prospects. After completing the development of the blockchain product, the blockchain product is submitted to the test platform (such as a software development and testing process management platform, which is used to manage software version development, testing, defect submission, regression testing, and release of the entire life cycle, etc.), and the test platform performs an abnormal test on the blockchain product. Among them, the above-mentioned test platform can be a blockchain application with a processing blockchain network, and the terminal device loaded with the above-mentioned blockchain application can interact with the test server for data, thereby realizing an abnormal test of the blockchain network and detecting whether the blockchain network has the ability to detect malicious consensus nodes.
[0085] Please see again Figure 1 , test server (such as Figure 1 The test server 100b shown in the figure can obtain the blockchain parameters for the consensus network in the blockchain network. Specifically, when the developer needs to perform an abnormal test on the blockchain product, the blockchain product that needs to be tested can be submitted to the above-mentioned blockchain application, and the terminal device (such as Figure 1 The terminal device 100c shown in the figure interacts with the test server 100b for data to implement abnormal testing of the blockchain product. The test server 100b can send a request to obtain the blockchain network in the above-mentioned blockchain product to the terminal device 100c, or the terminal device 100c can send a test request for the blockchain network to the test server 100b, and the test request can carry the blockchain parameters for the consensus network in the blockchain network, so that the test server 100b obtains the blockchain parameters for the consensus network in the blockchain network. It can be understood that the method for obtaining the blockchain parameters of the consensus network by the test server 100b can be specifically determined according to the actual application scenario, and this application does not limit it here. Among them, the blockchain parameters include the node information of M consensus nodes in the consensus network, and M is a positive integer greater than 3. Among them, the node information may include the node address of the consensus node. Among them, the blockchain network can be Figure 1In the blockchain network 100a shown, the consensus network of the blockchain network 100a may include multiple consensus nodes, and the number of consensus nodes in the consensus network is greater than 3, for example, Figure 1 The blockchain node 10a, blockchain node 10b, blockchain node 10c and blockchain node 10d shown may be consensus nodes included in the consensus network in the blockchain network 100a.
[0086] Step S102, obtaining an insertion location point in the underlying logic code in the blockchain network, obtaining an abnormal code for simulating an abnormal blockchain event, and injecting the abnormal code into the insertion location point in the underlying logic code.
[0087] For some possible implementations, please refer to Figure 3 After the tester submits the blockchain product to the blockchain application, the blockchain application will test the blockchain product through the terminal device and the test server. After the test server obtains the blockchain parameters for the consensus network in the blockchain network through the terminal device, it can obtain the insertion location point in the underlying logic code in the blockchain network, obtain the abnormal code used to simulate the abnormal event of the blockchain, and inject the abnormal code into the insertion location point in the underlying logic code. Among them, the insertion location point can exist in any module that affects the consensus mechanism, including the transaction module, the smart contract execution module, etc. For example, the test server can scan the underlying logic code in the blockchain network, obtain the transaction module in the blockchain network, and obtain the insertion location point from the transaction module. Among them, the insertion location point can be a function, a class, etc. in the blockchain node. Among them, the abnormal code can be a code containing abnormal transaction information, which can be used to modify the block information associated with the blockchain network. Among them, the abnormal transaction information can include the number of block transactions, the content of block transactions, etc. Among them, the number of block transactions can include the logic of block transactions, the number of block transactions, the amount of block transactions, etc., and the content of block transactions can include the initiator of block transactions, the receiver of block transactions, etc. After the test server obtains the abnormal code, it can inject the abnormal code into the insertion point in the underlying logic code. For example, the test server can detect the operation process of the blockchain network, and when it runs to the injection logic, it can inject the abnormal code into the insertion point in the underlying logic code. Among them, the injection logic refers to the logic of injecting the abnormal code. The tester can insert the injection logic into the underlying logic code of the blockchain network, so that the tester can control the number of simulated malicious consensus nodes and modify the block information through the injection logic to achieve the malicious content.
[0088] Step S103, determine S simulated malicious consensus nodes from the M consensus nodes, obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information; S is a positive integer less than or equal to M.
[0089] In some feasible implementations, the test server determines S simulated malicious consensus nodes among the M consensus nodes included in the consensus network. Specifically, the test server can determine the number of simulated malicious consensus nodes according to the consensus mechanism of the blockchain network. For the convenience of description, this application will take the Byzantine Fault Tolerance consensus (BFT) as an example for detailed description. The test server can obtain the abnormal consensus scenario type and determine the proportion threshold according to the Byzantine Fault Tolerance consensus. Among them, the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network. Among them, the proportion threshold can be used to represent the maximum tolerance value of the consensus network for the number of malicious consensus nodes, that is, when the number of malicious consensus nodes in the consensus network is greater than the maximum tolerance value, the consensus network is tested at this time and the test abnormal result is obtained; when the number of malicious consensus nodes in the consensus network is less than or equal to the maximum tolerance value, the consensus network is tested and the test normal result is obtained. Therefore, under the premise that the consensus network itself does not have defects, the blockchain network can be tested for abnormality based on the condition that when the number of malicious consensus nodes in the consensus network is greater than the ratio threshold, the test abnormality result will appear, so as to obtain the detection capability of the blockchain network for malicious consensus nodes. Among them, the test server can obtain the ratio threshold of abnormal consensus scenario type according to the following formula 1, that is,
[0090]
[0091] Wherein, M is the number of consensus nodes in the consensus network. Wherein, the ratio threshold can be used to determine the type of abnormal consensus scenario, that is, the abnormal consensus scenario type can include a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold, and a consensus scenario in which the number of simulated malicious consensus nodes is less than or equal to the ratio threshold.
[0092] Furthermore, the test server may determine the number S based on the M consensus nodes and the abnormal consensus scenario type, that is, the test server selects S consensus nodes from the M consensus nodes as simulated malicious consensus nodes according to the abnormal consensus scenario type, which is a consensus scenario in which the number S of simulated malicious consensus nodes is greater than the ratio threshold, or a consensus scenario in which the number S of simulated malicious consensus nodes is less than or equal to the ratio threshold, and obtains the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information. Among them, S is a positive integer less than or equal to M. Among them, the test server may randomly select a consensus node as a malicious consensus node, or specify any consensus node as a malicious consensus node. For example, please refer to Figure 1, if the consensus network in blockchain network 100a includes 4 consensus nodes, M is equal to 4. At this time, blockchain node 10a, blockchain node 10b, blockchain node 10c, and blockchain node 10d together constitute a consensus network. Test server 100b can determine that the ratio threshold is equal to 1.3 according to the above formula 1. Test server 100b can determine the number S of simulated malicious consensus nodes according to the consensus scenario in which the number S of simulated malicious consensus nodes is greater than the ratio threshold, or the consensus scenario in which the number S of simulated malicious consensus nodes is less than or equal to the ratio threshold. If test server 100b determines that the number S of simulated malicious consensus nodes is 2, and blockchain node 10a and blockchain node 10b are determined as simulated malicious consensus nodes, then test server 100b can obtain the node information corresponding to blockchain node 10a and blockchain node 10b respectively from the blockchain parameters as malicious node information.
[0093] Step S104, generating an executable file for the abnormal code, and sending the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capabilities indicated by the executable file.
[0094] For some possible implementations, please refer to Figure 3 , the test server can generate an executable file for the abnormal code. Specifically, the test server can precompile the abnormal code to obtain an intermediate file code, and perform binary compilation on the intermediate file code to obtain an executable file. Among them, the intermediate file code can include configuration parameters of the abnormal code, and the executable file is a binary code.
[0095] Further, the test server may send the malicious node information and executable file to the consensus network so that the S simulated malicious consensus nodes in the consensus network have the malicious capability indicated by the executable file. Specifically, the test server may send the malicious node information and executable file to the consensus network through the terminal device based on the node address included in the node information of the M consensus nodes. Among them, after the consensus node receives the malicious node information and executable file sent by the test server through the terminal device, if the malicious node information includes the node information of the above-mentioned consensus node, that is, the S simulated malicious consensus nodes include the above-mentioned consensus node, then the above-mentioned consensus node determines that it belongs to the simulated malicious consensus node, and the above-mentioned consensus node is configured with the malicious capability indicated by the executable file, that is, the above-mentioned consensus node has the malicious capability to modify the block information associated with the blockchain network. It can be understood that if the malicious node information does not include the node information of the above-mentioned consensus node, then the above-mentioned consensus node determines that it does not belong to the simulated malicious consensus node, that is, the above-mentioned consensus node does not have the malicious capability to modify the block information associated with the blockchain network. For example, please refer again Figure 1, the test server 100b sends the malicious node information and the executable file to the consensus network in the blockchain network 100a. If the test server 100b detects that the malicious node information includes the node information corresponding to the blockchain node 10a and the blockchain node 10b in the consensus network, the test server 100b can determine the blockchain node 10a and the blockchain node 10b as simulated malicious consensus nodes. The blockchain node 10a and the blockchain node 10b can receive the malicious node information and the executable file for the abnormal code sent by the test server 100b through the terminal device 100c. If the blockchain node 10a detects that the malicious node information includes the node information of the blockchain node 10a, the blockchain node 10a determines that it belongs to the simulated malicious consensus node, and the blockchain node 10a can configure the malicious capability indicated by the executable file, that is, the blockchain node 10a has the malicious capability to modify the block information associated with the blockchain network. Similarly, if blockchain node 10b detects that the malicious node information includes blockchain node 10b, blockchain node 10b can be configured with the malicious capability indicated by the executable file, that is, blockchain node 10b has the malicious capability to modify the block information associated with the blockchain network.
[0096] Step S105, sending the test case for executing the blockchain business to the blockchain network, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network.
[0097] For some possible implementations, please refer to Figure 3, the test server sends the test case for executing the blockchain business to the blockchain network through the terminal device, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network. Among them, the test case for executing the blockchain business is legal. Specifically, the test server can send the test case for executing the blockchain business to the blockchain network, and the test server can generate an abnormal trigger request for the consensus network. Among them, the abnormal trigger request is used to trigger the S simulated malicious consensus nodes in the consensus network to execute the abnormal code based on the executable file. Further, based on the node information of the M consensus nodes, the test server sends the abnormal trigger request to each simulated malicious consensus node included in the M consensus nodes, so that each simulated malicious consensus node in the M consensus nodes runs the executable file based on the abnormal trigger request, and obtains the malicious capability indicated by the executable file. Among them, the consensus node has the ability to identify itself as a simulated malicious consensus node through the malicious node information. In other words, after the consensus node receives the malicious node information and the executable file for the abnormal code sent by the test server, it can identify whether it is a simulated malicious consensus node based on the malicious node information. Figure 1 After the test server 100b determines the blockchain node 10a and the blockchain node 10b in the consensus network as simulated malicious consensus nodes, the test server 100b can generate an abnormal trigger request for the consensus network. The test server 100b sends the abnormal trigger request to the blockchain node 10a and the blockchain node 10b in the consensus network according to the node information of the consensus node, triggering the blockchain node 10a and the blockchain node 10b to run the executable file respectively, so as to obtain the malicious capability indicated by the executable file.
[0098] Further, after the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test results for the blockchain network, the test server can generate a detection log based on the test results for the blockchain network. The detection log includes the malicious node information of the S simulated malicious consensus nodes and the test results for the blockchain network. For example, please refer to Figure 1, if the abnormal consensus scenario type is a consensus scenario in which the number S of simulated malicious consensus nodes is less than or equal to the ratio threshold, the number S of simulated malicious consensus nodes is determined to be 1, and the test server 100b can determine the blockchain node 10a as a simulated malicious consensus node, so that the blockchain network 100a can obtain the test results for the blockchain network 100a by simulating the malicious consensus node (i.e., blockchain node 10a) and the abnormal code execution test case. The test server 100b can generate a detection log based on the test results for the blockchain network 100a. Among them, the detection log may include the malicious node information of the blockchain node 10a, and the test results for the blockchain network 100a.
[0099] Optionally, the test server may match the test results for the blockchain network with the abnormal consensus scenario type. If the proportion of the number of simulated malicious consensus nodes indicated by the abnormal consensus scenario type is greater than the ratio threshold, and the test result is a successful blockchain business execution result, it is determined that the blockchain network does not have the ability to detect malicious consensus nodes. Specifically, if the abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold, and the test result is a successful blockchain business execution result, the test server determines that the blockchain network does not have the ability to detect malicious consensus nodes. If the abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold, and the test result is an abnormal result of blockchain business execution, the test server determines that the blockchain network has the ability to detect malicious consensus nodes. If the abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is less than or equal to the ratio threshold, and the test result is a successful blockchain business execution result, the test server cannot determine whether the blockchain network has the ability to detect malicious consensus nodes.
[0100] For example, see Figure 1, if the consensus network in the blockchain network 100a includes 4 consensus nodes, that is, M is equal to 4, that is, the blockchain node 10a, the blockchain node 10b, the blockchain node 10c, and the blockchain node 10d together constitute the consensus network. The test server 100b can determine the number S of simulated consensus nodes according to the above formula 1. If the test server 100b determines that the number S of simulated malicious consensus nodes is 2, and the blockchain node 10a and the blockchain node 10b are determined as simulated malicious consensus nodes. After the test server 100b can send the test case to the blockchain network 100a, the blockchain network 100a can execute the test case through the underlying logic code containing the abnormal code and the consensus network containing 2 simulated malicious consensus nodes. At this time, the abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold. If the test result of the blockchain network 100a for the consensus network is a successful blockchain business execution result, the test server determines that the blockchain network does not have the ability to detect malicious consensus nodes. The abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold. If the test result of the blockchain network 100a for the consensus network is an abnormal result of the blockchain business execution, the test server determines that the blockchain network has the ability to detect malicious consensus nodes.
[0101] Optionally, after the test server obtains the test results for the blockchain network, the test server can clear the intermediate file code, notify the blockchain network to restore the S simulated malicious consensus nodes to normal consensus nodes, package the detection logs into blocks, and send the blocks to the blockchain network, so that the blockchain network can process the blocks on the blockchain through M consensus nodes that are all normal. It should be understood that after the test server can clear the intermediate file code, the S simulated malicious consensus nodes will restore the block information associated with the blockchain network modified based on the executable file to the block information associated with the blockchain network before the modification.
[0102] In the embodiments of the present application, the data processing method provided by the present application can realize the automatic compilation process of the abnormal code by injecting the abnormal code into the plug-in location point, thereby greatly improving the efficiency of the abnormal test of the blockchain network; at the same time, the data processing method provided by the present application can cover multiple abnormal consensus scenario types, improve the accuracy of the abnormal test of the blockchain network, and has a high degree of automation and strong scalability.
[0103] See also Figure 4 , Figure 4 FIG. 1 is another flow chart of the data processing method provided in the embodiment of the present application. Figure 4 As shown, the method provided in the embodiment of the present application can be performed as follows Figure 1The test server 100 shown in the figure can also be executed by the terminal device and the test server together. The specific details can be determined according to the actual application scenario and are not limited here. For ease of understanding, the embodiment of the present application takes the test server and the terminal device interacting to execute the method as an example to illustrate. For example, the terminal device 100c is used as the target terminal device, and the test server can be the above Figure 1 The test server 100b of the corresponding embodiment. Figure 4 As shown, the data processing method may at least include the following steps S201 to S207.
[0104] Step S201, obtaining blockchain parameters for a consensus network in a blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3.
[0105] Step S202, obtaining an insertion location point in the underlying logic code in the blockchain network, obtaining an abnormal code for simulating an abnormal blockchain event, and injecting the abnormal code into the insertion location point in the underlying logic code.
[0106] The specific implementation of step S201 and step S202 can be found in the above Figure 2 S101-S102 in the corresponding embodiment will not be described in detail here.
[0107] Step S203, obtaining the abnormal consensus scenario type, where the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network.
[0108] In some feasible implementations, the test server can obtain the abnormal consensus scenario type. The abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network. The test server can obtain the abnormal consensus scenario type based on the Byzantine fault-tolerant consensus, that is, determine the proportion of simulated malicious consensus nodes in the consensus network based on the Byzantine fault-tolerant consensus. The test server can determine the abnormal consensus scenario type based on Formula 1, and determine the number of simulated malicious consensus nodes based on the abnormal consensus scenario type. Please refer to Figure 5 , Figure 5 is another data processing flow chart of the data processing method provided in the embodiment of the present application. Figure 5As shown, the consensus network includes 4 consensus nodes, that is, M=4, and the consensus network includes consensus node 1, consensus node 2, consensus node 3 and consensus node 4. According to formula 1, the ratio threshold is equal to 1.3. Since the number S of simulated malicious consensus nodes is a positive integer less than or equal to M, the number S of simulated malicious consensus nodes can be determined according to the ratio threshold equal to 1.3, and the abnormal consensus scenario type can be determined according to the number S of simulated malicious consensus nodes and the number M of consensus nodes in the consensus network. When S>1.3, the simulated abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold, that is, the number of simulated malicious consensus nodes is greater than 1 and less than or equal to 4. When S≤1.3, the simulated abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is less than or equal to the ratio threshold, that is, the number of simulated malicious consensus nodes is 1. After the test server selects the simulated malicious consensus node, it can trigger the simulated malicious consensus node to execute the executable file, so that the simulated malicious consensus node has the ability to do evil, and then perform abnormal tests on the blockchain network by simulating the malicious consensus node and the test case for executing the blockchain business, and obtain the test results for the blockchain network. The test server can generate a detection log based on the test results for the blockchain network. The specific steps can be referred to the implementation methods provided in each step from step S204 to step S207, which will not be repeated here.
[0109] Step S204, based on the M consensus nodes and the abnormal consensus scenario type, determine the number S, select S consensus nodes from the M consensus nodes as simulated malicious consensus nodes, and obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information.
[0110] In some feasible implementations, the test server can determine the number of simulated malicious consensus nodes based on the number of consensus nodes and the type of abnormal consensus scenario. Figure 5, the consensus network includes 4 consensus nodes and the abnormal consensus scenario type can be determined. When S>1.3, that is, the simulated abnormal consensus scenario type is a consensus scenario in which the number of simulated malicious consensus nodes is greater than the ratio threshold, then the number of simulated malicious consensus nodes is greater than 1 and less than or equal to 4, that is, the above consensus network can include 2 simulated malicious consensus nodes, 3 simulated malicious consensus nodes, and 4 simulated malicious consensus nodes. One of the three methods. For example, when the consensus network includes 2 simulated malicious consensus nodes, the test server can use consensus node 1 and consensus node 2 as simulated malicious consensus nodes, or consensus node 2 and consensus node 4 as simulated malicious consensus nodes. It can be understood that the test server can randomly select a consensus node as a simulated malicious consensus node, or specify a consensus node as a simulated malicious consensus node. The way in which the test server determines to select a consensus node as a simulated malicious consensus node can be determined according to the actual application scenario, and this application is not limited here. Similarly, when S≤1.3, that is, the type of simulated abnormal consensus scenario is a consensus scenario in which the number of simulated malicious consensus nodes is less than or equal to the ratio threshold, then the number of simulated malicious consensus nodes is less than or equal to 1 and greater than 0, that is, the above consensus network can include 1 simulated malicious consensus node. For example, when the consensus network includes 1 simulated malicious consensus node, the test server can use consensus node 1 as the simulated malicious consensus node, or consensus node 2 as the simulated malicious consensus node.
[0111] Step S205, precompile the abnormal code to obtain an intermediate file code, and perform binary compilation on the intermediate file code to obtain an executable file.
[0112] In some feasible implementations, the test server may precompile the abnormal code to obtain an intermediate file code, and perform binary compilation on the intermediate file code to obtain an executable file. The intermediate file code may include configuration parameters of the abnormal code, and the executable file is a binary code. The executable file includes an abnormal flag, and the abnormal flag is used to indicate that any transaction information such as the number of block transactions and the content of block transactions included in the abnormal transaction information has changed. When the test server clears the intermediate file code, the S simulated malicious consensus nodes will restore the block information associated with the blockchain network modified based on the executable file to the block information associated with the blockchain network before the modification.
[0113] Step S206: Based on the node addresses contained in the node information of the M consensus nodes, the executable files are sent to the M consensus nodes respectively.
[0114] In some feasible implementations, the test server may send the executable files to the M consensus nodes respectively based on the node addresses contained in the node information of the M consensus nodes. For example, please refer to Figure 5 The test server can obtain the node information of the four consensus nodes included in the consensus network, and send the executable files to the M consensus nodes respectively based on the node addresses respectively contained in the node information of the four consensus nodes.
[0115] Step S207, sending the test case for executing the blockchain business to the blockchain network, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network.
[0116] The specific implementation of step S207 can be found in the above Figure 2 S107 in the corresponding embodiment will not be described in detail here.
[0117] In the embodiment of the present application, the data processing method provided by the present application can realize the automatic compilation process of the abnormal code by injecting the abnormal code into the plugging position point, thereby improving the efficiency of the abnormal test for the blockchain network, and no manual access is required, and the cost is low; at the same time, the data processing method provided by the present application can cover multiple abnormal consensus scenario types, improve the accuracy of the abnormal test for the blockchain network, and has strong scalability. By adopting this application, it is possible to more efficiently and comprehensively detect whether the blockchain network has the ability to detect malicious consensus nodes, and it is more applicable.
[0118] Above Figure 2 , Figure 4 The execution process of the data processing method shown is based on the application server as the execution subject. The consensus nodes in the blockchain network (blockchain nodes 10a, 10b, 10c and 10d as shown in the figure) are used as the execution subjects. For example, blockchain node 10a is used as the execution subject to specifically explain the consensus node side behavior of the data processing method through an embodiment. Please refer to Figure 6 , Figure 6 FIG. 1 is another flow chart of the data processing method provided in the embodiment of the present application. Figure 6 As shown, the method is applicable to a terminal device loaded with a blockchain application, and includes the following steps:
[0119] Step S301: The consensus node receives the malicious node information and the executable file for the abnormal code sent by the test server.
[0120] In some feasible implementations, testers can submit the developed blockchain product to the blockchain application for abnormal testing. The blockchain application can be loaded on the terminal device, and the consensus node can realize the data interaction between the blockchain network in the blockchain product and the test server through the terminal device loaded with the blockchain application. Figure 1 , test server (such as Figure 1 The test server 100b) shown in FIG. 1 can send the malicious node information and executable files to the consensus network, and each consensus node in the consensus network can obtain the malicious node information and executable files through the terminal device 100c. Figure 1 The blockchain node 10a shown is described in detail as an example of a consensus node, that is, the blockchain node 10a can receive the malicious node information and executable file sent by the test server 100 through the terminal device 100c. Among them, the malicious node information includes the node information of the simulated malicious consensus node. Among them, the simulated malicious consensus node can obtain the malicious capability indicated by the executable file based on the executable file, that is, the simulated malicious consensus node has the malicious capability to modify the block information associated with the blockchain network.
[0121] Step S302: If the malicious node information includes the node information of the consensus node, the malicious capability indicated by the executable file is configured.
[0122] In some feasible implementations, if the consensus node detects that the malicious node information includes the node information of the above consensus node, the above consensus node determines that it is a simulated malicious consensus node. It can be understood that the consensus node has the ability to identify itself as a simulated malicious consensus node through the malicious node information. For details, please refer to Figure 1 ,like Figure 1 The blockchain network 100a shown includes 4 blockchain nodes, namely, blockchain node 10a, blockchain node 10b, blockchain node 10c and blockchain node 10d. Blockchain node 10a, blockchain node 10b, blockchain node 10c and blockchain node 10d can together form a consensus network, that is, blockchain node 10a, blockchain node 10b, blockchain node 10c and blockchain node 10d can be used as consensus nodes in the consensus network. It can be understood that blockchain node 10a, blockchain node 10b, blockchain node 10c and blockchain node 10d can all receive the malicious node information and executable file sent by the test server 100b through the terminal device 100c. If blockchain node 10a detects that the malicious node information includes the node information of blockchain node 10a, blockchain node 10a can determine that it belongs to a simulated malicious consensus node. If blockchain node 10b does not detect that the malicious node information includes the node information of blockchain node 10b, blockchain node 10b determines that it does not belong to a simulated malicious consensus node.
[0123] Furthermore, when the consensus node detects that the executable file includes an abnormal flag, or when the consensus node receives an abnormal trigger request sent by the test server, it triggers the execution of the executable file based on the simulated malicious consensus node to which it belongs, and obtains the malicious capability indicated by the executable file. Figure 1 If the blockchain node 10a has determined that it belongs to a simulated malicious consensus node, and detects through the terminal device 100c that the executable file includes an abnormal flag, then the blockchain node 10a triggers the execution of the executable file through the terminal device 100c based on the simulated malicious consensus node to which it belongs, and obtains the malicious capability indicated by the executable file, that is, the blockchain node 10a has the malicious capability to modify the block information associated with the blockchain network. Among them, the above-mentioned abnormal flag is used to indicate that any transaction information such as the number of block transactions and the content of block transactions included in the abnormal transaction information has changed. It can be understood that if the malicious node information does not include the node information of the above-mentioned consensus node, the above-mentioned consensus node determines that it does not belong to a simulated malicious consensus node, that is, the above-mentioned consensus node does not have the malicious capability to modify the block information associated with the blockchain network. For example, please refer again Figure 1 If the blockchain node 10a detects that the malicious node information includes the node information of the blockchain node 10a in the consensus network, the blockchain node 10a determines that it belongs to a simulated malicious consensus node, and the blockchain node 10a can be configured with the malicious capability indicated by the executable file, that is, the blockchain node 10a has the malicious capability to modify the block information associated with the blockchain network.
[0124] Optionally, the test server 100b can generate an abnormal trigger request for the consensus network, and send the abnormal trigger request to each simulated malicious consensus node in the consensus network through the terminal device 100c. If the blockchain node 10a detects the abnormal trigger request sent by the test server 100b, the blockchain node 10a determines that it belongs to a simulated malicious consensus node. At this time, the blockchain node 10a can trigger the execution of the executable file to obtain the malicious capability indicated by the executable file.
[0125] Step S303, receiving a test case for executing a blockchain business sent by a test server, and executing the test case together through the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include a consensus node, and the S simulated malicious consensus nodes are determined by the server from M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
[0126] In some feasible implementations, the consensus node may receive a test case sent by the test server for executing a blockchain service, and obtain the first transaction block associated with the test case. The first transaction block includes block information associated with the test case. For details, please refer to Figure 1 , the blockchain node 10a can receive the test case for executing the blockchain business sent by the test server 100b through the terminal device 100c, and obtain the first transaction block associated with the test case through the terminal device 100c. The first transaction block includes the block information associated with the test case. The block information may include the number of block transactions, the content of block transactions, etc. The number of block transactions may include the logic of block transactions, the number of block transactions, the amount of block transactions, etc., and the content of block transactions may include the initiator of block transactions, the recipient of block transactions, etc.
[0127] Furthermore, after the consensus node determines that it is a simulated malicious consensus node, it can trigger the modification of the block information in the first transaction block based on the underlying logic code and executable files containing abnormal codes in the blockchain network to obtain the second transaction block. For details, please refer to Figure 1 When the blockchain node 10a detects that the executable file includes an abnormal identification through the terminal device 100c, or the blockchain node 10a receives the abnormal trigger request sent by the application server 100b through the terminal device 100c, the blockchain node 10a triggers the modification of the block information in the first transaction block through the terminal device 100c based on the underlying logic code and executable file containing the abnormal code in the blockchain network 100a to obtain the second transaction block. It can be understood that the blockchain node 10a can modify the block transaction quantity, block transaction content, etc. included in the block information through the terminal device 100c.
[0128] Furthermore, the consensus node can broadcast the second transaction block to the consensus network through the terminal device, so that each consensus node in the consensus network can reach a consensus on the first transaction block, that is, obtain the voting result of each consensus node on the first transaction block, until the consensus result of the consensus network for the first transaction block is obtained, and the test result for the blockchain network is determined based on the consensus result. Figure 1, blockchain node 10a broadcasts the second transaction block to the consensus network, so that blockchain nodes 10a, blockchain nodes 10b, blockchain nodes 10c and blockchain nodes 10d in the consensus network all vote for the second transaction block. The consensus network obtains the consensus result of the consensus network for the first transaction block based on the voting result of each consensus node for the second transaction block, and determines the test result for the blockchain network based on the consensus result. Blockchain node 10a can send the test result for the blockchain network to the test server 100b through the terminal device 100c, and the test server 100b can generate a detection log based on the test result for the blockchain network. Among them, the detection log includes the malicious node information of S simulated malicious consensus nodes and the test result for the blockchain network.
[0129] In the embodiment of the present application, the data processing method provided by the present application, the consensus node can receive the malicious node information and the executable file for the abnormal code sent by the test server, determine whether it belongs to the simulated malicious consensus node based on the malicious node information, and run the executable file to configure the malicious ability indicated by the executable file, so that the consensus node has the ability to modify the block information associated with the blockchain network. The use of this application can enable the consensus node to have the ability to simulate the malicious ability of the abnormal node, thereby performing a simulated abnormal test on the blockchain network, which can improve the efficiency and accuracy of the abnormal test on the blockchain network, and does not require manual intervention, with low cost and strong scalability.
[0130] Please also see Figure 1 and Figure 7 , Figure 7 : is an interactive schematic diagram of the data processing method provided by the embodiment of the present application. Among them, the system between the terminal device and the application server can adopt the client / server (Client / Server, C / S) mode, or the browser and server (Browser / Server, B / S) mode. The data processing method includes:
[0131] Step 1: Submit the blockchain product to the test platform.
[0132] In some feasible implementations, when developers need to perform abnormal tests on blockchain products, they can submit the blockchain products that need to be tested to the above-mentioned blockchain application, and then load the blockchain application on the terminal device (such as Figure 1 The terminal device 100c) shown in the figure interacts with the test server 100b to perform abnormal testing on the blockchain product.
[0133] Step 2: The test server obtains the blockchain parameters for the consensus network in the blockchain network in the blockchain product.
[0134] In some feasible implementations, the test server may send a request for obtaining the blockchain network in the above-mentioned blockchain product to the blockchain network through a terminal device, or the terminal device may send a test request for the blockchain network to the test server, so that the test server obtains the blockchain parameters for the consensus network in the blockchain network. It can be understood that the method for obtaining the blockchain parameters of the consensus network by the test server can be determined according to the actual application scenario, and this application does not limit it here. Among them, the blockchain parameters include the node information of M consensus nodes in the consensus network, and M is a positive integer greater than 3. Among them, the node information may include the node address of the consensus node.
[0135] Step 3: The test server obtains the insertion location point and obtains the exception code used to simulate the blockchain abnormal event.
[0136] In some feasible implementations, after the test server obtains the blockchain parameters for the consensus network in the blockchain network through the terminal device, it can obtain the insertion location point in the underlying logic code in the blockchain network and obtain the abnormal code for simulating the abnormal event of the blockchain. Among them, the insertion location point can exist in any module that affects the consensus mechanism, including the transaction module, the smart contract execution module and other modules. For example, the test server can scan the underlying logic code in the blockchain network, obtain the transaction module in the blockchain network, and obtain the insertion location point from the transaction module. Among them, the insertion location point can be a function, a class, etc. in the blockchain node. Among them, the abnormal code can be a code containing abnormal transaction information, which can be used to modify the block information associated with the blockchain network. Among them, the abnormal transaction information can include the number of block transactions, the content of block transactions, etc. Among them, the number of block transactions can include the logic of block transactions, the number of block transactions, the amount of block transactions, etc., and the content of block transactions can include the initiator of block transactions, the receiver of block transactions, etc.
[0137] Step 4: The test server injects the exception code into the insertion point in the underlying logic code.
[0138] In some feasible implementations, after the test server obtains the insertion location point and the abnormal code used to simulate the abnormal event of the blockchain, the abnormal code is injected into the insertion location point in the underlying logic code. For example, the test server can monitor the operation process of the blockchain network, and when it runs to the injection logic, the abnormal code can be injected into the insertion location point in the underlying logic code. Among them, the injection logic refers to the logic of injecting the abnormal code. The tester can insert the injection logic into the underlying logic code of the blockchain network, so that the tester can control the number of simulated malicious consensus nodes and modify the block information through the injection logic to achieve the malicious content.
[0139] Step 5: The test server obtains the abnormal consensus scenario type.
[0140] In some feasible implementations, when the test server can obtain the abnormal consensus scenario type and determine the ratio threshold according to the Byzantine fault-tolerant consensus. Among them, the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network. Among them, the ratio threshold can be used to represent the maximum tolerance value of the consensus network for the number of malicious consensus nodes, that is, when the number of malicious consensus nodes in the consensus network is greater than the maximum tolerance value, the consensus network is tested at this time and the test abnormal result is obtained; when the number of malicious consensus nodes in the consensus network is less than or equal to the maximum tolerance value, the consensus network is tested and the test normal result is obtained. Therefore, under the premise that there are no defects in the consensus network itself, the blockchain network can be tested abnormally based on the condition that the test abnormal result will appear when the number of malicious consensus nodes in the consensus network is greater than the ratio threshold, so as to obtain the detection capability of the blockchain network for malicious consensus nodes.
[0141] Step 6: The test server determines the number of simulated malicious consensus nodes.
[0142] In some feasible implementations, the test server may determine the number S of simulated malicious consensus nodes based on the M consensus nodes and the abnormal consensus scenario type included in the consensus network, and select S consensus nodes from the M consensus nodes as simulated malicious consensus nodes. It is understandable that the test server may randomly select consensus nodes as simulated malicious consensus nodes, or may specify consensus nodes as simulated malicious consensus nodes. The way in which the test server determines to select consensus nodes as simulated malicious consensus nodes may be specifically determined according to the actual application scenario, and this application does not limit this.
[0143] Step 7: The test server determines the simulated malicious consensus node.
[0144] In some feasible implementations, after the test server selects S consensus nodes from M consensus nodes as simulated malicious consensus nodes, the node information of the S simulated malicious consensus nodes is obtained from the blockchain parameters as the malicious node information. Among them, the test server can randomly select S consensus nodes as simulated malicious consensus nodes, or specify consensus nodes as simulated malicious consensus nodes, which can be determined according to actual scenario applications, and this application does not limit it here.
[0145] Step 8: The test server obtains the intermediate file code.
[0146] In some feasible implementations, the test server may precompile the abnormal code to obtain an intermediate file code, wherein the intermediate file code may include configuration parameters of the abnormal code.
[0147] Step 9: Test the server to obtain the executable file.
[0148] In some feasible implementations, the test server may perform binary compilation on the intermediate file code to obtain an executable file.
[0149] Step 10: The test server sends the malicious node information and executable files to M consensus nodes respectively.
[0150] In some feasible implementations, the test server may send the malicious node information and executable file to the consensus network through the terminal device based on the node address included in the node information of the M consensus nodes. After the consensus node receives the malicious node information and executable file sent by the test server through the terminal device, if the malicious node information includes the node information of the above consensus node, that is, the S simulated malicious consensus nodes include the above consensus node, then the above consensus node determines that it belongs to the simulated malicious consensus node, and the above consensus node is configured with the malicious capability indicated by the executable file, that is, the above consensus node has the malicious capability to modify the block information associated with the blockchain network. It can be understood that if the malicious node information does not include the node information of the above consensus node, then the above consensus node determines that it does not belong to the simulated malicious consensus node, that is, the above consensus node does not have the malicious capability to modify the block information associated with the blockchain network.
[0151] Step 11: The consensus node receives the malicious node information and the executable file for the abnormal code sent by the test server.
[0152] In some feasible implementations, each consensus node in the consensus network can obtain malicious node information and executable files through a terminal device.
[0153] Step 12: The test server sends the test case for executing the blockchain business to the consensus node.
[0154] In some feasible implementations, the test server sends the test case for executing the blockchain service to the blockchain network through the terminal device, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network. Among them, the test case for executing the blockchain service is legitimate, that is, the consensus result of the blockchain network for the above test case is a consensus success result.
[0155] Step 13: The test server generates an exception trigger request for the consensus network and sends the exception trigger request to the consensus node.
[0156] In some feasible implementations, the test server may send a test case for executing a blockchain business to the blockchain network, and the test server may generate an exception trigger request for the consensus network. Among them, the exception trigger request is used to trigger S simulated malicious consensus nodes in the consensus network to execute abnormal codes based on executable files. Further, the test server sends the exception trigger request to M consensus nodes based on the node information of the M consensus nodes, so that each simulated malicious consensus node in the M consensus nodes runs the executable file based on the exception trigger request to obtain the malicious capability indicated by the executable file. Among them, the consensus node has the ability to identify itself as a simulated malicious consensus node through the malicious node information. In other words, after the consensus node receives the malicious node information sent by the test server and the executable file for the abnormal code, it can identify whether it belongs to a simulated malicious consensus node based on the malicious node information.
[0157] Step 14: When the consensus node detects that an abnormal identifier is included in the executable file, the malicious capability indicated by the executable file is configured.
[0158] In some feasible implementations, when a consensus node detects an abnormal identification in an executable file through a terminal device, or when a consensus node receives an abnormal trigger request sent by a test server through a terminal device, the executable file is triggered to run based on the simulated malicious consensus node to which it belongs, and the malicious capability indicated by the executable file is obtained.
[0159] Step 15: The consensus node executes the test case.
[0160] In some feasible implementations, the terminal device executes test cases through the underlying logic code containing abnormal code and the consensus network containing S simulated malicious consensus nodes to obtain test results for the blockchain network.
[0161] Step 16: The test server matches the test results of the blockchain network with the common consensus scenario type.
[0162] In some feasible implementations, if the abnormal consensus scenario type is a consensus scenario where the number of simulated malicious consensus nodes is greater than the ratio threshold, and the test result is a successful blockchain business execution result, the test server determines that the blockchain network does not have the ability to detect malicious consensus nodes. If the abnormal consensus scenario type is a consensus scenario where the number of simulated malicious consensus nodes is greater than the ratio threshold, and the test result is an abnormal result of blockchain business execution, the test server determines that the blockchain network has the ability to detect malicious consensus nodes. If the abnormal consensus scenario type is a consensus scenario where the number of simulated malicious consensus nodes is less than or equal to the ratio threshold, and the test result is a successful blockchain business execution result, the test server cannot determine whether the blockchain network has the ability to detect malicious consensus nodes.
[0163] Step 17: The test server generates a detection log based on the test results of the blockchain network.
[0164] In some feasible implementations, after the test server obtains the test results for the blockchain network, the test server may generate a detection log, wherein the detection log includes the malicious node information of S simulated malicious consensus nodes and the test results for the blockchain network.
[0165] Step 18: The test server clears the intermediate file code.
[0166] In some feasible implementations, after the test server obtains the test results for the blockchain network, the test server can clear the intermediate file code, notify the blockchain network to restore the S simulated malicious consensus nodes to normal consensus nodes, package the detection logs into blocks, and send the blocks to the blockchain network, so that the blockchain network can perform consensus on-chain processing on the blocks through M consensus nodes that are all normal. It should be understood that after the test server can clear the intermediate file code, the S simulated malicious consensus nodes will restore the block information associated with the blockchain network modified based on the executable file to the block information associated with the blockchain network before the modification.
[0167] The data processing method provided in the embodiment of the present application can test the ability of the blockchain network to detect malicious consensus nodes and realize the automated compilation process of abnormal codes, thereby greatly improving the efficiency of blockchain network abnormality testing; at the same time, the data processing method provided in the present application can cover multiple abnormal consensus scenario types, improve the accuracy of blockchain network abnormality testing, and has a high degree of automation and strong scalability.
[0168] Based on the description of the above data processing method embodiment, the present application embodiment also discloses a data processing device. The data processing device can be applied to Figures 2 to 5 In the data processing method of the embodiment shown, the data processing device is used to execute the steps in the data processing method. Here, the data processing device can be the above-mentioned Figures 2 to 5 The test server in the embodiment shown, that is, the data processing device can be the above-mentioned Figures 2 to 5 The execution subject of the data processing method in the embodiment shown. Figure 8 , Figure 8 1 is a schematic diagram of a data processing device provided in an embodiment of the present application. In an embodiment of the present application, the device 1 can run the following modules:
[0169] The first acquisition module 11 is used to obtain blockchain parameters for the consensus network in the blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3;
[0170] The first processing module 12 is used to obtain a plug-in location point in the underlying logic code in the blockchain network, obtain an abnormal code for simulating an abnormal event of the blockchain, and inject the abnormal code into the plug-in location point in the underlying logic code;
[0171] The malicious consensus node determination module 13 is used to determine S simulated malicious consensus nodes from the M consensus nodes, and obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information; S is a positive integer less than or equal to M;
[0172] The first generating module 14 is used to generate an executable file for the abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capability indicated by the executable file;
[0173] The first test module 15 is used to send the test case for executing the blockchain business to the blockchain network, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes to obtain the test result for the blockchain network.
[0174] According to the above Figure 2 The corresponding embodiment, Figure 2 The implementation method described in steps S101 to S105 in the data processing method shown in FIG. Figure 8 Each module of the device 1 shown in FIG. Figure 2 The implementation method described in step S101 of the data processing method shown in FIG. Figure 2 The implementation method described in step S102 can be performed by the first acquisition module 11 in the device 1 shown in the figure, the implementation method described in step S103 can be performed by the malicious consensus node determination module 13, the implementation method described in step S104 can be performed by the first generation module 14, and the implementation method described in step S105 can be performed by the first test module 15. The implementation methods performed by the above-mentioned first acquisition module 11, the first processing module 12, the malicious consensus node determination module 13, the first generation module 14 and the first test module 15 can refer to the above-mentioned Figure 2 The implementation methods provided in each step of the corresponding embodiment will not be repeated here.
[0175] The malicious consensus node determination module 13 includes:
[0176] The first acquisition unit 131 is used to acquire the abnormal consensus scenario type, where the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network;
[0177] The first processing unit 132 is used to determine the number S based on the M consensus nodes and the abnormal consensus scenario type, select S consensus nodes from the M consensus nodes as simulated malicious consensus nodes, and obtain node information of the S simulated malicious consensus nodes from the blockchain parameters as malicious node information.
[0178] The first generating module 14 includes:
[0179] The compiling unit 141 is used to precompile the abnormal code to obtain an intermediate file code, and perform binary compilation on the intermediate file code to obtain an executable file;
[0180] The second processing unit 142 is used to send the executable files to the M consensus nodes respectively based on the node addresses included in the node information of the M consensus nodes.
[0181] Wherein, the above-mentioned data processing device 1 further includes:
[0182] The second generating module 16 is used to generate an abnormal trigger request for the consensus network, where the abnormal trigger request is used to trigger S simulated malicious consensus nodes in the consensus network to execute abnormal codes based on executable files;
[0183] The first sending module 17 is used to send an exception trigger request to each simulated malicious consensus node included in the M consensus nodes based on the node information of the M consensus nodes, so that each simulated malicious consensus node in the M consensus nodes runs the executable file based on the exception trigger request to obtain the malicious capability indicated by the executable file; the consensus node has the ability to identify itself as a simulated malicious consensus node through the malicious node information.
[0184] Wherein, the above-mentioned data processing device 1 further includes:
[0185] A detection log generating module 18 is used to generate a detection log based on the test results for the blockchain network, and the detection log includes malicious node information of S simulated malicious consensus nodes and the test results for the blockchain network;
[0186] The third processing module 19 is used to clear the intermediate file code, notify the blockchain network to restore the S simulated malicious consensus nodes to normal consensus nodes, package the detection logs into blocks, and send the blocks to the blockchain network, so that the blockchain network can process the blocks on the blockchain through M normal consensus nodes.
[0187] Wherein, the above-mentioned data processing device 1 further includes:
[0188] A fourth processing module 20, for matching the test results for the blockchain network with the abnormal consensus scenario type;
[0189] The first test module 15 is used to determine that the blockchain network does not have the ability to detect malicious consensus nodes when the proportion of the number of simulated malicious consensus nodes indicated by the abnormal consensus scenario type is greater than the proportion threshold and the test result is a successful blockchain business execution result.
[0190] In the embodiment of the present application, based on the functional implementation of each unit in the data processing device 1, the automatic compilation process of the exception code is realized, thereby greatly improving the efficiency of the blockchain network exception test; at the same time, the data processing method provided by the present application can cover multiple types of abnormal consensus scenarios, improve the accuracy of the blockchain network exception test, and has a high degree of automation and strong scalability.
[0191] For further information, see Fig. 9 , Fig. 9 is another structural diagram of the data processing device provided in the embodiment of the present application. The above-mentioned data processing device may be a computer program (including program code) running in a computer device, for example, the data processing device is an application software; the device may be used to execute the corresponding steps in the method provided in the embodiment of the present application. Fig. 9 As shown, the data processing device 2 can be run on a terminal device, which can be the above-mentioned Figure 6 The data processing device 2 may include:
[0192] The second acquisition module 21 is used to receive the malicious node information and the executable file for the abnormal code sent by the test server;
[0193] The second processing module 22 is used to configure the malicious capability indicated by the executable file when the malicious node information includes the node information of the consensus node;
[0194] The second test module 23 is used to receive a test case for executing a blockchain business sent by a test server, and to execute the test case together with the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the test server from the M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
[0195] According to the above Figure 6 The corresponding embodiment, Figure 6 The implementation method described in steps S301 to S303 of the data processing method shown in FIG. Fig. 9 Each module of the device 2 shown in FIG. Figure 2 The implementation method described in step S301 of the data processing method shown in FIG. Figure 2 The implementation method described in step S302 can be performed by the second acquisition module 21 in the device 2 shown in the figure, the implementation method described in step S302 can be performed by the second processing module 22, and the implementation method described in step S303 can be performed by the second testing module 23. The implementation methods performed by the second acquisition module 21, the second processing module 22 and the second testing module 23 can refer to the above Figure 6 The implementation methods provided in each step of the corresponding embodiment will not be repeated here.
[0196] The executable file includes an exception identifier; the second processing module 22 includes:
[0197] The third processing unit 221 is used to determine that the consensus node belongs to a simulated malicious consensus node when the consensus node detects that the malicious node information includes the node information of the consensus node;
[0198] The fourth processing unit 222 is used to trigger the execution of the executable file based on the simulated malicious consensus node to which the consensus node belongs when the consensus node detects that the executable file includes an exception identifier, or when the consensus node receives an exception trigger request sent by the test server, to obtain the malicious capability indicated by the executable file.
[0199] The second test module 23 includes:
[0200] The fifth processing unit 231 is used to receive a test case for executing a blockchain service sent by the test server, and obtain a first transaction block associated with the test case, where the first transaction block includes block information associated with the test case;
[0201] The sixth processing unit 232 is used to trigger the modification of block information in the first transaction block based on the underlying logic code and executable file containing the abnormal code in the blockchain network to obtain a second transaction block;
[0202] The detection unit 233 is used to broadcast the second transaction block to the consensus network until a consensus result for the first transaction block is obtained, and determine a test result for the blockchain network based on the consensus result.
[0203] In the embodiment of the present application, the functions of each unit in the data processing device 2 realize the automated compilation process of the exception code, thereby greatly improving the efficiency of the blockchain network exception test; at the same time, the data processing method provided by the present application can cover multiple types of abnormal consensus scenarios, improve the accuracy of the blockchain network exception test, and has a high degree of automation and strong scalability.
[0204] For further information, see Fig.10 , Fig.10 Schematic diagram of a computer device provided in an embodiment of the present application. Fig.10 As shown, the computer device 1000 may include: at least one processor 1001, such as a CPU, at least one network interface 1004, a transceiver 1003, a memory 1005, and at least one communication bus 1002. The communication bus 1002 is used to realize the connection and communication between these components. The network interface 1004 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 1005 may be a high-speed RAM memory, or a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 1005 may optionally also be at least one storage device located away from the aforementioned processor 1001. As shown in FIG. Fig.10 As shown, the memory 1005 as a computer storage medium may include an operating system, a network communication module, a user interface module, and a device control application.
[0205] exist Fig.10 In the computer device 1000 shown, the network interface 1004 can provide a network communication function; and the transceiver 1003 and the processor 1001 can be used to call the device control application stored in the memory 1005 to achieve:
[0206] Obtain blockchain parameters for the consensus network in the blockchain network, where the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3;
[0207] Obtain the insertion location point in the underlying logic code in the blockchain network, obtain the abnormal code used to simulate the abnormal event of the blockchain, and inject the abnormal code into the insertion location point in the underlying logic code;
[0208] Determine S simulated malicious consensus nodes from the M consensus nodes, and obtain the node information of the S simulated malicious consensus nodes from the blockchain parameters as the malicious node information; S is a positive integer less than or equal to M;
[0209] Generate an executable file for the abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capabilities indicated by the executable file;
[0210] The test case used to execute the blockchain business is sent to the blockchain network, so that the blockchain network executes the test case through the underlying logic code containing the abnormal code and the consensus network containing S simulated malicious consensus nodes, and obtains the test result for the blockchain network.
[0211] It should be understood that the computer device 1000 described in the embodiment of the present application can execute the above Figure 2 , Figure 4 The description of the data processing method in the corresponding embodiment can also be performed as described above. Figure 8 The description of the data processing device 1 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.
[0212] For further information, see Fig.11 , Fig.11 is another structural diagram of a computer device provided in an embodiment of the present application. Fig.11 As shown, the computer device 2000 may be the above Figure 6 Corresponding to the terminal device in the embodiment, the above-mentioned computer device 2000 may include: a processor 2001, a network interface 2004 and a memory 2005. In addition, the above-mentioned computer device 2000 may also include: a transceiver 2003, and at least one communication bus 2002. Among them, the communication bus 2002 is used to realize the connection and communication between these components. Among them, the network interface 2004 may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface). The memory 2005 may be a high-speed RAM memory, or it may be a non-volatile memory (non-volatile memory), such as at least one disk storage. The memory 2005 may optionally also be at least one storage device located away from the aforementioned processor 2001. As Fig.11 As shown, the memory 2005 as a computer-readable storage medium may include an operating system, a network communication module, a user interface module, and a device control application program.
[0213] exist Fig.11 In the computer device 2000 shown, the network interface 2004 can provide a network communication function; and the transceiver 2003 and the processor 2001 can be used to call the device control application stored in the memory 2005 to achieve:
[0214] The consensus node receives the malicious node information and executable files for abnormal codes sent by the test server;
[0215] If the malicious node information contains the node information of the consensus node, the malicious capability indicated by the executable file is configured;
[0216] A test case for executing a blockchain business sent by a test server is received, and the test case is jointly executed by the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, so as to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the test server from M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
[0217] It should be understood that the computer device 2000 described in the embodiment of the present application can execute the above Figure 6 The description of the data processing method in the corresponding embodiment can also be performed as described above. Fig. 9 The description of the data processing device 2 in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated here either.
[0218] In addition, it should be pointed out here that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the data processing device mentioned above, and when the processor executes the computer program, it can execute the above-mentioned Figure 2 , Figure 6 The description of the data processing method in the corresponding embodiment will therefore not be repeated here. In addition, the description of the beneficial effects of the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, program instructions may be deployed on a computing device for execution, or on multiple computing devices located at one location, or on multiple computing devices distributed at multiple locations and interconnected by a communication network. Multiple computing devices distributed at multiple locations and interconnected by a communication network can constitute a blockchain system.
[0219] In addition, it should be noted that: the embodiment of the present application also provides a computer program product or a computer program, the computer program product, the computer program product may include a computer program, the computer program may be stored in a computer-readable storage medium. The processor of the computer device reads the computer program from the computer-readable storage medium, and the processor may execute the computer program, so that the computer device can execute the above Figure 2 , Figure 6 The description of the data processing method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here. For technical details not disclosed in the computer program product embodiment involved in this application, please refer to the description of the method embodiment of this application.
[0220] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing related hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and when the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the storage medium can be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM), etc.
[0221] The terms "second", "second", etc. in the description, claims, and drawings of the embodiments of the present application are used to distinguish different objects, rather than to describe a specific order. In addition, the terms "include" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, device, product, or equipment that includes a series of steps or units is not limited to the listed steps or modules, but may optionally include steps or modules that are not listed, or may optionally include other step units inherent to these processes, methods, devices, products, or equipment.
[0222] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0223] The method and related apparatus provided by the embodiment of the present application are described with reference to the method flow chart and / or structural diagram provided by the embodiment of the present application. Specifically, each process and / or box in the method flow chart and / or structural diagram, as well as the combination of the processes and / or boxes in the flow chart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1These computer program instructions can also be stored in a computer-readable memory that can guide a computer or other programmable data processing device to work in a specific way, so that the instructions stored in the computer-readable memory produce a product including an instruction device, which implements the functions specified in the process. Figure 1 Schematic diagram of one or more processes and / or structures Figure 1 These computer program instructions can also be loaded onto a computer or other programmable data processing device, so that a series of operation steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide for implementing the process in the process. Figure 1 A flow or multiple flows and / or structures illustrate the steps of the functions specified in one block or multiple blocks.
[0224] The above disclosure is only the preferred embodiment of the present application, which certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A data processing method, characterized in that: The method comprises: Obtaining blockchain parameters for a consensus network in a blockchain network, wherein the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3; Obtaining an insertion location point in the underlying logic code in the blockchain network, obtaining an abnormal code for simulating an abnormal blockchain event, and injecting the abnormal code into the insertion location point in the underlying logic code; Determine S simulated malicious consensus nodes from the M consensus nodes, and obtain node information of the S simulated malicious consensus nodes from the blockchain parameters as malicious node information; S is a positive integer less than or equal to M; Generate an executable file for the abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capability indicated by the executable file; The test case for executing the blockchain business is sent to the blockchain network, so that the blockchain network executes the test case through the underlying logic code including the abnormal code and the consensus network including S simulated malicious consensus nodes, and obtains the test result for the blockchain network.
2. The method according to claim 1, characterized in that The determining S simulated malicious consensus nodes from the M consensus nodes, and obtaining node information of the S simulated malicious consensus nodes from the blockchain parameters as malicious node information, includes: Obtaining an abnormal consensus scenario type, where the abnormal consensus scenario type is used to indicate the proportion of simulated malicious consensus nodes in the consensus network; Based on the M consensus nodes and the abnormal consensus scenario type, the number S is determined, S consensus nodes are selected from the M consensus nodes as simulated malicious consensus nodes, and node information of the S simulated malicious consensus nodes is obtained from the blockchain parameters as malicious node information.
3. The method according to claim 1, characterized in that The generating an executable file for the abnormal code and sending the executable file to the consensus network includes: Precompiling the abnormal code to obtain an intermediate file code, and binary compiling the intermediate file code to obtain an executable file; Based on the node addresses contained in the node information of the M consensus nodes, the executable file is sent to the M consensus nodes respectively.
4. The method according to claim 1, characterized in that: The method further comprises: Generate an exception trigger request for the consensus network, where the exception trigger request is used to trigger the S simulated malicious consensus nodes in the consensus network to execute the abnormal code based on the executable file; Based on the node information of the M consensus nodes, the exception trigger request is sent to each of the simulated malicious consensus nodes included in the M consensus nodes, so that each of the simulated malicious consensus nodes in the M consensus nodes runs the executable file based on the exception trigger request to obtain the malicious capability indicated by the executable file; the consensus node has the ability to identify itself as the simulated malicious consensus node through the malicious node information.
5. The method according to claim 1, characterized in that The method further comprises: Based on the test result for the blockchain network, a detection log is generated, wherein the detection log includes malicious node information of the S simulated malicious consensus nodes and the test result for the blockchain network; Clear the intermediate file code, notify the blockchain network to restore the S simulated malicious consensus nodes to normal consensus nodes, package the detection logs into blocks, and send the blocks to the blockchain network, so that the blockchain network can perform consensus on-chain processing on the blocks through M consensus nodes that are all normal.
6. The method according to claim 2, characterized in that The method further comprises: Matching the test results for the blockchain network with the abnormal consensus scenario type; If the proportion of the number of simulated malicious consensus nodes indicated by the abnormal consensus scenario type is greater than the proportion threshold, and the test result is a successful result of the blockchain business execution, it is determined that the blockchain network does not have the ability to detect malicious consensus nodes.
7. A data processing method, characterized in that: The method is performed by a consensus node in a blockchain network, wherein the consensus node belongs to a consensus network including M consensus nodes in the blockchain network; the method comprises: The consensus node receives the malicious node information and the executable file for the abnormal code sent by the test server; If the malicious node information includes the node information of the consensus node, then configuring the malicious capability indicated by the executable file; Receive a test case for executing a blockchain business sent by the test server, and execute the test case together through the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the test server from M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
8. The method according to claim 7, characterized in that The executable file includes an abnormal identification; if the malicious node information includes the node information of the consensus node, configuring the malicious capability indicated by the executable file includes: If the consensus node detects that the malicious node information includes the node information of the consensus node, it determines that it belongs to the simulated malicious consensus node; When the consensus node detects that the executable file includes the exception identifier, or when the consensus node receives an exception trigger request sent by the test server, the executable file is triggered to run based on the simulated malicious consensus node to which it belongs, and the malicious capability indicated by the executable file is obtained.
9. The method according to claim 7, characterized in that: The receiving of the test case for executing the blockchain business sent by the test server, executing the test case through the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, and obtaining the test result for the blockchain network, including: Receiving a test case for executing a blockchain service sent by the test server, and acquiring a first transaction block associated with the test case, wherein the first transaction block includes block information associated with the test case; Based on the underlying logic code containing the abnormal code in the blockchain network and the executable file, triggering modification of block information in the first transaction block to obtain a second transaction block; The second transaction block is broadcast to the consensus network until a consensus result for the first transaction block is obtained, and a test result for the blockchain network is determined based on the consensus result.
10. A data processing device, characterized in that: include: A first acquisition module is used to acquire blockchain parameters for a consensus network in a blockchain network, wherein the blockchain parameters include node information of M consensus nodes in the consensus network; M is a positive integer greater than 3; A first processing module is used to obtain a plug-in location point in the underlying logic code in the blockchain network, obtain an abnormal code for simulating an abnormal blockchain event, and inject the abnormal code into the plug-in location point in the underlying logic code; A malicious consensus node determination module, used to determine S simulated malicious consensus nodes from the M consensus nodes, and obtain node information of the S simulated malicious consensus nodes from the blockchain parameters as malicious node information; S is a positive integer less than or equal to M; A first generating module, used to generate an executable file for the abnormal code, and send the malicious node information and the executable file to the consensus network, so that the S simulated malicious consensus nodes in the consensus network have the malicious capability indicated by the executable file; The first test module is used to send a test case for executing a blockchain business to the blockchain network, so that the blockchain network executes the test case through an underlying logic code including the abnormal code and a consensus network including S simulated malicious consensus nodes to obtain a test result for the blockchain network.
11. A data processing device, characterized in that: The data processing device is applied to a consensus node in a blockchain network, and the consensus node belongs to a consensus network including M consensus nodes in the blockchain network; the data processing device includes: The second acquisition module is used to receive the malicious node information and the executable file for the abnormal code sent by the test server; A second processing module, configured to configure the malicious capability indicated by the executable file when the malicious node information includes the node information of the consensus node; The second test module is used to receive a test case for executing a blockchain business sent by the test server, and to execute the test case together through the underlying logic code containing the abnormal code in the blockchain network and the consensus network containing S simulated malicious consensus nodes, so as to obtain a test result for the blockchain network; the S simulated malicious consensus nodes include the consensus node, and the S simulated malicious consensus nodes are determined by the server from M consensus nodes, and S is a positive integer less than or equal to M; the underlying logic code containing the abnormal code is obtained by injecting the abnormal code into the underlying logic code.
12. A computer device, characterized in that: include: Processor, memory, and network interface; The processor is connected to the memory and the network interface, wherein the network interface is used to provide a data communication function, the memory is used to store program code, and the processor is used to call the program code to execute the method described in any one of claims 1-9.
13. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and the computer program is suitable for being loaded by a processor and executing the method according to any one of claims 1 to 9.
14. A computer program product, characterized in that The computer program product comprises computer instructions, which are stored in a computer-readable storage medium. The computer instructions are suitable for being read and executed by a processor, so that a computer device having the processor executes the method according to any one of claims 1 to 9.
