arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2402.03186cs.SE
收藏

绘制Solidity错误处理演进图

Charting The Evolution of Solidity Error Handling

Charalambos Mitropoulos, Maria Kechagia, Chrysostomos Maschas, Sotiris Ioannidis, Federica Sarro, Dimitris Mitropoulos

AI总结:

本研究通过分析283K个智能合约和102版本文档,揭示Solidity错误处理特性使用有限但require上升,近70%合约面临缺失错误处理风险,建议改进文档。

摘要:

在Solidity智能合约中,错误处理的使用至关重要,因为智能合约执行应被验证的交易。未仔细处理的交易可能导致程序崩溃和漏洞,进而造成经济损失和法律后果。尽管Solidity设计者不断尝试用新特性更新语言,包括错误处理(EH)特性,开发者仍需迅速掌握如何使用它们。我们对283K个独特的开源智能合约进行了大规模实证研究,以识别随时间推移Solidity EH特性的使用模式。总体而言,大多数EH特性的使用有限。然而,我们观察到Solidity特有EH特性即require的使用呈上升趋势(>60%)。这表明现代编程语言的设计者可能会考虑使错误处理更贴合每种语言的目的。我们对102个版本的Solidity文档的分析表明Solidity的易变性,因为语言频繁变化,即EH特性每年变化一到两次。如此频繁的发布可能会使智能合约开发者困惑,阻碍他们仔细阅读Solidity文档并正确采用EH特性。此外,我们的发现显示,近70%的被检查智能合约因缺少错误处理(例如未检查的外部调用)而面临潜在失败。因此,应通过更具信息量的文档进一步支持EH特性的使用,该文档包含(1)代表性且有意义的示例和(2)潜在EH误用影响的细节。

英文摘要:

The usage of error handling in Solidity smart contracts is vital because smart contracts perform transactions that should be verified. Transactions that are not carefully handled, may lead to program crashes and vulnerabilities, implying financial loss and legal consequences. While Solidity designers attempt to constantly update the language with new features, including error-handling (EH) features, it is necessary for developers to promptly absorb how to use them. We conduct a large-scale empirical study on 283K unique open-source smart contracts to identify patterns regarding the usage of Solidity EH features over time. Overall, the usage of most EH features is limited. However, we observe an upward trend (> 60%) in the usage of a Solidity-tailored EH feature, i.e., require. This indicates that designers of modern programming languages may consider making error handling more tailored to the purposes of each language. Our analysis on 102 versions of the Solidity documentation indicates the volatile nature of Solidity, as the language changes frequently, i.e., there are changes on EH features once or twice a year. Such frequent releases may confuse smart contract developers, discouraging them to carefully read the Solidity documentation, and correctly adopt EH features. Furthermore, our findings reveal that nearly 70% of the examined smart contracts are exposed to potential failures due to missing error handing, e.g., unchecked external calls. Therefore, the use of EH features should be further supported via a more informative documentation containing (1) representative and meaningful examples and (2) details about the impact of potential EH misuses.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑