Smart contracts are computer programs running on blockchains to implement Decentralized Applications.The absence of contract specifications hinders routine tasks, such as contract understanding and testing. Inthis work, we propose a specification mining approach to infer contract specifications from past transactionhistories. Our approach derives high-level behavioral automata of function invocations, accompanied byprogram invariants statistically inferred from the transaction histories. We implemented our approach as toolSmConand evaluated it on eleven well-studied Azure benchmark smart contracts and six popular real-worldDApp smart contracts. The experiments show thatSmConmines reasonably accurate specifications that canbe used to facilitate DApp understanding and development in terms of document maintenance and test suite improvement.
翻译:智能合约是运行在区块链上的计算机程序,用于实现去中心化应用。合约规约的缺失阻碍了合约理解与测试等常规任务的开展。本文提出一种规约挖掘方法,通过历史交易记录推断合约规约。该方法可推导出函数调用的高层行为自动机,并辅以从交易记录中统计推断的程序不变量。我们将该方法实现为工具SmCon,并在经过充分研究的11个Azure基准智能合约和6个主流真实DApp智能合约上进行了评估。实验表明,SmCon挖掘的规约具有较高准确性,可在文档维护和测试套件改进方面促进DApp的理解与开发。