To read this content please select one of the options below:

GethReplayer: a smart contract testing method based on transaction replay

Xiaohong Shi (School of Information Engineering, Guangzhou Panyu Polytechnic, Guangzhou, China)
Ziyan Wang (School of Computer Science and Engineering, Sun Yat-Sen University, Guangzhou, China)
Runlu Zhong (School of Information Engineering, Guangzhou Panyu Polytechnic, Guangzhou, China)
Liangliang Ma (School of Information Engineering, Guangzhou Panyu Polytechnic, Guangzhou, China)
Xiangping Chen (School of Communication and Design, Sun Yat-Sen University, Guangzhou, China)
Peng Yang (School of Information Engineering, Guangzhou Panyu Polytechnic, Guangzhou, China and School of Computer, South China Normal University, Guangzhou, China)

International Journal of Web Information Systems

ISSN: 1744-0084

Article publication date: 5 April 2024

12

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.

Keywords

Acknowledgements

This work is partially supported by the Scientific Research Project of Guangzhou Education Bureau (No. 202032818), the Guangzhou Basic and Applied Basic Research Foundation (No. 202102080394), the Academic Innovation Team Project of Guangzhou Panyu Polytechnic (No. 2020CXTD004) and Guangdong Young Innovative Talent Project of General College and University (No. 2021WQNCX274).

Citation

Shi, X., Wang, Z., Zhong, R., Ma, L., Chen, X. and Yang, P. (2024), "GethReplayer: a smart contract testing method based on transaction replay", International Journal of Web Information Systems, Vol. ahead-of-print No. ahead-of-print. https://doi.org/10.1108/IJWIS-08-2023-0138

Publisher

:

Emerald Publishing Limited

Copyright © 2024, Emerald Publishing Limited

Related articles