Abstract
Smart contracts challenge the existing, highly efficient techniques applied in symbolic model checking of software by their unique traits not present in standard programming models. Still, the majority of reported smart contract verification projects either reuse off-the-shelf model checking tools resulting in inefficient and even unsound models, or apply generic solutions that typically require highly-trained human intervention. In this paper, we present the solution adopted in the formal analysis engine of the official Solidity compiler. We focus on the accurate modeling of the central aspects of smart contracts. For that, we specify purpose-built rules defined in the expressive and highly automatable logic of constrained Horn clauses, which are readily supported by an effective solving infrastructure for establishing sound safety proofs or finite-length counterexamples. We evaluated our approach on an extensive set of smart contracts recently deployed in the Ethereum platform. The reported results show that the approach is able to prove correctness and discover bugs in significantly more contracts than comparable publicly available systems.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
Solidity official documentation is available at https://solidity.readthedocs.io.
- 2.
Available at https://github.com/usi-verification-and-security/solc.
- 3.
References
Etherscan. https://etherscan.io
Smtchecker documentation. https://solidity.readthedocs.io/en/v0.6.6/security-considerations.html#formal-verification
Solidity documentation. https://solidity.readthedocs.io
theDAO. https://etherscan.io/address/0xbb9bc244d798123fde783fcc1c72d3bb8c189413
Vyper documentation. https://vyper.readthedocs.io
Parity security alert (2017). https://www.parity.io/security-alert-2/
Albert, E., Correas, J., Gordillo, P., Román-Díez, G., Rubio, A.: SAFEVM: a safety verifier for Ethereum smart contracts. In: Proceedings of the ISSTA 2019, pp. 386–389 (2019)
Alt, L., Reitwiessner, C.: SMT-based verification of solidity smart contracts. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11247, pp. 376–388. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03427-6_28
Barrett, K., Cassels, B., Haahr, P., Moon, D.A., Playford, K., Withington, P.T.: A monotonic superclass linearization for Dylan. In: Proceedings of the OOPSLA 1996, pp. 69–82 (1996)
Bhargavan, K., et al.: Formal verification of smart contracts: short paper. In: Proceedings of the PLAS 2016, pp. 91–96 (2016)
Bjørner, N., Gurfinkel, A., McMillan, K., Rybalchenko, A.: Horn clause solvers for program verification. In: Beklemishev, L.D., Blass, A., Dershowitz, N., Finkbeiner, B., Schulte, W. (eds.) Fields of Logic and Computation II. LNCS, vol. 9300, pp. 24–51. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-23534-9_2
Blass, A., Gurevich, Y.: Existential fixed-point logic. In: Börger, E. (ed.) Computation Theory and Logic. LNCS, vol. 270, pp. 20–36. Springer, Heidelberg (1987). https://doi.org/10.1007/3-540-18170-9_151
Blicha, M., Hyvärinen, A.E.J., Marescotti, M., Sharygina, N.: A cooperative parallelization approach for property-directed k-induction. In: Beyer, D., Zufferey, D. (eds.) VMCAI 2020. LNCS, vol. 11990, pp. 270–292. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-39322-9_13
Bradley, A.R.: SAT-based model checking without unrolling. In: Jhala, R., Schmidt, D. (eds.) VMCAI 2011. LNCS, vol. 6538, pp. 70–87. Springer, Heidelberg (2011). https://doi.org/10.1007/978-3-642-18275-4_7
ConsenSys: Mythril (2018). https://github.com/ConsenSys/mythril
Erfurt, D., Lundfall, M., Hildenbrandt, E., Livnev, L.: Klab (2020). https://github.com/dapphub/klab
Ethereum Foundation: Ethereum: a secure decentralised generalised transaction ledger (2018). http://ethereum.github.io/yellowpaper/paper.pdf
Ethereum Foundation: Solidity compiler (2018). https://github.com/ethereum/solidity
Ethereum Foundation: HEVM Ethereum evaluator (2020). https://github.com/dapphub/dapptools/tree/master/src/hevm
Feist, J., Grieco, G., Groce, A.: Slither: a static analysis framework for smart contracts. arXiv e-prints arXiv:1908.09878, August 2019
kframework: Solidity semantics (2018). https://github.com/kframework/solidity-semantics
kframework: Vyper semantics (2018). https://github.com/kframework/vyper-semantics
Gurfinkel, A., Kahsai, T., Komuravelli, A., Navas, J.A.: The SeaHorn verification framework. In: Kroening, D., Păsăreanu, C.S. (eds.) CAV 2015. LNCS, vol. 9206, pp. 343–361. Springer, Cham (2015). https://doi.org/10.1007/978-3-319-21690-4_20
Hajdu, Á., Jovanović, D.: SMT-friendly formalization of the solidity memory model. ESOP 2020. LNCS, vol. 12075, pp. 224–250. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-44914-8_9
Hajdu, Á., Jovanovic, D.: solc-verify: a modular verifier for solidity smart contracts. CoRR abs/1907.04262 (2019)
Hildenbrandt, E., et al.: KEVM: a complete formal semantics of the Ethereum virtual machine. In: Proceedings of the CSF 2018, pp. 204–217 (2018)
Hoare, C.A.R.: An axiomatic basis for computer programming. Commun. ACM 12(10), 576–580 (1969)
Kalra, S., Goel, S., Dhawan, M., Sharma, S.: ZEUS: analyzing safety of smart contracts. In: Proceedings of the NDSS 2018. The Internet Society (2018)
Komuravelli, A., Gurfinkel, A., Chaki, S.: SMT-based model checking for recursive programs. Formal Methods Syst. Des. 48(3), 175–205 (2016). https://doi.org/10.1007/s10703-016-0249-4
Lahiri, S.K., Chen, S., Wang, Y., Dillig, I.: Formal specification and verification of smart contracts for azure blockchain. CoRR abs/1812.08829 (2018)
Luu, L., Chu, D.H., Olickel, H., Saxena, P., Hobor, A.: Making smart contracts smarter. In: Proceedings of the CCS 2016, pp. 254–269. ACM (2016)
Marescotti, M., Blicha, M., Hyvärinen, A.E.J., Asadi, S., Sharygina, N.: Computing exact worst-case gas consumption for smart contracts. In: Margaria, T., Steffen, B. (eds.) ISoLA 2018. LNCS, vol. 11247, pp. 450–465. Springer, Cham (2018). https://doi.org/10.1007/978-3-030-03427-6_33
Marescotti, M., Gurfinkel, A., Hyvärinen, A.E.J., Sharygina, N.: Designing parallel PDR. In: Stewart, D., Weissenbacher, G. (eds.) Proceedings of the FMCAD 2017, pp. 156–163. IEEE (2017)
Mossberg, M., et al.: Manticore: a user-friendly symbolic execution framework for binaries and smart contracts. CoRR abs/1907.03890 (2019)
de Moura, L., Bjørner, N.: Z3: an efficient SMT solver. In: Ramakrishnan, C.R., Rehof, J. (eds.) TACAS 2008. LNCS, vol. 4963, pp. 337–340. Springer, Heidelberg (2008). https://doi.org/10.1007/978-3-540-78800-3_24
Nikolic, I., Kolluri, A., Sergey, I., Saxena, P., Hobor, A.: Finding the greedy, prodigal, and suicidal contracts at scale. CoRR abs/1802.06038 (2018)
Permenev, A., Dimitrov, D., Tsankov, P., Drachsler-Cohen, D., Vechev, M.: VerX: safety verification of smart contracts. In: Proceedings of the IEEE SSP 2020 (2020, to appear)
Rosu, G., Serbanuta, T.F.: An overview of the K semantic framework. J. Log. Algebraic Program. 79(6), 397–434 (2010)
Tsankov, P., Dan, A., Drachsler-Cohen, D., Gervais, A., Bünzli, F., Vechev, M.: Securify: practical security analysis of smart contracts. In: Proceedings of the CCS 2018, pp. 67–82. ACM (2018)
Why3: Why3 (2018). http://why3.lri.fr/
Acknowledgements
The authors would like to thank Enrique Fynn and Fernando Pedone for their kind assistance in providing us with the addresses for the deployed Ethereum contracts used in the experiments. This work is partially supported by the SNSF grant 200021_185031 and by the ERC grant FP7-617805.
Author information
Authors and Affiliations
Corresponding authors
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
Cite this paper
Marescotti, M., Otoni, R., Alt, L., Eugster, P., Hyvärinen, A.E.J., Sharygina, N. (2020). Accurate Smart Contract Verification Through Direct Modelling. In: Margaria, T., Steffen, B. (eds) Leveraging Applications of Formal Methods, Verification and Validation: Applications. ISoLA 2020. Lecture Notes in Computer Science(), vol 12478. Springer, Cham. https://doi.org/10.1007/978-3-030-61467-6_12
Download citation
DOI: https://doi.org/10.1007/978-3-030-61467-6_12
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-61466-9
Online ISBN: 978-3-030-61467-6
eBook Packages: Computer ScienceComputer Science (R0)