西安电子科技大学学报 ›› 2024, Vol. 51 ›› Issue (3): 194-202.doi: 10.19665/j.issn1001-2400.20230803

• 网络空间安全 • 上一篇    下一篇

一种支持交易筛选的高性能智能合约测试方案

彭泳翔1(), 马勇2(), 刘志全1,3(), 王立波1(), 吴永东1(), 陈宁3(), 唐泳4()   

  1. 1.暨南大学 信息科学技术学院,广东 广州 510632
    2.江西师范大学 计算机信息工程学院,江西 南昌 330022
    3.广东省网络与信息安全漏洞研究重点实验室,广东 广州 510643
    4.电子科技大学 计算机科学与工程学院,四川 成都 610054
  • 收稿日期:2023-05-07 出版日期:2024-06-20 发布日期:2023-11-08
  • 作者简介:彭泳翔(1998—),男,暨南大学硕士研究生,E-mail:greapi@foxmail.com
    刘志全(1989—),男,教授,E-mail:zqliu@vip.qq.com
    王立波(1988—),男,讲师,E-mail:wanglibo12b@mails.ucas.edu.cn
    吴永东(1970—),男,教授,E-mail:wuyd007@vip.qq.com
    陈 宁(1984—),女,工程师,E-mail:chenn@gditsec.org.cn
    唐 泳(1979—),男,讲师,E-mail:tangyong@uestc.com
  • 基金资助:
    国家自然科学基金(62032025);国家自然科学基金(61932011);国家自然科学基金(62272195);广东省网络与信息安全漏洞研究重点实验室项目(2020B1212060081);广东省重点研发计划(2020B0101090002);广东省基础与应用基础研究基金(2022A1515010299);广东省基础与应用基础研究基金(2020A1515110364);广州市科技计划项目(202201010421);中央高校基本科研业务费专项资金(21622402)

Efficient smart contract testing scheme supporting transactions filtering

PENG Yongxiang1(), MA Yong2(), LIU Zhiquan1,3(), WANG Libo1(), WU Yongdong1(), CHEN Ning3(), TANG Yong4()   

  1. 1. College of Information Science and Technology,Jinan University,Guangzhou 510632,China
    2. School of Computer and Information Engineering,Jiangxi Normal University,Nanchang 330022,China
    3. Guangdong Provincial Key Laboratory of Cyber and Information Security Vulnerability Research,Guangzhou 510643,China
    4. School of Computer Science and Engineering,University of Electronic Science and Technology of China,Chengdu 610054,China
  • Received:2023-05-07 Online:2024-06-20 Published:2023-11-08

摘要:

近年来,作为以太坊的重要组成部分,智能合约引起了工业界与学术界的广泛兴趣。智能合约是一段部署在区块链上的程序,为分布式交易提供了可能。然而,由于智能合约携带的金融属性,使其成为黑客攻击的目标。因此,为保证合约的安全性,需对漏洞合约进行修复并通过测试保证功能一致性。然而,现有智能合约测试方案缺乏拓展性、重放准确性低以及储存消耗大等问题。为此,提出一种支持交易筛选的高性能智能合约测试方案。该方案首先基于以太坊状态变更建模交易特征,增强扩展性;接着基于二阶树结构储存以太坊历史数据,优化储存空间;最后通过分叉机制进行交易重放,实现在不干扰主链的情况下对修复合约进行测试。基于所提方案实现原型工具SCTester,并与现有合约测试方案EVMPatch、HARTEL和KIM相比较。实验结果表明,所提方案在拓展性与重放准确率有更好的表现,并且在空间消耗方面,所提方案相较于KIM降低了约21.6%的储存空间;在时间消耗方面,所提方案相较于KIM在账户测试场景下的交易重放减少了约70.5%的时间消耗。

关键词: 区块链, 智能合约, 合约测试

Abstract:

In recent years,the smart contract has become a focal point of both the industry and academia as a vital component of the Ethereum blockchain.A smart contract is a program deployed on the blockchain that enables distributed transactions.However,due to the financial attributes of the smart contract,it becomes the target of hacker attacks.To ensure the security of the contract,identifying and repairing vulnerabilities is essential,and functional consistency must be guaranteed through rigorous testing.Regrettably,existing smart contract testing schemes suffer from several shortcomings,including a low replay accuracy and high storage consumption.In response to these challenges,an efficient smart contract testing scheme supporting transactions filtering is proposed which first models transaction features based on Ethereum state changes to enhance scalability;then optimizes storage space by storing Ethereum historical data based on a second-order tree structure;and finally,perform the transaction replay through the forking mechanism to test patched contract without interfering with the main chain.The prototype tool SCTester is implemented based on the proposed solution and conducts comparative assessments against existing contract testing schemes such as EVMPatch,Hartel,and Kim.Experimental results show the superiority of our proposed approach in terms of scalability and replay accuracy.Besides,it reduces storage space by 21.6% compared with Kim in terms of space consumption;and in terms of time consumption,it reduces time consumption by 70.5% compared with Kim in transaction replay under account testing scenario.

Key words: blockchain, smart contract, contract testing

中图分类号: 

  • TP309
Baidu
map