一句话:提出 RAGas,用检索增强的大模型三阶段框架自动定位并修复智能合约的 Gas 低效问题。
以太坊智能合约的 Gas 费用随计算复杂度增长,降低高 Gas 开销代码对部署成本意义重大,但现有工具依赖固定规则集,无法自主适应不断演化的 Gas 消耗模式。该工作系统分析了导致 Gas 过高的语法与语义特征,构建了覆盖 6 大类、12 种细粒度高 Gas 消耗(HGC)模式及其知识库。在此基础上提出 RAGas——一个三阶段检索增强生成框架,利用大语言模型定位并自动修复 Gas 低效问题,并支持持续知识集成。实验表明,在真实已部署合约上,RAGas 最高可降低 11.2% 的 Gas 使用量。
Ethereum has gradually become an infrastructure in key areas such as finance, healthcare, and supply chain. When its smart contracts are executed, Gas fees increase with the growth of computational complexity. Therefore, reducing code with high Gas overhead while maintaining functional equivalence is of great significance to deployment costs. Currently available tools rely on fixed rule sets and cannot autonomously adapt to the dynamically evolving patterns of Gas consumption. To this end, we systematically analyzed the grammatical and semantic features that lead to excessive Gas consumption and constructed 12 fine-grained High Gas Consumption (HGC) patterns and knowledge bases covering 6 major categories. Based on this, we propose RAGas, a three-stage retrieval enhancement generation framework that utilizes large language models to locate and automatically fix Gas inefficiency issues. The experimental results show that RAGas can reduce Gas usage by up to 11.2% in real world deployed contracts.
@inproceedings{paperbot11563,
title = {RAGas: Retrieval Augmented Gas Optimization for Smart Contracts with Continuous Knowledge Integration},
author = {Xiaoqi Li and Yishun Wang and Wenkai Li and Zongwei Li},
booktitle = {ICSE},
year = {2026},
doi = {10.1145/3774748.3795663}
}