一句话:首个基于 2,915 个 GitHub Solidity 项目的事件日志实践实证研究,并实现检查器发现高 gas 日志问题。
事件日志是 Solidity 中由高层 event 特性提供的日志机制,但此前缺乏对其真实项目实践的系统理解。本文首次对 GitHub 上 2,915 个流行 Solidity 项目进行定量特征研究,考察事件日志的普遍性、当前实践质量,尤其关注事件日志代码演化的原因,并得出 8 项重要发现。这些发现包括大量独立的事件日志代码修改,且不同类别独立修改的动因多样,例如修复缺陷和节省 gas。作者进一步给出对开发者、研究者、工具构建者和语言设计者的启示。为展示研究价值,作者基于其中一项发现实现了一个概念验证检查器,在 35 个流行 GitHub 项目中有效检测出消耗额外 gas 的问题事件日志代码,其中 9 个项目维护者已确认相关问题。
Writing logging messages is a well-established conventional programming practice, and it is of vital importance for a wide variety of software development activities. The logging mechanism in Solidity programming is enabled by the high-level event feature, but up to now there lacks study for understanding Solidity event logging practices in the wild. To fill this gap, we in this paper provide the first quantitative characteristic study of the current Solidity event logging practices using 2,915 popular Solidity projects hosted on GitHub. The study methodically explores the pervasiveness of event logging, the goodness of current event logging practices, and in particular the reasons for event logging code evolution, and delivers 8 original and important findings. The findings notably include the existence of a large percentage of independent event logging code modifications, and the underlying reasons for different categories of independent event logging code modifications are diverse (for instance, bug fixing and gas saving). We additionally give the implications of our findings, and these implications can enlighten developers, researchers, tool builders, and language designers to improve the event logging practices. To illustrate the potential benefits of our study, we develop a proof-of-concept checker on top of one of our findings and the checker effectively detects problematic event logging code that consumes extra gas in 35 popular GitHub projects and 9 project owners have already confirmed the detected issues.