paperbot · PL 论文追踪

全部论文 待读 收藏

P2 PrefGen: A Preference-Driven Methodology for Secure Yet Gas-Efficient Smart Contract Generation

PrefGen:一种面向安全且 Gas 高效的智能合约生成的偏好驱动方法
ASE 2025 40th IEEE/ACM International Conference on Automated Software Engineering (ASE)2025匹配度 2/10 · 该论文聚焦于用偏好优化(DPO)提升 LLM 生成 Solidity 智能合约的功能、Gas 与安全性,属于 LLM 代码生成/对齐方向,而非用户核心关注的静态分析、Agentic 程序分析、浮点程序分析或贝叶斯程序分析。虽然涉及 PL 与安全交叉,但方法和目标与画像匹配度很低。引用 1 inbox
Zhiyuan Peng, Xin Yin, Zijie Zhou, Chenhao Ying, Chao Ni, Yuan Luo
crossref: 2026-09-12

AI 速览

一句话:把直接偏好优化扩展到可量化的区块链专用度量,实现智能合约功能、Gas 与安全的多目标联合优化。

大语言模型虽能生成功能正确的 Solidity 代码,但在真实部署同样关键的 Gas 效率与安全性上仍明显不足;现有基于监督微调与直接偏好优化(DPO)的方法把功能正确性、Gas 优化与安全视为彼此独立的目标,生成的合约要么执行成本过高,要么存在危险漏洞。本文提出 PrefGen,将标准 DPO 从人类偏好扩展到可量化的区块链专用度量,实现面向智能合约生成的整体多目标优化,并设计了 Pass@k(功能正确性)、Compile@k(语法正确性)、Gas@k(Gas 效率)、Secure@k(安全评估)四个互补指标的评估方法。实验表明 PrefGen 在所有关键维度上显著优于现有方法,达到 66.7% Pass@5、58.9% Gas@5 与 62.5% Secure@5,可生成功能正确、成本低且安全的可部署合约。

问题
LLM 生成的 Solidity 合约往往功能正确却 Gas 开销高或存在安全漏洞,因为现有偏好对齐方法把功能正确性、Gas 优化与安全当作相互独立的目标。
方法
提出 PrefGen,把标准 DPO 从人类偏好扩展到可量化的区块链专用度量,对功能正确性、Gas 效率与安全性做整体多目标偏好优化,并配套四维评估指标 Pass@k、Compile@k、Gas@k、Secure@k。
评估
通过大量实验在四个维度上与现有方法对比,PrefGen 全面领先,取得 66.7% Pass@5、58.9% Gas@5 与 62.5% Secure@5。
原文摘要(Abstract)

While Large Language Models (LLMs) have demonstrated remarkable progress in generating functionally correct Solidity code, they continue to face critical challenges in producing gas-efficient and secure code, which are critical requirements for real-world smart contract deployment. Although recent advances leverage Supervised Fine-Tuning (SFT) and Direct Preference Optimization (DPO) for code preference alignment, existing approaches treat functional correctness, gas optimization, and security as independent objectives, resulting in contracts that may achieve operational soundness but suffer from prohibitive execution costs or dangerous vulnerabilities. To address these limitations, we propose PrefGen, a novel framework that extends standard DPO beyond human preferences to incorporate quantifiable blockchain-specific metrics, enabling holistic multi-objective optimization specifically tailored for smart contract generation. Our framework introduces a comprehensive evaluation methodology with four complementary metrics: Pass@k (functional correctness), Compile@k (syntactic correctness), Gas@k (gas efficiency), and Secure@k (security assessment), providing rigorous multi-dimensional contract evaluation. Through extensive experimentation, we demonstrate that PrefGen significantly outperforms existing approaches across all critical dimensions, achieving 66.7% Pass@5, 58.9% Gas@5, and 62.5% Secure@5, while generating production-ready smart contracts that are functionally correct, cost-efficient, and secure.

链接与引用

DOI 原文 ·

BibTeX
@inproceedings{paperbot9203,
  title = {PrefGen: A Preference-Driven Methodology for Secure Yet Gas-Efficient Smart Contract Generation},
  author = {Zhiyuan Peng and Xin Yin and Zijie Zhou and Chenhao Ying and Chao Ni and Yuan Luo},
  booktitle = {ASE},
  year = {2025},
  doi = {10.1109/ase63991.2025.00034}
}