Strengthening Solidity Invariant Generation: From Post- to Pre-Deployment
Kartik Kaushik, Raju Halder, Samrat Mondal
TL;DR
This work tackles the problem of ensuring Solidity smart contract correctness before deployment by generating invariants without relying on post-deployment transaction histories. It introduces InvSol, a Solidity-to-Java transcompiler-based framework that annotates code with JML specifications, uses a dynamic invariant explorer (Daikon) and loop invariant detector (GIN-DYN), and employs a Test Crafter to generate coverage-rich tests, all under static verification. Its key contributions include pre-deployment invariant synthesis, loop invariant coverage, a broad set of blockchain-specific invariant templates (gas, reentrancy, time locks, access control, etc.), and a comprehensive evaluation showing InvSol outperforms state-of-the-art tools like InvCon, InvCon+, and Trace2Inv across multiple datasets. This approach enables earlier, safer deployment of contracts and provides a practical, auditable toolchain for developers and auditors in the blockchain ecosystem.
Abstract
Invariants are essential for ensuring the security and correctness of Solidity smart contracts, particularly in the context of blockchain's immutability and decentralized execution. This paper introduces InvSol, a novel framework for pre-deployment invariant generation tailored specifically for Solidity smart contracts. Unlike existing solutions, namely InvCon, InvCon+, and Trace2Inv, that rely on post-deployment transaction histories on Ethereum mainnet, InvSol identifies invariants before deployment and offers comprehensive coverage of Solidity language constructs, including loops. Additionally, InvSol incorporates custom templates to effectively prevent critical issues such as reentrancy, out-of-gas errors, and exceptions during invariant generation. We rigorously evaluate InvSol using a benchmark set of smart contracts and compare its performance with state-of-the-art solutions. Our findings reveal that InvSol significantly outperforms these tools, demonstrating its effectiveness in handling new contracts with limited transaction histories. Notably, InvSol achieves a 15% improvement in identifying common vulnerabilities compared to InvCon+ and is able to address certain crucial vulnerabilities using specific invariant templates, better than Trace2Inv.
