Skip to main content
QUICK REVIEW

[论文解读] WhylSon: Proving your Michelson Smart Contracts in Why3

Luís Pedro Arrojado da Horta, João Santos Reis|arXiv (Cornell University)|May 29, 2020
Blockchain Technology Applications and Security参考文献 7被引用 6
一句话总结

WhylSon 是一种将 Michelson 智能合约自动翻译为 WhyML 以进行形式化验证的工具,利用 Why3 框架实现,支持通过集成的定理证明器自动生成证明。它采用浅层嵌入方式表达 Michelson 的语义,使开发者能够以高度自动化的方式验证 Tezos 智能合约的正确性,并无缝集成到现有的形式化验证工作流中。

ABSTRACT

This paper introduces WhylSon, a deductive verification tool for smart contracts written in Michelson, which is the low-level language of the Tezos blockchain. WhylSon accepts a formally specified Michelson contract and automatically translates it to an equivalent program written in WhyML, the programming and specification language of the Why3 framework. Smart contract instructions are mapped into a corresponding WhyML shallow-embedding of the their axiomatic semantics, which we also developed in the context of this work. One major advantage of this approach is that it allows an out-of-the-box integration with the Why3 framework, namely its VCGen and the backend support for several automated theorem provers. We also discuss the use of WhylSon to automatically prove the correctness of diverse annotated smart contracts.

研究动机与目标

  • 为应对 Tezos 智能合约因不可变性及在金融逻辑中日益广泛的应用而产生的形式化验证关键需求。
  • 自动化 Michelson 智能合约的验证过程,最大限度减少手动证明工作量。
  • 与 Why3 框架无缝集成,以利用现有的自动化与交互式定理证明工具。
  • 在实际执行层面(Michelson)进行验证,而非高层抽象,以确保验证代码的准确性和可信度。
  • 通过将 Michelson 作为经验证的后端,为未来 LIGO 或 SmartPy 等高级语言的验证工作流提供支持。

提出的方法

  • 该工具解析 Michelson 合约,并通过 Michelson 的公理化语义的浅层嵌入,将其翻译为等价的 WhyML 代码。
  • 在 Why3 中定义了 Michelson 的自定义公理化语义,将每条指令映射到其对应的正式行为。
  • 将 Michelson 的基本类型(如 nat、int、bytes、bool、option)映射到相应的 Why3 类型,并通过自定义不变式(如对 nat 的约束)确保正确性。
  • 手动在 Why3 中实现比较函数(如 compare_bool),以符合 Michelson 的规范,返回 -1、0 或 1。
  • Why3 的验证条件生成器(VCGen)自动产生证明义务,由外部自动化定理证明器(如 Z3 或 CVC4)进行消解。
  • 该工具作为 Why3 插件实现,基于 OCaml 的 Why3 API,支持集成到形式化验证工作流中。

实验结果

研究问题

  • RQ1Michelson 智能合约能否在保留语义的前提下自动翻译为 WhyML,以支持形式化验证?
  • RQ2在使用 Why3 时,自动化定理证明器在多大程度上能够消解由 Michelson 合约生成的证明义务?
  • RQ3浅层嵌入方法在多大程度上保持了 Michelson 堆栈式语义在 WhyML 中的表达能力与可验证性?
  • RQ4在将自动化验证扩展到复杂 Michelson 合约时面临哪些实际挑战,如何缓解?
  • RQ5WhylSon 是否可作为 LIGO 或 SmartPy 等高级智能合约语言的后端验证层?

主要发现

  • WhylSon 能够成功将 Michelson 合约翻译为 WhyML,使开发者能够利用 Why3 的自动化定理证明器进行形式化验证。
  • 该工具实现了高度自动化,证明义务由 Why3 的 VCGen 自动生成,并由 Z3 或 CVC4 等外部证明器消解。
  • 尽管实现了自动化,部分证明树仍过于庞大,需要用户干预,表明当前类型编码策略存在局限性。
  • 使用树状数据结构表示 Michelson 类型导致了复杂的证明义务,提示需要更优化的编码策略。
  • 由于 Why3 具有良好的 OCaml API 文档,与 Why3 的集成过程十分顺利,支持快速插件开发。
  • 该方法可通过作为编译的经验证后端,支持未来与认证编译器及高级语言(如 Archetype 或 LIGO)的集成。

更好的研究,从现在开始

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

无需绑定信用卡

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