A method, device, equipment and storage medium for detecting malicious nodes
By comparing the actual transaction order of block transactions in the blockchain and the order of gasoline price sorting in combination with the calculation of the profitable quantity, malicious nodes were successfully detected, solving the problems of fairness and normal operation of blockchain transactions.
Patent Information
- Application Number
- CN202210264275.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-17
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2042-03-17
AI Technical Summary
The existing technology cannot detect malicious nodes in the blockchain, resulting in the damage to transaction fairness and affecting the normal operation of the blockchain.
By obtaining the actual transaction order and gasoline price of all transactions in a block in the blockchain, comparing the two sort orders. If different, determine that the block is the target block and calculate its profitable amount. If the profitable amount is a positive value, it is determined that the node is a malicious node.
Effectively detect malicious nodes, maintain the fairness and normal operation of blockchain transactions, and improve the accuracy of detection results.
Smart Images

Figure CN114612102B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of blockchain technology, and specifically to a malicious node detection method, device, equipment and storage medium. Background Art
[0002] In the transaction process of blockchain, the sender of the transaction first publishes the transaction on the blockchain and then broadcasts it. After receiving the transaction, the nodes in the blockchain sort the transactions according to the gas price given by the sender to the node in each transaction, thereby determining the transaction order of all transactions and executing these transactions in this transaction order. This process is called node packaging of transactions, and then the node uploads the packaged transactions to the block. However, some nodes collude with the sender and will privately change the original transaction order of the transaction to increase the sender's balance and obtain greater benefits.
[0003] However, existing technologies cannot detect which nodes are malicious nodes. The existence of malicious nodes violates the fairness of transactions in the blockchain and is not conducive to the normal operation of the blockchain. Summary of the invention
[0004] In view of this, the present application provides a malicious node detection method, apparatus, device and storage medium to solve the defect that the prior art cannot detect which node is a malicious node, which is not conducive to the fairness of transactions in the blockchain and the normal operation of the blockchain.
[0005] To achieve the above objectives, the proposed solution is as follows:
[0006] In a first aspect, a malicious node detection method includes:
[0007] Obtain the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction, wherein the first transaction order is the order in which all transactions are actually completed;
[0008] Sort all transactions in the block according to the gas price to obtain a second transaction order;
[0009] If the first transaction order is different from the second transaction order, determining the block as the target block;
[0010] Calculating the profitable amount of the target block;
[0011] If the profitable amount is a positive value, it is determined that the node corresponding to the target block is a malicious node.
[0012] Preferably, the calculating the profitable amount of the target block includes:
[0013] Obtain the first final balance and the second final balance of each sender in the target block, and obtain the first final balance and the second final balance of each receiver; wherein the first final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the first transaction sequence, the second final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the second transaction sequence, the first final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the first transaction sequence, and the second final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the second transaction sequence;
[0014] The profitable amount of the target block is obtained according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver.
[0015] Preferably, obtaining the profitable amount of the target block according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver includes:
[0016] Subtract the second final balance from the first final balance of each sender to obtain a sender balance difference;
[0017] Subtract the second final balance from the first final balance of each recipient to obtain a recipient balance difference;
[0018] The sender's balance difference and the receiver's balance difference are added together to obtain the profitable amount of the target block.
[0019] Preferably, the method further comprises:
[0020] Obtain the first transaction balance and the second transaction balance of the sender in each transaction in the target block corresponding to the malicious node; wherein the first transaction balance is the balance of the sender in each transaction after the first transaction sequence is completed, and the second transaction balance is the balance of the sender in each transaction after the second transaction sequence is completed;
[0021] Obtaining a transaction balance difference of the sender in each transaction according to the first transaction balance and the second transaction balance;
[0022] Determine whether the address of the recipient in the transaction where the transaction balance difference is a positive value is a contract address, wherein the contract address contains a smart contract;
[0023] If so, the smart contract is the reason why the malicious node commits evil.
[0024] Preferably, obtaining the transaction balance difference of the sender in each transaction according to the first transaction balance and the second transaction balance includes:
[0025] The second transaction balance is subtracted from the first transaction balance to obtain the transaction balance difference of the sender in each transaction.
[0026] In a second aspect, a malicious node detection device includes:
[0027] An acquisition module, used to acquire the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction, wherein the first transaction order is the order in which all transactions are actually completed;
[0028] A sorting module, used for sorting all transactions in the block according to the size of the gas price to obtain a second transaction order;
[0029] A target block determination module, configured to determine a block whose first transaction order is different from a second transaction order as a target block;
[0030] A profit calculation module, used to calculate the profit amount of the target block;
[0031] The malicious node determination module is used to determine the node corresponding to the target block with a positive profit amount as a malicious node.
[0032] Preferably, the profit calculation module includes:
[0033] The final balance acquisition module is used to acquire the first final balance and the second final balance of each sender in the target block, and acquire the first final balance and the second final balance of each receiver; wherein the first final balance of the sender is the final balance of the sender after the first transaction sequence is completed, the second final balance of the sender is the final balance of the sender after the second transaction sequence is completed, the first final balance of the receiver is the final balance of the receiver after the first transaction sequence is completed, and the second final balance of the receiver is the final balance of the receiver after the second transaction sequence is completed;
[0034] The profitable amount obtaining module obtains the profitable amount of the target block according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver.
[0035] Preferably, the module for obtaining the profitable quantity includes:
[0036] a sender balance difference calculation module, configured to obtain a sender balance difference by subtracting the second final balance from the first final balance of each sender;
[0037] A sender balance difference calculation module, which subtracts the second final balance from the first final balance of each receiver to obtain a receiver balance difference;
[0038] The balance difference adding module is used to add the sender's balance difference and the receiver's balance difference to obtain the profitable amount of the target block.
[0039] In a third aspect, a malicious node detection device includes a memory and a processor;
[0040] The memory is used to store programs;
[0041] The processor is used to execute the program to implement the various steps of the malicious node detection method as described in the first aspect above.
[0042] In a fourth aspect, a storage medium stores a computer program thereon, and when the computer program is executed by a processor, the steps of the malicious node detection method as described in the first aspect are implemented.
[0043] It can be seen from the above technical scheme that the present application obtains the order of actual transactions of all transactions contained in a block in the blockchain as the first order, obtains the gas price of each transaction, sorts all transactions in this block according to the gas price to obtain the second order, and then compares the first order and the second order. If the two are not the same, the block is determined as the target block, and then the profitable amount of the target block is calculated to be a positive value. If it is a positive value, the node corresponding to the target block is determined to be a malicious node. The scheme uses the gas price to sort all transactions to obtain the second transaction order, and then continues to compare it with the actual transaction order, that is, the first transaction order. If the two are not the same, it can be said that there is a problem with the block, and continue to judge whether the profitable amount of the block is a positive value. If it is a positive value, it means that the block has profited from it, so it can be determined that the node corresponding to the block is a malicious node, thereby maintaining the fairness of transactions in the blockchain and the normal operation of the blockchain. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 An optional flow chart of a malicious node detection method provided in an embodiment of the present application;
[0045] Figure 2 A schematic diagram of a malicious node detection device provided in an embodiment of the present application;
[0046] Figure 3 A schematic diagram of the structure of a malicious node detection device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0047] 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.
[0048] The blockchain is a data structure in the form of a linked list composed of the hash values of the block header. Each block consists of transactions generated within a period of time, which are packaged by computer nodes that have obtained the right to record accounts and independently verified by each computer node. A transaction is the smallest unit of state transition on the blockchain. It is initiated by the signature of the sender to transfer specific digital assets or perform operations that affect the state of the blockchain, such as smart contract calls. In essence, the blockchain is a shared database, and the data or information stored in it has the characteristics of "unforgeable", "full traceability", "traceability", "openness and transparency", and "collective maintenance". The blockchain contains a variety of transactions. During the transaction execution process, the sender of the transaction first publishes the transaction on the blockchain, and then broadcasts it. The node closer to the sender's address will receive the transaction. The node will sort all the transactions received within a period of time according to the gas price given to the node by the sender in each transaction, thereby determining the transaction order of all transactions and allowing these transactions to be executed in this transaction order. This process is called node packaging of transactions, and then the node uploads the packaged transactions to the block to realize blockchain data sharing.
[0049] The application scenarios of the malicious node detection method provided in the embodiment of the present application include blockchain and client. The client can be redeer geth, referred to as ROG. ROG is used to obtain shared data in the blockchain. Among them, ROG includes a data processing module ROG-OUTSIDE for further processing the data obtained by ROG.
[0050] Below, we first introduce the defects of the existing technology through a specific example. An example scenario is as follows: sender A and sender B initiate a transaction to purchase the same commodity at the same time. Senders A and B will purchase the commodity from the receiver according to the specific amount of the commodity. At the same time, the two senders will decide the price of the "tip" they give to the node in the blockchain. For a transaction, the actual benefit (transaction fee) obtained by the node is the product of the price of the "tip" determined by the sender in the transaction and the amount of gasoline consumed in the actual execution of the transaction. In this application, the "tip" is called the gas price, that is, transaction fee = gas price × gasoline consumption. In addition, some transactions involve code. The more complex the code, the more gasoline is consumed. For example, the gas price given by sender A to the node is 10, and the gas price given by sender B to the node is 20. Generally speaking, the node will sort the two transactions from high to low according to the gas price, that is, the transaction order is B first and then A, and let them execute in this transaction order, and then the node will upload the packaged transaction to the block, so that the node gets the highest transaction fee. However, when the node colludes with sender A and needs to make sender A gain greater benefits, the node will also profit from it. The node will privately change the transaction order of the two transactions, that is, change it to A first and then B. In this case, the node will be identified as a malicious node. This behavior of the malicious node violates the fairness of transactions in the blockchain and is not conducive to the normal operation of the blockchain.
[0051] In order to solve the defects of the above-mentioned prior art, the embodiment of the present application provides a malicious node detection solution. Figure 1 The malicious node detection method of this application is described as follows: Figure 1 As shown, the method includes:
[0052] S1: Get the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction.
[0053] Among them, the first transaction order is the order in which all transactions determined by the nodes in the block are actually completed. A block in the blockchain contains a variety of transactions, such as purchasing goods, exchanging token a for token b, etc. During the execution of these transactions, the sender will pay a "tip" to the node.
[0054] S2: Sort all transactions in the block according to the size of the gas price to obtain the second transaction order.
[0055] Specifically, the transactions are reordered from high to low according to the gas price that the sender of each transaction in the block gives to the node. This order is called the second transaction order, and the second transaction order is the order that should be executed originally. The second transaction order may or may not be the same as the first transaction order.
[0056] S3: If the first transaction sequence is different from the second transaction sequence, the block is determined to be the target block.
[0057] In the above steps, the first transaction sequence and the second transaction sequence are obtained. In this step, it is determined whether the two are the same. If the first transaction sequence is different from the second transaction sequence, it can be explained that the node privately changed the second transaction sequence that should have occurred into the first transaction sequence and executed it. Therefore, it can be roughly determined that there is a problem with the block, and the node corresponding to the block is likely to have a problem, so the block is determined as the target block.
[0058] S4: Calculate the profitable amount of the target block.
[0059] Specifically, after determining that the node corresponding to the target block is likely to have a problem, the amount of profit that can be made from the target block is calculated, thereby further accurately judging the goodness or evilness of the node.
[0060] S5: If the amount of profit is a positive value, it is determined that the node corresponding to the target block is a malicious node.
[0061] In step S4, the profitable amount of the target block is obtained. If the profitable amount is a positive value, it means that the node corresponding to the target block has made the sender or receiver in the block gain benefits, so it can be determined that the node is a malicious node.
[0062] The malicious node detection method provided in the embodiment of the present application obtains the order of actual transactions of all transactions contained in a block in the blockchain as the first order, obtains the gas price of each transaction, sorts all transactions in this block according to the gas price to obtain the second order, and then compares the first order and the second order. If the two are not the same, the block is determined as the target block, and then the profitable amount of the target block is calculated to be a positive value. If it is a positive value, the node corresponding to the target block is determined to be a malicious node. The scheme uses the gas price to sort all transactions to obtain the second transaction order, and then continues to compare it with the actual transaction order, that is, the first transaction order. If the two are not the same, it can be said that there is a problem with the block, and it is continued to determine whether the profitable amount of the block is a positive value. If it is a positive value, it means that the block has profited from it, so it can be determined that the node corresponding to the block is a malicious node, thereby maintaining the fairness of transactions in the blockchain and the normal operation of the blockchain.
[0063] In addition, some existing technologies deploy nodes in the blockchain to collect transactions in the blockchain in real time. In this process, some transactions may be missed due to network delays and other reasons, and all transactions in the corresponding block may not be obtained, resulting in inaccurate detection results. This solution does not need to deploy nodes to collect data in the blockchain, but can directly target the blocks in the blockchain to obtain the existing data in the blocks, which will not cause some transactions to be missed and improve the accuracy of the detection results.
[0064] Optionally, after step S2, the solution may further include the following steps:
[0065] S6: If the first transaction sequence is the same as the second transaction sequence, return to execute step S1.
[0066] Specifically, after determining whether the first transaction sequence and the second transaction sequence are the same in step S3, if it is determined that the first transaction sequence and the second transaction sequence are the same, the transaction data of other blocks in the blockchain are continuously obtained, that is, the execution of step S1 is returned.
[0067] Optionally, after step S4, the solution may further include the following steps:
[0068] S7: If the profitable amount of the target block is not a positive value, return to step S1.
[0069] Specifically, if the profitable amount of the target block is not a positive value, it means that the target block has not made any profit from it, and there is actually no problem. Then, the transaction data of other blocks in the blockchain will continue to be obtained, that is, returning to execute step S1.
[0070] Furthermore, an optional method for calculating the profitable amount of the target block in step S4 is as follows:
[0071] S41: Obtain the first final balance and the second final balance of each sender in the target block, and obtain the first final balance and the second final balance of each receiver.
[0072] The first final balance of the sender is the final balance of the sender after the first transaction sequence is completed, the second final balance of the sender is the final balance of the sender after the second transaction sequence is completed, the first final balance of the receiver is the final balance of the receiver after the first transaction sequence is completed, and the second final balance of the receiver is the final balance of the receiver after the second transaction sequence is completed;
[0073] S42: Obtain the profitable amount of the target block according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver.
[0074] In this scheme, for a transaction in a block, taking the sender as an example, the sender in the transaction may have conducted other transactions in the block. Therefore, when the same sender has many transactions, when all transactions in the block are completed regardless of which transaction is completed, the final balance displayed will depend on the balance of the sender after completing the last transaction in the block, and it will be used as the first final balance.
[0075] In addition, in a transaction, the sender may be the receiver in other transactions in the block. Therefore, when calculating the profitable amount of the target block, it is necessary to consider the final balance of each sender after the transaction is completed in the first transaction order and the second transaction order, and the final balance of each receiver after the transaction is completed in the first transaction order and the second transaction order.
[0076] Further, for step S42, an optional method for obtaining the profitable amount of the target block according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver is as follows:
[0077] S421: Subtract the second final balance from the first final balance of each sender to obtain the sender balance difference.
[0078] In the above step S41, while obtaining the first final balance and the second final balance of the sender and the first final balance and the second final balance of the receiver in each transaction in the block corresponding to the malicious node, the following are also obtained:
[0079] The transaction hash of each transaction represents the unique number of the transaction, such as the courier number. Each courier has its own number, so each transaction hash represents a transaction.
[0080] The addresses of the sender and receiver of each transaction, that is, who the sender and receiver are. In this scheme, the sender is represented by the sender's specific address. For example, the sender address of one of the transactions is 0x100, and the transaction hash of the transaction is 1.
[0081] Specifically, for ease of understanding, we will select a block in the blockchain and analyze the sender balance difference in the block, and list examples for illustration. Please refer to Table 1 and Table 2:
[0082] Table 1
[0083]
[0084] Table 1 shows the second final balance of the sender of four transactions with transaction hashes of 1, 2, 3, and 4 after the second transaction order is completed. As shown in Table 1, the second transaction order is 4321, and the sender 0x100 has made a total of three transactions in this block, namely, transactions with transaction hashes of 4, 2, and 1. Therefore, the second final balance of the sender 0x100 is m1.
[0085] Please refer to Table 2, which shows the first final balance of the sender of four transactions with transaction hashes 1, 2, 3, and 4 after the first transaction order is completed.
[0086] Table 2
[0087]
[0088] It can be seen from Table 2 that the transaction sequence that should have been 4321 was changed to 3214. After these four transactions were completed in the first transaction sequence, the first final balance of the sender 0x100 was n4.
[0089] In summary, the first final balance n4 and the second final balance m1 of the sender 0x100 are obtained, and the sender balance difference of the sender 0x100 is n4-m1.
[0090] S422: Subtract the second final balance from the first final balance of each recipient to obtain the recipient balance difference.
[0091] S423: Add the balance difference of the sender and the balance difference of the receiver to obtain the profitable amount of the target block.
[0092] In the embodiment of the present application, the profitable amount values of the top 20 blocks in terms of the profitable amount in a blockchain within a period of time are counted, and the acquired data can be converted into a comma separated value file format (csv file), as shown in the following table:
[0093] Table 3
[0094]
[0095]
[0096] The unit of the profitable amount is wei. As can be seen from the table, the profitable amounts of these blocks are all positive values, and it can be determined that these blocks are target blocks.
[0097] In one embodiment of the present application, the scheme can also find out the reason why the malicious node does evil. The reason for the evil is the benefit obtained by the malicious node through which transaction, specifically the smart contract of the transaction. The sender and receiver of the transaction can also be found. The receiver can be called the initiator of the transaction. The specific method is as follows:
[0098] 1) Obtain the first transaction balance and the second transaction balance of the sender in each transaction in the target block corresponding to the malicious node; wherein the first transaction balance is the balance of the sender in each transaction after the first transaction order is completed, and the second transaction balance is the balance of the sender in each transaction after the second transaction order is completed.
[0099] 2) Obtaining the transaction balance difference of the sender in each transaction according to the first transaction balance and the second transaction balance.
[0100] Optionally, the transaction balance difference of the sender in each transaction is obtained based on the first transaction balance and the second transaction balance. The transaction balance difference of the sender in each transaction can be obtained by subtracting the second transaction balance from the first transaction balance.
[0101] For ease of understanding, we will select a block in the blockchain and analyze the transaction balance difference of the transactions in the block, and list examples, such as Table 4 and Table 5:
[0102] Table 4
[0103]
[0104]
[0105] Please refer to Table 4, which shows the first transaction balance of the sender after the transactions in the block are executed according to the second transaction order. After the transaction is completed according to the second transaction order, the second transaction balance of the sender 0x500 is k5, the second transaction balance of the sender 0x600 is k6, the second transaction balance of the sender 0x700 is n3, and the second transaction balance of the sender 0x800 is k8.
[0106] Next, please refer to Table 5, which shows the sender's first transaction balance after the transactions in the block are executed in the first transaction order.
[0107] Table 5
[0108]
[0109] It can be seen from Table 5 that the transaction order of these four transactions has changed, from 5678, the second transaction order, to 7586, the first transaction order.
[0110] Therefore, the transaction balance difference of sender 0x500 is h5-k5, the transaction balance difference of sender 0x600 is h6-k6, the transaction balance difference of sender 0x700 is h7-k7, and the transaction balance difference of sender 0x800 is h8-k8.
[0111] 3) Determine whether the recipient's address is a contract address in a transaction where the transaction balance difference is positive, where the contract address contains a smart contract.
[0112] 4) If the recipient’s address is a contract address, the smart contract contained in the contract address is the reason for the malicious node to commit the crime.
[0113] The following lists the method provided in the embodiment of the present application to detect whether the node corresponding to the block numbered 9748116 in the blockchain is a malicious node. As shown in Table 6:
[0114] Table 6
[0115]
[0116]
[0117] The above table shows that the transaction hashes in the block are 0xe8e45431b93215566BA923a7E611B7342Ea954DF, 0x60C615E4780f9E7a3970ECD59564b0Fafc5e8523, and 0xce5702E94aD38C061e44a4a049Cc29261F992846. As shown in Table 6, the transaction balance difference between the transactions with sequence numbers 1 and 2 is positive. Therefore, it is necessary to determine whether the recipient address in these two transactions is the contract address, thereby determining the malicious cause of the node corresponding to the block number 9748116.
[0118] Therefore, the data of transactions with sequence numbers 1 and 2 are obtained as follows:
[0119] Table 7
[0120]
[0121] It can be seen from Table 7 that the smart contracts involved in these two transactions are both Uniswap. Uniswap can be a piece of code, that is, Uniswap is the malicious reason for the node corresponding to the block. Specifically, these two transactions are token exchange transactions. The node obtains the first transaction order by reordering the transactions, which changes the exchange rate between different tokens on Uniswap, so that a user can exchange the same token A for more token B, thereby making a profit.
[0122] The following is a supplementary explanation of how senders, receivers, or nodes make profits on Uniswap:
[0123] Define the price model as x*y=constant. For example, if x=100, y=100, then constant=10000.
[0124] If user A buys y with 10 x, then x=110, y=90.9, and user A gets 9.1y. (x*y is still equal to the constant 10000)
[0125] User B uses 10 x to buy y. At this time, x=120, y=83.33, and user B gets 7.57y. (x*y is still equal to the constant 10000)
[0126] Therefore, the order of transactions between users A and B will have a great impact on the number of tokens they exchange.
[0127] The malicious node detection device provided in an embodiment of the present application is described below. The malicious node detection device described below and the malicious node detection method described above can refer to each other.
[0128] Combination Figure 2 ,The malicious node detection device is introduced, such as Figure 2 As shown, the detection device may include:
[0129] The acquisition module 10 is used to obtain the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction, wherein the first transaction order is the order in which all transactions are actually completed.
[0130] The sorting module 20 is used to sort all transactions in the block according to the size of the gas price to obtain a second transaction order.
[0131] The target block determination module 30 is used to determine a block whose first transaction sequence is different from the second transaction sequence as a target block.
[0132] The profit calculation module 40 is used to calculate the profit amount of the target block.
[0133] The malicious node determination module 50 is used to determine the node corresponding to the target block with a positive profit amount as a malicious node.
[0134] In an optional embodiment, the profit calculation module 40 may include:
[0135] The final balance acquisition module is used to obtain the first final balance and the second final balance of each sender in the target block, and obtain the first final balance and the second final balance of each receiver; wherein the first final balance of the sender is the final balance of the sender after the first transaction sequence is completed, the second final balance of the sender is the final balance of the sender after the second transaction sequence is completed, the first final balance of the receiver is the final balance of the receiver after the first transaction sequence is completed, and the second final balance of the receiver is the final balance of the receiver after the second transaction sequence is completed.
[0136] The module for obtaining the profitable amount obtains the profitable amount of the target block according to the first final balance and the second final balance of each sender and the first final balance and the second final balance of each receiver.
[0137] In another optional embodiment, the profitable quantity obtaining module may include:
[0138] The sender balance difference calculation module is used to subtract the second final balance from the first final balance of each sender to obtain the sender balance difference.
[0139] The sender balance difference calculation module subtracts the second final balance from the first final balance of each receiver to obtain the receiver balance difference.
[0140] The balance difference addition module is used to add the sender's balance difference and the receiver's balance difference to obtain the profitable amount of the target block.
[0141] Furthermore, the embodiment of the present application provides a malicious node detection device. Optionally, Figure 3 The hardware structure diagram of the malicious node detection device is shown in FIG. Figure 3 The hardware structure of the malicious node detection device may include: at least one processor 01 , at least one communication interface 02 , at least one memory 03 and at least one communication bus 04 .
[0142] In the embodiment of the present application, the number of the processor 01 , the communication interface 02 , the memory 03 , and the communication bus 04 is at least one, and the processor 01 , the communication interface 02 , and the memory 03 communicate with each other through the communication bus 04 .
[0143] The processor 01 may be a central processing unit (CPU), or an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of the present invention.
[0144] The memory 03 may include a high-speed RAM memory, and may also include a non-volatile memory (non-volatile memory), etc., such as at least one disk memory.
[0145] The memory stores a program, and the processor can call the program stored in the memory, and the program is used to execute the malicious node detection method described in the method embodiment.
[0146] Optionally, the detailed functions and extended functions of the program may refer to the description of the malicious node detection method in the method embodiment.
[0147] An embodiment of the present application also provides a storage medium, which can store a program suitable for execution by a processor, and the program is used to execute the malicious node detection method described in the method embodiment.
[0148] Specifically, the storage medium may be a computer-readable storage medium, and the computer-readable storage medium may be an electronic memory such as a flash memory, an EEPROM (Electrically Erasable Programmable Read-Only Memory), an EPROM, a hard disk or a ROM.
[0149] Optionally, the detailed functions and extended functions of the program may refer to the description of the malicious node detection method in the method embodiment.
[0150] In addition, the functional modules in the various embodiments of the present disclosure can be integrated together to form an independent part, or each module can exist separately, or two or more modules can be integrated to form an independent part. If the function is implemented in the form of a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present disclosure is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes a number of instructions for a computer device (which can be a personal computer, a live broadcast device, or a network device, etc.) to perform all or part of the steps of the methods of the various embodiments of the present disclosure.
[0151] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0152] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0153] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A malicious node detection method, characterized in that: include: Obtain the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction, wherein the first transaction order is the order in which all transactions are actually completed; Sort all transactions in the block according to the gas price to obtain a second transaction order; If the first transaction order is different from the second transaction order, determining the block as the target block; Calculating the profitable amount of the target block; including: obtaining the first final balance and the second final balance of each sender in the target block, and calculating the first final balance and the second final balance of each receiver; wherein the first final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the first transaction sequence, the second final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the second transaction sequence, the first final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the first transaction sequence, and the second final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the second transaction sequence; subtracting the second final balance from the first final balance of each sender to obtain the sender balance difference; subtracting the second final balance from the first final balance of each receiver to obtain the receiver balance difference; adding the sender balance difference and the receiver balance difference to obtain the profitable amount of the target block; If the profitable amount is a positive value, it is determined that the node corresponding to the target block is a malicious node.
2. The method according to claim 1, characterized in that Also includes: Obtain the first transaction balance and the second transaction balance of the sender in each transaction in the target block corresponding to the malicious node; wherein the first transaction balance is the balance of the sender in each transaction after the first transaction sequence is completed, and the second transaction balance is the balance of the sender in each transaction after the second transaction sequence is completed; Obtaining a transaction balance difference of the sender in each transaction according to the first transaction balance and the second transaction balance; Determine whether the address of the recipient in the transaction where the transaction balance difference is a positive value is a contract address, wherein the contract address contains a smart contract; If so, the smart contract is the reason why the malicious node commits evil.
3. The method according to claim 2, characterized in that The obtaining the transaction balance difference of the sender in each transaction according to the first transaction balance and the second transaction balance includes: The second transaction balance is subtracted from the first transaction balance to obtain the transaction balance difference of the sender in each transaction.
4. A malicious node detection device, characterized in that: include: An acquisition module, used to acquire the first transaction order of all transactions contained in a block in the blockchain and the gas price of each transaction, wherein the first transaction order is the order in which all transactions are actually completed; A sorting module, used for sorting all transactions in the block according to the size of the gas price to obtain a second transaction order; A target block determination module, configured to determine a block whose first transaction order is different from a second transaction order as a target block; A profit calculation module, used to calculate the profit amount of the target block; A malicious node determination module, used for determining the node corresponding to the target block with a positive profit amount as a malicious node; Wherein, the profit calculation module includes: The final balance acquisition module is used to acquire the first final balance and the second final balance of each sender in the target block, and acquire the first final balance and the second final balance of each receiver; wherein the first final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the first transaction sequence, the second final balance of the sender is the final balance of the sender after the transaction is completed in accordance with the second transaction sequence, the first final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the first transaction sequence, and the second final balance of the receiver is the final balance of the receiver after the transaction is completed in accordance with the second transaction sequence; a sender balance difference calculation module, configured to obtain a sender balance difference by subtracting the second final balance from the first final balance of each sender; A sender balance difference calculation module, which subtracts the second final balance from the first final balance of each receiver to obtain a receiver balance difference; The balance difference adding module is used to add the sender's balance difference and the receiver's balance difference to obtain the profitable amount of the target block.
5. A malicious node detection device, characterized in that: including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the malicious node detection method as claimed in any one of claims 1 to 3.
6. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, each step of the malicious node detection method according to any one of claims 1 to 3 is implemented.
Citation Information
Patent Citations
Transaction verification method and related equipment
CN110599177A
Transaction sequence dependence vulnerability detection method and system, electronic device and storage medium
CN110766402A