一句话:提出 DocCon,基于预计算事实检测 Solidity 智能合约库 API 文档与代码的不一致。
智能合约开发者常依赖 OpenZeppelin 等 Solidity 库,其 API 文档是学习正确用法的重要来源,但文档维护困难,文档与代码不一致会误导开发者。论文提出 DocCon,针对 Solidity 智能合约库检测文档与代码之间的不一致。该方法采用基于事实的方式,从 API 代码和文档中预计算事实并存入数据库,再支持按不同严重程度查询不一致,如参数不匹配、缺失需求、过时描述等。作者在流行智能合约库上评估,DocCon 达到较好精度并适用于不同库;报告的 40 个错误中,29 个被库开发者确认,22 个已修复,表明其能发现高优先级文档问题。
Smart contracts are gaining popularity as a means to support transparent, traceable, and self-executing decentralized applications, which enable the exchange of value in a trustless environment. Developers of smart contracts rely on various libraries, such as OpenZeppelin for Solidity contracts, to improve application quality and reduce development costs. The API documentations of these libraries are important sources of information for developers who are unfamiliar with the APIs. Yet, maintaining high-quality documentations is non-trivial, and errors in documentations may place barriers for developers to learn the correct usages of APIs. In this paper, we propose a technique, DocCon, to detect inconsistencies between documentations and the corresponding code for Solidity smart contract libraries. Our fact-based approach allows inconsistencies of different severity levels to be queried, from a database containing precomputed facts about the API code and documentations. DocCon successfully detected high-priority API documentation errors in popular smart contract libraries, including mismatching parameters, missing requirements, outdated descriptions, etc. Our experiment result shows that DocCon achieves good precision and is applicable to different libraries: 29 and 22 out of our reported 40 errors have been confirmed and fixed by library developers so far.