arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2106.06458cs.SEcs.PL
收藏

Solidity智能合约的低级评论自动生成

Low-level Comments auto-generation for Solidity Smart Contracts

Chaochen Shi, Yong Xiang, Jiangshan Yu, Keshav Sood, Longxiang Gao

摘要:

背景:区块链平台上的去中心化应用通过智能合约实现。然而,缺乏编程知识的参与者往往难以阅读智能合约源代码,这导致潜在的安全风险和参与障碍。目的:我们的目标是将智能合约源代码翻译成自然语言描述,以帮助人们更好地理解、操作和学习智能合约。方法:本文提出了一种基于抽象语法树和形式语法的Solidity智能合约自动翻译工具SolcTrans。我们调查了3,000个智能合约,并确定了相应区块链术语的词性。其中,我们进一步过滤出没有详细注释的合同片段,留下811个片段来评估SolcTrans的翻译质量。结果如下:实验结果表明,即使是一个小的语料库,SolcTrans可以实现类似的性能,国家的最先进的代码注释生成模型的其他程序设计语言。此外,SolcTrans在处理不同长度和gas消耗的代码片段时具有一致的性能。结论:SolcTrans能够正确解释Solidity代码并自动将其转换为可理解的英文文本。我们将发布我们的工具和数据集,以支持相关领域的复制和进一步研究。

英文摘要:

Context: Decentralized applications on blockchain platforms are realized through smart contracts. However, participants who lack programming knowledge often have difficulties reading the smart contract source codes, which leads to potential security risks and barriers to participation. Objective: Our objective is to translate the smart contract source codes into natural language descriptions to help people better understand, operate, and learn smart contracts. Method: This paper proposes an automated translation tool for Solidity smart contracts, termed SolcTrans, based on an abstract syntax tree and formal grammar. We have investigated 3,000 smart contracts and determined the part of speeches of corresponding blockchain terms. Among them, we further filtered out contract snippets without detailed comments and left 811 snippets to evaluate the translation quality of SolcTrans. Results: Experimental results show that even with a small corpus, SolcTrans can achieve similar performance to the state-of-the-art code comments generation models for other programming languages. In addition, SolcTrans has consistent performance when dealing with code snippets with different lengths and gas consumption. Conclusion: SolcTrans can correctly interpret Solidity codes and automatically convert them into comprehensible English text. We will release our tool and dataset for supporting reproduction and further studies in related fields.

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

↑