论文标题

用结构代码嵌入检查智能合约

Checking Smart Contracts with Structural Code Embedding

论文作者

Gao, Zhipeng, Jiang, Lingxiao, Xia, Xin, Lo, David, Grundy, John

论文摘要

智能合约越来越多地与区块链一起使用,以使财务和业务交易自动化。但是,许多合同中已经确定了许多错误和漏洞,这引起了人们对智能合约安全的严重关注,更不用说建立智能合约的区块链系统可能是错误的。因此,非常需要更好地维护智能合同代码并确保其高可靠性。在本文中,我们提出了一种自动化方法来学习坚固性智能合约的特征,这对于克隆检测,错误检测和智能合约验证的合同验证非常有用。我们的新方法基于单词嵌入和矢量空间比较。我们将智能合约代码分析到具有代码结构信息的单词流中,将代码元素(例如语句,函数)转换为数值向量,这些向量应编码代码语法和语义,并比较编码代码和已知错误的向量之间的相似性,以识别潜在的问题。我们已经在原型中实现了该方法,名为SmartEmbed。结果表明,我们的工具可以有效地确定许多重复的固体代码实例,而克隆比率约为90 \%。也可以准确检测到诸如III类型的代码克隆,甚至是IV类型语义克隆。我们的工具可以根据我们的错误数据库有效,准确地识别1000多个与克隆相关的错误。我们的工具还可以帮助有效地验证任何给定的智能合约,以防止一组已知的错误,这可以帮助提高用户对合同可靠性的信心。 可以通过以下网址访问匿名复制软件包:https://drive.google.com/file/d/1kault3y2iihpkulvx4fstda-dvayl4za/view?usp = Sharing?usp = Sharing,并通过从以太坊收集到的22,000多个智能合约进行了评估。

Smart contracts have been increasingly used together with blockchains to automate financial and business transactions. However, many bugs and vulnerabilities have been identified in many contracts which raises serious concerns about smart contract security, not to mention that the blockchain systems on which the smart contracts are built can be buggy. Thus, there is a significant need to better maintain smart contract code and ensure its high reliability. In this paper, we propose an automated approach to learn characteristics of smart contracts in Solidity, which is useful for clone detection, bug detection and contract validation on smart contracts. Our new approach is based on word embeddings and vector space comparison. We parse smart contract code into word streams with code structural information, convert code elements (e.g., statements, functions) into numerical vectors that are supposed to encode the code syntax and semantics, and compare the similarities among the vectors encoding code and known bugs, to identify potential issues. We have implemented the approach in a prototype, named SmartEmbed. Results show that our tool can effectively identify many repetitive instances of Solidity code, where the clone ratio is around 90\%. Code clones such as type-III or even type-IV semantic clones can also be detected accurately. Our tool can identify more than 1000 clone related bugs based on our bug databases efficiently and accurately. Our tool can also help to efficiently validate any given smart contract against a known set of bugs, which can help to improve the users' confidence in the reliability of the contract. The anonymous replication packages can be accessed at: https://drive.google.com/file/d/1kauLT3y2IiHPkUlVx4FSTda-dVAyL4za/view?usp=sharing, and evaluated it with more than 22,000 smart contracts collected from the Ethereum blockchain.

扫码加入交流群

加入微信交流群

微信交流群二维码

扫码加入学术交流群,获取更多资源