Skip to main content
QUICK REVIEW

[论文解读] Deductive Proof of Ethereum Smart Contracts Using Why3

Zeinab Nehaï, François Bobot|arXiv (Cornell University)|Apr 25, 2019
Blockchain Technology Applications and Security参考文献 13被引用 12
一句话总结

本文提出了一种使用 Why3(一个演绎验证工具)对工业级以太坊智能合约进行形式化验证的框架。它将 Solidity 合约编码为 WhyML,指定安全属性(例如,运行时错误的缺失和正确的代币转账),使用自动化定理证明器进行验证,并在估算气体消耗的同时将已验证的合约编译为 EVM 字节码。其主要贡献在于展示了 Why3 在对具有形式化保证的复杂真实世界智能合约进行验证方面的可行性。

ABSTRACT

A bug or error is a common problem that any software or computer program may encounter. It can occur from badly writing the program, a typing error or bad memory management. However, errors can become a significant issue if the unsafe program is used for critical systems. Therefore, formal methods for these kinds of systems are greatly required. In this paper, we use a formal language that performs deductive verification on an Ethereum Blockchain application based on smart contracts, which are self-executing digital contracts. Blockchain systems manipulate cryptocurrency and transaction information. Therefore , if a bug occurs in the blockchain, serious consequences such as a loss of money can happen. Thus, the aim of this paper is to propose a language dedicated to deductive verification, called Why3, as a new language for writing formal and verified smart contracts, thereby avoiding attacks exploiting such contract execution vulnerabilities. We first write a Why3 smart contracts program; next we formulate specifications to be proved as absence of RunTime Error properties and functional properties, then we verify the behavior of the program using the Why3 system. Finally we compile the Why3 contracts to the Ethereum Virtual Machine (EVM). Moreover, we give a set of generic mathematical statements that allows verifying functional properties suited to any type of smart contracts holding cryptocurrency, showing that Why3 can be a suitable language to write smart contracts. To illustrate our approach, we describe its application to a realistic industrial use case.

研究动机与目标

  • 为解决工业智能合约中的关键安全风险(例如,因漏洞导致的财务损失),通过形式化验证加以应对。
  • 评估 Why3(一个演绎验证平台)是否能够有效用于指定、验证和编译复杂智能合约。
  • 将形式化验证从简单合约扩展到包含多种数据类型(例如,代币、地址、余额)和复杂逻辑的功能属性。
  • 在形式化验证流程中提供气体估算机制,将正确性与执行成本关联起来。

提出的方法

  • 将来自区块链能源市场平台(BEMP)应用的现有基于 Solidity 的智能合约编码为 Why3 内的高阶形式语言 WhyML。
  • 使用前置条件、后置条件和不变量指定功能性属性,例如正确的余额转账、有效的交易条件以及运行时错误的缺失。
  • 使用 Why3 内置的定理证明器(例如,Alt-ergo、Z3、CVC4)自动处理正确性和安全性的证明义务。
  • 通过 `@evm:gas_checking` 注解对函数进行气体成本注解,以在验证过程中估算计算成本。
  • 使用 Why3 的代码生成流水线将已验证的 Why3 合约编译为与 EVM 兼容的字节码。
  • 集成一个自定义气体成本模型,用于追踪每种操作的气体使用量,并在函数调用间聚合气体消耗。

实验结果

研究问题

  • RQ1Why3 是否能够有效用于对具有复杂逻辑和多种数据类型的工业级以太坊智能合约进行形式化验证?
  • RQ2在智能合约的演绎验证框架中,气体消耗的估算精度如何?
  • RQ3使用 Why3 的形式化验证能否防止运行时错误并确保真实世界应用(如 BEMP)的功能正确性?
  • RQ4与 Solidity 相比,使用 WhyML 指定复杂属性(例如,订单匹配、余额转账)的开销和表达能力如何?
  • RQ5Why3 流水线在多阶段验证中的支持程度如何,从规格说明到 EVM 编译的端到端验证?

主要发现

  • Why3 框架成功验证了 BEMP 应用中的一个复杂交易合约,包括对余额、代币转账和订单匹配的正确处理。
  • 形式化规格成功证明了运行时错误(例如,数组越界访问和除零错误)的不存在性。
  • 系统正确验证了功能性属性,包括在市场参与者之间正确转移以太币和绿色代币。
  • 通过注解的成本模型准确估算出气体消耗,每种操作的气体成本(例如,128 用于列表遍历,185 用于分配)已集成到验证过程中。
  • 已验证的合约成功编译为 EVM 字节码,证明了从规格说明到部署的端到端可信性。
  • 该方法在多用户、多参与方的能源交易系统中表现出可扩展性,表明其适用性超越了简单合约。

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。