以太坊中代理模式的大规模探索性研究
A Large-Scale Exploratory Study on the Proxy Pattern in Ethereum
AI总结:
本研究基于5000万合约和16亿交易,系统分析以太坊代理模式的流行度、集成方式与类型,并提出精确率和召回率均达100%的行为检测方法,为开发者提供实践建议。
摘要:
代理模式是一种广为人知的设计模式,在软件行业的多个领域中有大量用例。因此,代理模式的使用也是以太坊区块链上复杂去中心化应用(DApp)开发中的常见方法。尽管代理合约十分重要,但人们对以下问题知之甚少:(i)其流行程度如何随时间变化,(ii)开发者在 DApp 设计中集成代理的方式,以及(iii)开发者最常使用的代理类型是什么。本研究通过对以太坊智能合约进行全面分析来弥合这些空白,利用了截至 2022 年 9 月的 5000 万个合约和 16 亿笔交易的数据集。我们的发现表明,所有已部署智能合约中有 14.2% 是代理合约。我们表明,代理合约比非代理合约被更积极地使用。此外,代理合约在各种上下文中的使用、涉及代理合约的交易以及用户对代理合约的采用随时间呈上升趋势,并在我们研究期结束时达到峰值。它们要么通过链下脚本部署,要么通过链上工厂合约部署,前者和后者分别在已识别使用上下文中占 39.1% 和 60.9%。我们发现,虽然大多数代理(67.8%)充当拦截器,但 32.2% 支持可升级性。代理合约通常(79%)基于已知的参考实现来实现,其中 29.4% 属于 ERC-1167 类型,这是一类旨在低成本复用和克隆合约功能的代理。我们的评估表明,我们提出的行为代理检测方法在检测活跃代理方面具有 100% 的精确率和召回率。最后,我们为开发者推导出一组实用建议,并提出开放研究问题以指导该主题的未来研究。
英文摘要:
The proxy pattern is a well-known design pattern with numerous use cases in several sectors of the software industry. As such, the use of the proxy pattern is also a common approach in the development of complex decentralized applications (DApps) on the Ethereum blockchain. Despite the importance of proxy contracts, little is known about (i) how their prevalence changed over time, (ii) the ways in which developers integrate proxies in the design of DApps, and (iii) what proxy types are being most commonly leveraged by developers. This study bridges these gaps through a comprehensive analysis of Ethereum smart contracts, utilizing a dataset of 50 million contracts and 1.6 billion transactions as of September 2022. Our findings reveal that 14.2% of all deployed smart contracts are proxy contracts. We show that proxy contracts are being more actively used than non-proxy contracts. Also, the usage of proxy contracts in various contexts, transactions involving proxy contracts, and adoption of proxy contracts by users have shown an upward trend over time, peaking at the end of our study period. They are either deployed through off-chain scripts or on-chain factory contracts, with the former and latter being employed in 39.1% and 60.9% of identified usage contexts in turn. We found that while the majority (67.8%) of proxies act as an interceptor, 32.2% enables upgradeability. Proxy contracts are typically (79%) implemented based on known reference implementations with 29.4% being of type ERC-1167, a class of proxies that aims to cheaply reuse and clone contracts' functionality. Our evaluation shows that our proposed behavioral proxy detection method has a precision and recall of 100% in detecting active proxies. Finally, we derive a set of practical recommendations for developers and introduce open research questions to guide future research on the topic.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。