Skip to main content
QUICK REVIEW

[Paper Review] Smart Contract Design Meets State Machine Synthesis: Case Studies

Dmitrii Suvorov, Vladimir Ulyantsev|arXiv (Cornell University)|Jun 7, 2019
Security and Verification in ComputingComputer Science15 references5 citations
TL;DR

This paper proposes a specification-driven approach to automatically generate correct-by-construction smart contracts using linear temporal logic (LTL) synthesis and finite state machine (FSM) modeling. By encoding contract behavior as LTL formulas and integrating test scenarios, the method synthesizes FSMs that are compiled into secure, executable Solidity code, demonstrated through case studies in crowdfunding, auctions, and licensing—showcasing end-to-end verification and code generation with formal correctness guarantees.

ABSTRACT

Modern blockchain systems support creation of smart contracts -- stateful programs hosted and executed on a blockchain. Smart contracts hold and transfer significant amounts of digital currency which makes them an attractive target for security attacks. It has been shown that many contracts deployed to public ledgers contain security vulnerabilities. Moreover, the design of blockchain systems does not allow the code of the smart contract to be changed after it has been deployed to the system. Therefore, it is important to guarantee the correctness of smart contracts prior to their deployment. Formal verification is widely used to check smart contracts for correctness with respect to given specification. In this work we consider program synthesis techniques in which the specification is used to generate correct-by-construction programs. We focus on one of the special cases of program synthesis where programs are modeled with finite state machines (FSMs). We show how FSM synthesis can be applied to the problem of automatic smart contract generation. Several case studies of smart contracts are outlined: crowdfunding platform, blinded auction and a license contract. For each case study we specify the corresponding smart contract with a set of formulas in linear temporal logic (LTL) and use this specification together with test scenarios to synthesize a FSM model for that contract. These models are later used to generate executable Solidity code which can be directly used in a blockchain system.

Motivation & Objective

  • To address the critical challenge of smart contract security by enabling automatic generation of correct-by-construction contracts prior to deployment.
  • To explore whether program synthesis via finite state machines (FSMs) can be effectively applied to smart contract development, given their relatively small and stateful nature.
  • To bridge formal specification and executable code by synthesizing FSMs from LTL specifications and test scenarios, ensuring temporal logic compliance.
  • To demonstrate the feasibility and practicality of this approach through case studies involving crowdfunding, blinded auctions, and license contracts.
  • To lay the foundation for future integration of synthesis with source-level verification and gas-aware property modeling in smart contracts.

Proposed method

  • The approach models smart contracts as extended finite state machines (EFSMs), where input events correspond to contract methods and output actions represent method implementations.
  • Formal specifications are expressed in linear temporal logic (LTL), capturing desired behavioral properties such as invariants, safety, and liveness conditions.
  • Test scenarios are used alongside LTL formulas to guide the synthesis of correct-by-construction FSM models, ensuring behavioral conformance.
  • The synthesized FSMs are then compiled into executable Solidity code using a custom code generation tool (fsmc), which supports multiple transitions per event—unlike existing tools such as VeriSolid.
  • The method leverages EFSM-tools for FSM synthesis and integrates temporal logic verification to ensure that generated contracts meet specified safety and liveness properties.
  • The framework supports extension to multi-contract systems and can be combined with source-level verification techniques to enhance trustworthiness.

Experimental results

Research questions

  • RQ1Can LTL-based program synthesis effectively generate correct-by-construction smart contracts with formal behavioral guarantees?
  • RQ2To what extent can finite state machine synthesis model the control flow of real-world smart contracts such as crowdfunding and auction systems?
  • RQ3How can test scenarios be integrated with LTL specifications to improve the precision and practicality of synthesized FSM models?
  • RQ4What are the limitations of LTL in expressing complex smart contract properties, and how can they be mitigated in practice?
  • RQ5Can the synthesis pipeline be extended to incorporate on-chain concerns such as gas costs and coin transfers in formal specifications?

Key findings

  • The proposed method successfully synthesized FSM models for three distinct smart contract use cases: crowdfunding, blinded auction, and license contract, all verified against formal LTL specifications.
  • Synthesis completed within seconds for each case study, demonstrating the practical efficiency of the approach despite the undecidability of general program synthesis.
  • The generated Solidity code was correct-by-construction with respect to the given LTL properties, including invariants like "noRemove" and liveness conditions such as "donate" leading to eventual approval.
  • The custom tool fsmc enabled support for multiple transitions per event, overcoming a key limitation of existing tools like VeriSolid, and facilitated reliable code generation.
  • The approach demonstrated that FSM synthesis with LTL is viable for smart contracts, offering a path to automated, formally verified contract deployment.
  • While LTL lacks expressiveness for certain properties (e.g., "φ can happen infinitely often while ψ has not occurred"), this limitation was mitigated by using sufficiently long test scenarios to cover all FSM transitions.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.