Specification Mining for Smart Contracts with Trace Slicing and Predicate Abstraction (2403.13279v1)
Abstract: Smart contracts are computer programs running on blockchains to implement Decentralized Applications.The absence of contract specifications hinders routine tasks, such as contract understanding and testing. Inthis work, we propose a specification mining approach to infer contract specifications from past transactionhistories. Our approach derives high-level behavioral automata of function invocations, accompanied byprogram invariants statistically inferred from the transaction histories. We implemented our approach as toolSmConand evaluated it on eleven well-studied Azure benchmark smart contracts and six popular real-worldDApp smart contracts. The experiments show thatSmConmines reasonably accurate specifications that canbe used to facilitate DApp understanding and development in terms of document maintenance and test suite improvement.
- 2015. EIP-20: A standard interface for tokens. https://eips.ethereum.org/EIPS/eip-20.
- 2017. CryptoPunks: Collectible Characters on the Ethereum Blockchain. https://github.com/larvalabs/cryptopunks/tree/master/test.
- 2021. Daikon. http://plse.cs.washington.edu/daikon/. The Daikon invariant detector.
- 2023. CryptoPunks. https://www.larvalabs.com/cryptopunks/.
- 2023. DAppRadar. https://dappradar.com/.
- 2023. Etherscan. https://etherscan.io.
- 2023. QuickNode. https://www.quicknode.com/.
- 2024a. Bug report in defective-component-counter smart contract. https://github.com/Azure-Samples/blockchain/issues/278.
- 2024b. Bug report in digital-locker smart contract. https://github.com/Azure-Samples/blockchain/issues/279.
- 2024c. Bug report in hello-blockchain smart contract. https://github.com/Azure-Samples/blockchain/issues/280.
- 2024d. Bug report in simple-marketplace smart contract. https://github.com/Azure-Samples/blockchain/issues/281.
- 2024. InvConPlus. https://github.com/Franklinliu/InvConPlus-Tool.
- Automata learning through counterexample guided abstraction refinement. In International Symposium on Formal Methods. Springer, 10–27.
- Dana Angluin. 1987. Learning regular sets from queries and counterexamples. Information and computation 75, 2 (1987), 87–106.
- Behavioral simulation for smart contracts. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. 470–486.
- Leveraging existing instrumentation to automatically infer invariant-constrained models. In Proceedings of the 19th ACM SIGSOFT symposium and the 13th European conference on Foundations of software engineering. 267–277.
- Alan W Biermann and Jerome A Feldman. 1972. On the synthesis of finite-state machines from samples of their behavior. IEEE transactions on Computers 100, 6 (1972), 592–597.
- Automated abstraction refinement for model checking large state spaces using SAT based conflict analysis. In International Conference on Formal Methods in Computer-Aided Design. Springer, 33–51.
- TokenScope: Automatically detecting inconsistent behaviors of cryptocurrency tokens in ethereum. In Proceedings of the 2019 ACM SIGSAC conference on computer and communications security. 1503–1520.
- Kwang-Ting Cheng and Avinash S Krishnakumar. 1993. Automatic functional test generation using the extended finite state machine model. In 30th ACM/IEEE Design Automation Conference. IEEE, 86–91.
- Counterexample-guided abstraction refinement. In International Conference on Computer Aided Verification. Springer, 154–169.
- Automated abstractions for contract validation. IEEE Transactions on Software Engineering 38, 1 (2010), 141–162.
- Colin De la Higuera. 2010. Grammatical inference: learning automata and grammars. Vol. 24. Cambridge University Press. 291–293 pages.
- Dicether 2018. Dicether: A Secure dice game. https://dicether.github.io/paper/paper.pdf.
- Empirical review of automated analysis tools on 47,587 Ethereum smart contracts. In Proceedings of the ACM/IEEE 42nd International conference on software engineering. 530–541.
- Slither: a static analysis framework for smart contracts. In 2019 IEEE/ACM 2nd International Workshop on Emerging Trends in Software Engineering for Blockchain (WETSEB). IEEE, 8–15.
- E Mark Gold. 1967. Language identification in the limit. Information and control 10, 5 (1967), 447–474.
- Susanne Graf and Hassen Saidi. 1997. Construction of abstract state graphs with PVS. In Computer Aided Verification, Vol. 97. 72–83.
- Specification mining for smart contracts with automatic abstraction tuning. arXiv preprint arXiv:1807.07822 (2018).
- ContractFuzzer: Fuzzing Smart Contracts for Vulnerability Detection. In Proceedings of the 33rd ACM/IEEE International Conference on Automated Software Engineering. ACM, 259–269.
- Semantic understanding of smart contracts: Executable operational semantics of Solidity. In 2020 IEEE Symposium on Security and Privacy (SP). IEEE, 1695–1712.
- Automatic mining of specifications from invocation traces and method invariants. In Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering. 178–189.
- Results of the Abbadingo one DFA learning competition and a new evidence-driven state merging algorithm. In International Colloquium on Grammatical Inference. Springer, 1–12.
- Synergizing specification miners through model fissions and fusions (t). In 2015 30th IEEE/ACM International Conference on Automated Software Engineering (ASE). IEEE, 115–125.
- Tien-Duy B Le and David Lo. 2018. Deep specification mining. In Proceedings of the 27th ACM SIGSOFT International Symposium on Software Testing and Analysis. 106–117.
- Mining parametric specifications. In Proceedings of the 33rd International Conference on Software Engineering. 591–600.
- Securing smart contract with runtime validation. In Proceedings of the 41st ACM SIGPLAN Conference on Programming Language Design and Implementation. 438–453.
- Learning Contract Invariants Using Reinforcement Learning. In Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering. 1–11.
- Ye Liu and Yi Li. 2022. InvCon: A Dynamic Invariant Detector for Ethereum Smart Contracts. In Proceedings of the 37th IEEE/ACM International Conference on Automated Software Engineering (ASE).
- ModCon: A Model-Based Testing Platform for Smart Contracts. In Proceedings of the 28th ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering (FSE).
- Towards automated verification of smart contract fairness. In Proceedings of the 28th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering. 666–677.
- Automated Invariant Generation for Solidity Smart Contracts. arXiv preprint arXiv:2401.00650 (2024).
- David Lo and Siau-Cheng Khoo. 2006. QUARK: Empirical assessment of automaton-based specification miners. In 2006 13th Working Conference on Reverse Engineering. IEEE, 51–60.
- Learning extended FSA from software: An empirical assessment. Journal of Systems and Software 85, 9 (2012), 2063–2076.
- Automatic generation of software behavioral models. In Proceedings of the 30th international conference on Software engineering. 501–510.
- Anastasia Mavridou and Aron Laszka. 2018a. Designing secure ethereum smart contracts: A finite state machine based approach. In International Conference on Financial Cryptography and Data Security. Springer, 523–540.
- Anastasia Mavridou and Aron Laszka. 2018b. Tool demonstration: FSolidM for designing secure Ethereum smart contracts. In International conference on principles of security and trust. Springer, 270–277.
- VeriSolid: Correct-by-design smart contracts for Ethereum. In International Conference on Financial Cryptography and Data Security. Springer, 446–465.
- Recurrent neural network based language model.. In Interspeech, Vol. 2. Makuhari, 1045–1048.
- MoonCatRescue 2022. MoonCatRescue. https://dappradar.com/ethereum/games/mooncatrescue.
- Leonardo de Moura and Nikolaj Bjørner. 2008. Z3: An efficient SMT solver. In International conference on Tools and Algorithms for the Construction and Analysis of Systems. Springer, 337–340.
- Satoshi Nakamoto. 2008. Bitcoin: A peer-to-peer electronic cash system. Decentralized Business Review (2008), 21260.
- Verx: Safety verification of smart contracts. In 2020 IEEE symposium on security and privacy (SP). IEEE, 1661–1677.
- Attacking the DeFi ecosystem with flash loans for fun and profit. In International Conference on Financial Cryptography and Data Security. Springer, 3–32.
- SuperRare 2022. SuperRare. https://www.dapp.com/app/SuperRare.
- SolType: refinement types for arithmetic overflow in solidity. Proceedings of the ACM on Programming Languages 6, POPL (2022), 1–29.
- Inferring extended finite state machine models from software executions. Empirical Software Engineering 21, 3 (2016), 811–853.
- VULTRON: Catching Vulnerable Smart Contracts Once and for All. In Proceedings of the 41st International Conference on Software Engineering: New Ideas and Emerging Results (ICSE-NIER). IEEE Press, 1–4.
- SMARTINV: Multimodal Learning for Smart Contract Invariant Inference. In 2024 IEEE Symposium on Security and Privacy (SP). IEEE Computer Society, 126–126.
- Formal verification of workflow policies for smart contracts in azure blockchain. In Working Conference on Verified Software: Theories, Tools, and Experiments. Springer, 87–106.
- Gavin Wood. 2014. Ethereum: A Secure Decentralised Generalised Transaction Ledger. Ethereum project yellow paper 151 (2014), 1–32.