Smart contracts are programs running on blockchain to execute transactions. When input constraints or security properties are violated at runtime, the transaction being executed by a smart contract needs to be reverted to avoid undesirable consequences. On Ethereum, the most popular blockchain that supports smart contracts, developers can choose among three transaction-reverting statements (i.e., require, if...revert, and if...throw) to handle anomalous transactions. While these transaction-reverting statements are vital for preventing smart contracts from exhibiting abnormal behaviors or suffering malicious attacks, there is limited understanding of how they are used in practice. In this work, we perform the first empirical study to characterize transaction-reverting statements in Ethereum smart contracts. We measured the prevalence of these statements in 3,866 verified smart contracts from popular dapps and built a taxonomy of their purposes via manually analyzing 557 transaction-reverting statements. We also compared template contracts and their corresponding custom contracts to understand how developers customize the use of transaction-reverting statements. Finally, we analyzed the security impact of transaction-reverting statements by removing them from smart contracts and comparing the mutated contracts against the original ones. Our study led to important findings, which can shed light on further research in the broad area of smart contract quality assurance and provide practical guidance to smart contract developers on the appropriate use of transaction-reverting statements.
翻译:智能合同是执行交易的链条程序。 当输入限制或安全财产在运行时被违反时,需要恢复智能合同执行的交易,以避免不可取的后果。在最受欢迎的支持智能合同的链条Ethereum上,开发商可以选择三种交易反转报表(即,要求,如果.反转,如果.推)处理异常交易。这些交易反转报表对于防止智能合同显示异常行为或遭受恶意攻击至关重要,但对于如何在实践中使用这些报表的理解有限。在这项工作中,我们进行了第一次实验性研究,以确定Eteenum智能合同中交易反转报表的特点。我们通过手动分析557个交易反转报表(即,要求,如果.反转,如果.),开发商可以对这些报表进行分类。我们还比较模板合同及其相应的定制合同,以了解开发商如何定制交易反转报表的使用。最后,我们分析了交易反转报表在实际合同中的安全影响,从智能合同中删除这些报表,并将智能合同与智能合同比较到智能合同领域。我们将智能合同中的智能合同的使用与智能合同进行更精确的比较。