{"title":"GethReplayer: a smart contract testing method based on transaction replay","authors":"Xiaohong Shi, Ziyan Wang, Runlu Zhong, Liangliang Ma, Xiangping Chen, Peng Yang","doi":"10.1108/ijwis-08-2023-0138","DOIUrl":null,"url":null,"abstract":"\nPurpose\nSmart contracts are written in high-level programming languages, compiled into Ethereum Virtual Machine (EVM) bytecode, deployed onto blockchain systems and called with the corresponding address by transactions. The deployed smart contracts are immutable, even if there are bugs or vulnerabilities. Therefore, it is critical to verify smart contracts before deployment. This paper aims to help developers effectively and efficiently locate potential defects in smart contracts.\n\n\nDesign/methodology/approach\nGethReplayer, a smart contract testing method based on transaction replay, is proposed. It constructs a parallel transaction execution environment with two virtual machines to compare the execution results. It uses the real existing transaction data on Ethereum and the source code of the tested smart contacts as inputs, conditionally substitutes the bytecode of the tested smart contract input into the testing EVM, and then monitors the environmental information to check the correctness of the contract.\n\n\nFindings\nExperiments verified that the proposed method is effective in smart contract testing. Virtual environmental information has a significant effect on the success of transaction replay, which is the basis for the performance of the method. The efficiency of error locating was approximately 14 times faster with the proposed method than without. In addition, the proposed method supports gas consumption analysis.\n\n\nOriginality/value\nThis paper addresses the difficulty that developers encounter in testing smart contracts before deployment and focuses on helping develop smart contracts with as few defects as possible. GethReplayer is expected to be an alternative solution for smart contract testing and provide inspiration for further research.\n","PeriodicalId":44153,"journal":{"name":"International Journal of Web Information Systems","volume":null,"pages":null},"PeriodicalIF":2.5000,"publicationDate":"2024-04-05","publicationTypes":"Journal Article","fieldsOfStudy":null,"isOpenAccess":false,"openAccessPdf":"","citationCount":"0","resultStr":null,"platform":"Semanticscholar","paperid":null,"PeriodicalName":"International Journal of Web Information Systems","FirstCategoryId":"1085","ListUrlMain":"https://doi.org/10.1108/ijwis-08-2023-0138","RegionNum":0,"RegionCategory":null,"ArticlePicture":[],"TitleCN":null,"AbstractTextCN":null,"PMCID":null,"EPubDate":"","PubModel":"","JCR":"Q2","JCRName":"COMPUTER SCIENCE, INFORMATION SYSTEMS","Score":null,"Total":0}
引用次数: 0
Abstract
Purpose
Smart contracts are written in high-level programming languages, compiled into Ethereum Virtual Machine (EVM) bytecode, deployed onto blockchain systems and called with the corresponding address by transactions. The deployed smart contracts are immutable, even if there are bugs or vulnerabilities. Therefore, it is critical to verify smart contracts before deployment. This paper aims to help developers effectively and efficiently locate potential defects in smart contracts.
Design/methodology/approach
GethReplayer, a smart contract testing method based on transaction replay, is proposed. It constructs a parallel transaction execution environment with two virtual machines to compare the execution results. It uses the real existing transaction data on Ethereum and the source code of the tested smart contacts as inputs, conditionally substitutes the bytecode of the tested smart contract input into the testing EVM, and then monitors the environmental information to check the correctness of the contract.
Findings
Experiments verified that the proposed method is effective in smart contract testing. Virtual environmental information has a significant effect on the success of transaction replay, which is the basis for the performance of the method. The efficiency of error locating was approximately 14 times faster with the proposed method than without. In addition, the proposed method supports gas consumption analysis.
Originality/value
This paper addresses the difficulty that developers encounter in testing smart contracts before deployment and focuses on helping develop smart contracts with as few defects as possible. GethReplayer is expected to be an alternative solution for smart contract testing and provide inspiration for further research.
期刊介绍:
The Global Information Infrastructure is a daily reality. In spite of the many applications in all domains of our societies: e-business, e-commerce, e-learning, e-science, and e-government, for instance, and in spite of the tremendous advances by engineers and scientists, the seamless development of Web information systems and services remains a major challenge. The journal examines how current shared vision for the future is one of semantically-rich information and service oriented architecture for global information systems. This vision is at the convergence of progress in technologies such as XML, Web services, RDF, OWL, of multimedia, multimodal, and multilingual information retrieval, and of distributed, mobile and ubiquitous computing. Topicality While the International Journal of Web Information Systems covers a broad range of topics, the journal welcomes papers that provide a perspective on all aspects of Web information systems: Web semantics and Web dynamics, Web mining and searching, Web databases and Web data integration, Web-based commerce and e-business, Web collaboration and distributed computing, Internet computing and networks, performance of Web applications, and Web multimedia services and Web-based education.