Font Size: a A A

Research On Smart Contract Anomaly Detection Method Based On Machine Learning

Posted on:2024-07-04Degree:MasterType:Thesis
Country:ChinaCandidate:Q C ShiFull Text:PDF
GTID:2568307130453124Subject:Computer technology
Abstract/Summary:PDF Full Text Request
smart contracts,as a program deployed on the blockchain,play a vital role in blockchain technology.However,frequent smart contract abnormalities have caused huge economic losses,so contract anomaly detection has become an urgent problem to be solved in the development of blockchain.The abnormalities of existing smart contracts are divided into two categories: 1.Contract transaction behaviors are abnormal.Some smart contracts have abnormal behavioral logic problems,resulting in blockchain transactions that cannot be executed correctly.2.Contract code vulnerabilities are abnormal.During the writing process of the contract code,there is a risk of loopholes that may cause blockchain transactions to be abnormal.Only by completing the double detection of smart contract transaction behavior and code loopholes can the legal implementation of blockchain transactions be ensured.Based on static analysis and dynamic detection methods,there are problems such as high false negative rate,low efficiency,and dependence on expert mode.Therefore,using machine learning methods to solve abnormal contract detection has gradually become a research hotspot.However,the existing machine learning-based detection methods lack the analysis of contract characteristics,and the centralized training mode ignores more unopened contracts,and also lacks attention to contract data flow and control flow.In order to solve the above two types of contract anomalies,and overcome the problems of weak interpretation,insufficient scalability,and low accuracy of existing solutions,this thesis proposes a series of smart contract anomaly detection methods based on machine learning.The specific research work is as follows:(1)Aiming at the lack of analysis of the importance of behavioral features in contract transaction behavior anomaly detection methods,an interpretable intelligent Ponzi scheme detection method based on Shapley values is proposed.Use text embedding to convert opcodes into word frequency matrices,use oversampling algorithm to balance data sets,and improve the generalization ability of the model.Calculate the characteristic Shapley value as the basis to measure how it promotes the model prediction,sort according to the characteristic Shapley value,and visualize its distribution and numerical value as the model explanation.Analyze the characteristics of the global model and a single sample,analyze the deception logic of the smart Ponzi scheme,and improve the interpretability of the prediction results of smart contract transaction behavior.(2)Aiming at the problem of low accuracy caused by insufficient scalability of the contract code vulnerability detection method,a smart contract code vulnerability detection method based on federated learning is proposed.Using the federated learning training architecture based on the attention mechanism,the central server can more accurately aggregate the optimal global model while protecting the client data privacy and security according to the client’s attention score and each local sequence model.Through experimental analysis and performance evaluation,it is shown that this scheme enhances the scalability of detecting code vulnerabilities,and improves the accuracy of vulnerability detection compared with the traditional centralized training mode.(3)Based on the transaction behavior and code vulnerability detection method,the smart contract anomaly detection system is designed and implemented,including smart contract data processing,model training,abnormal contract detection,model interpretation and other functional modules,and the contract information,training process and detection results are displayed through the front-end interface.
Keywords/Search Tags:Smart contracts, anomaly detection, interpretability, federated learning, blockchain
PDF Full Text Request
Related items