Lune

ASE2022Top-tier venue

Learning Contract Invariants Using Reinforcement Learning

Junrui Liu, Yanju Chen, Bryan Tan, Isil Dillig, Yu Feng

Abstract

Due to the popularity of smart contracts in the modern financial ecosystem, there has been growing interest in formally verifying their correctness and security properties. Most existing techniques in this space focus on common vulnerabilities like arithmetic overflows and perform verification by leveraging contract invariants (i.e., logical formulas hold at transaction boundaries). In this paper, we propose a new technique, based on deep reinforcement learning, for automatically learning contract invariants that are useful for proving arithmetic safety. Our method incorporates an off-line training phase in which the verifier uses its own verification attempts to learn a policy for contract invariant generation. This learned (neural) policy is then used at verification time to predict likely invariants that are also useful for proving arithmetic safety. We implemented this idea in a tool called Cider and incorporated it into an existing verifier (based on refinement type checking) for proving arithmetic safety. Our evaluation shows that Cider improves both the quality of the inferred invariants as well as inference time, leading to faster verification and hardened contracts with fewer run-time assertions.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

4 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • PropertyGPT: LLM-driven Formal Verification of Smart Contracts through Retrieval-Augmented Property Generation cites SmartPulse: Automated Checking of Temporal Properties in Smart Contracts
  • PropertyGPT: LLM-driven Formal Verification of Smart Contracts through Retrieval-Augmented Property Generation cites SmartInv: Multimodal Learning for Smart Contract Invariant Inference
  • PropertyGPT: LLM-driven Formal Verification of Smart Contracts through Retrieval-Augmented Property Generation cites VerX: Safety Verification of Smart Contracts
  • Demystifying Loops in Smart Contracts cites VerX: Safety Verification of Smart Contracts
  • SmartPulse: Automated Checking of Temporal Properties in Smart Contracts cites VerX: Safety Verification of Smart Contracts
  • SmartInv: Multimodal Learning for Smart Contract Invariant Inference cites VERISMART: A Highly Precise Safety Verifier for Ethereum Smart Contracts
  • SmartInv: Multimodal Learning for Smart Contract Invariant Inference cites VerX: Safety Verification of Smart Contracts
  • SmartInv: Multimodal Learning for Smart Contract Invariant Inference cites SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in Seconds
  • HOUSTON: Real-Time Anomaly Detection of Attacks against Ethereum DeFi Protocols cites SmartPulse: Automated Checking of Temporal Properties in Smart Contracts
  • HOUSTON: Real-Time Anomaly Detection of Attacks against Ethereum DeFi Protocols cites VerX: Safety Verification of Smart Contracts
  • HOUSTON: Real-Time Anomaly Detection of Attacks against Ethereum DeFi Protocols cites SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in Seconds
  • Enforcing Control Flow Integrity on DeFi Smart Contracts cites SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in Seconds
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers4

  1. SmartInv: Multimodal Learning for Smart Contract Invariant InferenceSally Junsong Wang, Kexin Pei, Junfeng YangS&P 2024 · 38 citations
  2. HOUSTON: Real-Time Anomaly Detection of Attacks against Ethereum DeFi ProtocolsDongyu Meng, Fabio Gritti, Robert McLaughlin, Nicola Ruaro et al.NDSS 2026 · 2 citations
  3. PropertyGPT: LLM-driven Formal Verification of Smart Contracts through Retrieval-Augmented Property GenerationYe Liu, Yue Xue, Daoyuan Wu, Yuqiang Sun et al.NDSS 2025
  4. Enforcing Control Flow Integrity on DeFi Smart ContractsZhiyang Chen, Sidi Mohamed Beillahi, Pasha Barahimi, Cyrus Minwalla et al.ICSE 2026

Builds on5

  1. VerX: Safety Verification of Smart ContractsAnton Permenev, Dimitar Dimitrov, Petar Tsankov, Dana Drachsler-Cohen et al.S&P 2020 · 251 citations
  2. SAILFISH: Vetting Smart Contract State-Inconsistency Bugs in SecondsPriyanka Bose, Dipanjan Das, Yanju Chen, Yu Feng et al.S&P 2022 · 142 citations
  3. VERISMART: A Highly Precise Safety Verifier for Ethereum Smart ContractsSunbeom So, Myungho Lee, Jisu Park, Heejo Lee et al.S&P 2020 · 133 citations
  4. SmartPulse: Automated Checking of Temporal Properties in Smart ContractsJon Stephens, Kostas Ferles, Benjamin Mariano, Shuvendu K. Lahiri et al.S&P 2021 · 70 citations
  5. Demystifying Loops in Smart ContractsBenjamin Mariano, Yanju Chen, Yu Feng, Shuvendu K. Lahiri et al.ASE 2020 · 20 citations

Related papers

  1. SolType: refinement types for arithmetic overflow in solidityBryan Tan, Benjamin Mariano, Shuvendu K. Lahiri, Isil Dillig et al.POPL 2022 · 29 citations
  2. Verifying Declarative Smart ContractsHaoxian Chen, Lan Lu, Brendan Massey, Yuepeng Wang et al.ICSE 2024 · 2 citations
  3. Automated Inference on Financial Security of Ethereum Smart ContractsWansen Wang, Wenchao Huang, Zhaoyi Meng, Yan Xiong et al.USENIX Security 2023
  4. Trainify: A CEGAR-Driven Training and Verification Framework for Safe Deep Reinforcement LearningPeng Jin, Jiaxu Tian, Dapeng Zhi, Xuejun Wen et al.CAV 2022 · 28 citations
  5. Learning to Synthesize Relational InvariantsJingbo Wang, Chao WangASE 2022 · 9 citations
Dusk over the sea between two cliffs drawn in fine vertical lines