arXivDaily arXiv每日学术速递 周一至周五更新
感恩节,周五至周末无更新,大家顺遂。周一再来吧
arXiv 2610.18745cs.SEcs.AI
收藏

SolBehave:评估大语言模型生成智能合约的行为正确性

SolBehave: Evaluating the Behavioural Correctness of LLM-Generated Smart Contracts

University of Bologna(博洛尼亚大学);University of Copenhagen(哥本哈根大学)

Giovanni Pio Delvecchio, Stefano Fantazzini, Giacomo Frisoni, Gianluca Moro, Lorenzo Bacchiani, Mario Bravetti, Thomas Troels Hildebrandt

AI总结:

研究针对大语言模型生成智能合约的评估仅关注编译的问题,推出SolBehave基准,通过三项测试评估合约行为正确性,发现编译远非正确性的充分条件。

摘要:

大型语言模型越来越多地生成Solidity智能合约,这些合约一旦部署就无法修补,单个潜在故障会永久存在并被利用。然而当前评估大多仅询问生成的代码是否能编译。我们推出SolBehave,这是一个用于大规模评估模型生成合约正确性的基准,超越了临时单元测试。在250个真实、可复现的以太坊合约上,我们应用三项互补的行为保真度测试:差异模糊测试、历史交易重放,以及作为核心贡献的、由动态条件响应(DCR)图引导的合成交易重放,该图枚举了合法函数调用序列的空间。差异模糊测试在自动生成的输入上比较每个生成函数与原始函数;历史重放在合约实际收到的链上交易上比较整个合约;DCR引导的重放则在遵循其预期使用的调用序列上进行比较,包括链上从未出现过的排序。我们在一轮自动修复后评估了七个最先进的开放权重模型。编译成功率在26.4%至92.7%之间,但在差异模糊测试下,所有编译的生成函数体中,跨模型和样本汇总后仅有31.4%与原始函数等价。合约层面的分歧是常态而非例外:在七个模型中的六个里,编译的生成合约中有13%至31%在历史重放下与原始合约分歧,在DCR引导的重放下则为13%至44%;仅Gemma-4-31B在两项测试中均保持在3%以下。因此,编译是正确性的必要条件,但远非充分条件。

英文摘要:

Large language models increasingly generate Solidity smart contracts that, once deployed, can never be patched, making a single latent fault permanent and exploitable. Yet current evaluations mostly ask only whether generated code compiles. We introduce SolBehave, a benchmark for evaluating the correctness of model-generated contracts at scale, moving beyond ad hoc unit tests. Across 250 real, reproducible Ethereum contracts, we apply three complementary tests of behavioural fidelity: differential fuzzing, historical-transaction replay, and, as our core contribution, synthetic-transaction replay guided by a Dynamic Condition Response (DCR) graph that enumerates the space of legitimate function-call sequences. Differential fuzzing compares each generated function with the original on automatically generated inputs; historical replay compares the whole contract on the transactions it actually received on-chain; DCR-guided replay compares it on sequences of calls that follow its intended usage, including orderings that never occurred on-chain. We evaluate seven state-of-the-art open-weight models after one round of automated repair. Compilation success ranges from 26.4% to 92.7%, but under differential fuzzing only 31.4% of all generated function bodies that compile, pooled over models and samples, are equivalent to the original. Divergence at the contract level is the norm rather than the exception: for six of the seven models, between 13% and 31% of the generated contracts that compile diverge from the original under historical replay, and between 13% and 44% under DCR-guided replay; only Gemma-4-31B stays below 3% on both. Compilation is therefore a necessary condition for correctness and far from a sufficient one.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑