Provenance Verification of Smart Contracts: Analysing the Cost of Ensuring Authenticity over the Logic Hosted in Blockchain Networks
Abstract
:1. Introduction
2. Background
2.1. Verification
- Formal verification. Formal verification relies on the use of mathematical proofs to check the correctness of a system. The system is correct if it meets a given specification. Formal verification employs formal languages that allow the engineer to build a formal or mathematical model of a system which allows it to be later checked for correctness. This gave rise to model checking, as known as property checking, which is a method applied to check whether a system model meets a given specification. This process formulates a problem using some [8] logic with the goal of checking whether a particular model (namely, structure) satisfies a particular logical formula.
- Informal verification. This techniques relies on subjective reasoning that is typically driven by humans.
- Static verification. Static verification focuses on the analysis of a source code. Unlike a program or running code, the source code is a static asset. Therefore, static verification checks the structure of the code for syntactic correction and adherence to the norms and coding standards for a particular criticality level. Inspection of the code can check for coding conventions, bad practices exhibiting prohibited coding patterns, calculation of software metrics, or formal verification to detect, e.g., cycles in function invocations, failures in stop conditions, etc. Some articular examples of items that are often checked: a variable must have been defined before being used; or if a function declares to return an integer value, no other values (e.g., real or boolean values) should be returned.
- Dynamic verification. This process is performed during the execution of the program, i.e., over the running software. Dynamic verification is often called testing. It consists of actively checking the behavior of the code to find errors caused by some activity or by the repetitive execution of an activity or a set of activities (i.e., stress test). Testing can be applied to different scopes. The smallest scope includes a function or entity/class (namely unit test); larger scopes such as groups of classes and modules; the whole system, which also comprises integration tests with more than one module; or formal tests to define acceptance (functional or non-functional—e.g., performance).
2.2. Source-Code Verification
2.3. Smart Contract Verification through Block Verifiers
3. Approach
3.1. Life-Cycle Analysis
- Contract programming. This is the initial phase in which the contract is coded in some high-level programming language, e.g., Solidity.
- Executable/bytecode generation. The source code of a smart contract cannot run per se; so, an executable version of it needs to be created in order to be run by the nodes. For this reason, once the source code of a smart contract is fully programmed, it is compiled. Compilation generates a bytecode equivalent that is the executable version of the source code. The bytecode is the actual code that will eventually run in the blockchain network nodes. The bytecode is not human-readable; whereas the source code is.
- Deployment. The bytecode version of the smart contract must, then, be deployed to the distributed ledger. The deployment of a smart contract always results in the assignment of a particular address to it, which makes it uniquely identifiable. The address of a deployed smart contract plays a central role in the blockchain platform, as it is mandatory to refer to the corresponding smart contract that is running in the network. Smart contract deployment involves the execution of a transaction. It is important to note that there are differences between a transaction involving asset exchange and a transaction to deploy a contract; the latter does not require one to specify a recipient. Smart contracts are also stored in the blockchain; then, deploying a smart contract involves storing it in the global ledger and assigning it a unique address. Deployment involves transaction fees that are usually higher than other transaction types.
- Execution. Smart contracts execute when the predefined conditions expressed in their code hold. The execution of a smart contract may involve changing the state of the global ledger, as new transactions may be initiated and additional blocks can be generated to store transaction records.
- Verification. This phase is optional; it is explained in what follows.
3.2. Verification Types
3.3. Component Design
- Generator. Determining the temporal cost of the verification requires one to acquire a sufficient number of time samples that can be statistically representative. Each time sample corresponds to a particular smart contract verification occurrence. As block verifiers are able to distinguish whether successive smart contracts are the same, it is important to achieve an automatic generation of correct and unique smart contracts that will be identified as being unique. For this reason, the Executor component generates the unique smart contracts that are compiled and deployed to the blockchain. As shown in Figure 1, a smart contract can only be verified by a block verification service if it has been compiled and deployed. After being deployed, the blockchain infrastructure assigns a unique address to the running smart contract. Now, it can undergo a verification.
- Executor. This component manages the verification request triggers. After each smart contract is produced by the Generator, the Executor collects the verification parameters to be sent to the block verifiers. From the set of possible parameters, the bytecode address, the corresponding source code, and the original compiler options are obtained. The address corresponds to the unique reference of a given smart contract and points to the physical location of the running bytecode in the global ledger.
- Adaptor. This component acts as a bridge between the inherent middleware logic and the particular underlying block verifier that might want to be used. As different verification techniques are possible and a number of block verifiers are available, this component makes the middleware independent from the particular underlying block verifier. To change the verification service, only this component is affected and requires minimal updates to switch from, e.g., Polygonscan to Tenderly.
- Collector. The temporal data are gathered by this component, which includes the invocation instants and the response data from the verification as well as its associated timing. The component manages an internal storage for the collection of the obtained data.
3.4. Integration with Platform Alternatives through the Adaptor
- Etherscan. Etherscan [14] is among the most famous companies in the domain of blockchain technologies. It consists of a block explorer for the main network of Ethereum and also for its test networks, including analytic facilities.
- Polygonscan. Polygon [17] is a two-layer blockchain (also called sidechain) built on an Ethereum core. It incorporates a number of strategies for speeding up transactions and achieving lower fees. This makes it a parallel alternative to the Ethereum mainnet. Polygonscan is the block explorer that supports the interaction of users to access all transactions performed on the Polygon blockchain network.
- Sourcify. Sourcify.eth [16] is also among the very top smart contract verification providers. On top of its verification process, it also offers a testing playground to test the verification process; and a block explorer to allow users to check whether a smart contract is already verified or not.
- Tenderly. Tenderly [15] platform provides basic verification. An added value of Tenderly is that the visibility of the verified contracts can be configured. This means that the contract manager is able to restrict the visibility of the verificated source code to specific users. Controlling the visibility of the source code is a desirable characteristic in domains and systems that need to preserve the privacy over their source code, still providing some level of trustworthiness of that same code to the selected authorized third parties.
4. Implementation and Results
4.1. Experimental Settings
4.2. Results
4.2.1. Cached Scenario
4.2.2. Non-Cached Scenario
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
References
- Alchemy. Ethereum Statistics. 2022. Available online: https://www.alchemy.com/overviews/ethereum-statistics (accessed on 29 December 2023).
- Szabo, N. Smart Contracts. Technical Report, Nick Szabo’s Essays, Papers, and Concise Tutorials. 1997. Available online: https://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/idea.html (accessed on 29 December 2023).
- Szabo, N. The Idea of Smart Contracts. Available online: https://www.fon.hum.uva.nl/rob/Courses/InformationInSpeech/CDROM/Literature/LOTwinterschool2006/szabo.best.vwh.net/smart.contracts.html (accessed on 29 December 2023).
- Szabo, N. Smart Contracts: Formalizing and Securing Relationships on Public Networks. 1997, Volume 2. Available online: https://firstmonday.org/ojs/index.php/fm/article/download/548/469 (accessed on 29 December 2023).
- Gomez Gelvez, M. Explaining the DAO Exploit for Beginners in Solidity. 2016. Available online: https://medium.com/@MyPaoG/explaining-the-dao-exploit-for-beginners-in-solidity-80ee84f0d470 (accessed on 29 December 2023).
- Jyoti, A.; Chauhan, R.K. A blockchain and smart contract-based data provenance collection and storing in cloud environment. Wirel. Netw. 2022, 28, 1541–1562. [Google Scholar] [CrossRef]
- Dictionary, O.E. Available online: https://www.oed.com/ (accessed on 29 December 2023).
- Blair, J.; Johnson, R.H. Informal Logic: An Overview. Informal Log. 2000, 20, 93–107. [Google Scholar] [CrossRef]
- Qu, M.; Huang, X.; Chen, X.; Wang, Y.; Ma, X.; Liu, D. Formal Verification of Smart Contracts from the Perspective of Concurrency. In Proceedings of the International Conference on Smart Blockchain, Tokyo, Japan, 10–12 December 2018; Springer: Cham, Switzerland, 2018; pp. 32–43. [Google Scholar]
- Sun, T.; Yu, W. A formal verification framework for security issues of blockchain smart contracts. Electronics 2020, 9, 255. [Google Scholar] [CrossRef]
- Wang, D.; Huang, X.; Ma, X. Formal analysis of smart contract based on colored petri nets. IEEE Intell. Syst. 2020, 35, 19–30. [Google Scholar]
- He, Y.; Dong, H.; Wu, H.; Duan, Q. Formal Analysis of Reentrancy Vulnerabilities in Smart Contract Based on CPN. Electronics 2023, 12, 2152. [Google Scholar] [CrossRef]
- Ye, J.; Ma, L.; Lin, Y.; Xue, Y.; Sui, Y.; Peng, T. Clairvoyance: Cross-contract static analysis for detecting practical reentrancy vulnerabilities in smart contracts. In Proceedings of the IEEE/ACM 42nd International Conference on Software Engineering: Companion Proceedings (ICSE-Companion), Melbourne, VIC, Australia, 21–25 September 2020; pp. 274–275. [Google Scholar]
- Ethereum Foundation. Etherscan. Available online: https://etherscan.io/ (accessed on 29 December 2023).
- Tenderly. Tenderly Node. Available online: https://tenderly.co/ (accessed on 29 December 2023).
- Sourcify.eth. Available online: https://sourcify.dev/ (accessed on 29 December 2023).
- Polygon Labs. Polygon. Available online: https://polygon.technology/ (accessed on 29 December 2023).
- Chirivella-Ciruelos, A.M.; García-Valls, M. Automating the verification of smart contracts in blockchain networks for improving security. In Proceedings of the 2023 49th Euromicro Conference on Software Engineering and Advanced Applications (SEAA), Durres, Albania, 6–8 September 2023. [Google Scholar]
- Ma, P.; He, N.; Huang, Y.; Wang, H.; Luo, X. Abusing the Ethereum Smart Contract Verification Services for Fun and Profit. arXiv 2023, arXiv:2307.00549. [Google Scholar]
- Dia, B.; Ivaki, N.; Laranjeiro, N. An Empirical Evaluation of the Effectiveness of Smart Contract Verification Tools. In Proceedings of the 26th IEEE Pacific Rim International Symposium on Dependable Computing (PRDC), Perth, Australia, 1–4 December 2021; pp. 17–26. [Google Scholar]
- Frank, J.; Aschermann, C.; Holz, T. ETHBMC: A Bounded Model Checker for Smart Contracts. In Proceedings of the 29th USENIX Security Symposium, Boston, MA, USA, 12–14 August 2020. [Google Scholar]
- Linoy, S.; Ray, S.; Stakhanova, N. EtherProv: Provenance-Aware Detection, Analysis, and Mitigation of Ethereum Smart Contract Security Issues. In Proceedings of the 2021 IEEE International Conference on Blockchain (Blockchain), Melbourne, Australia, 6–8 December 2021; pp. 1–10. [Google Scholar]
- Sun, L.S.; Bai, X.; Zhang, C.; Li, Y.; Zhang, Y.B.; Guo, W.Q. BSTProv: Blockchain-Based Secure and Trustworthy Data Provenance Sharing. Electronics 2022, 11, 1489. [Google Scholar] [CrossRef]
- Yin, F.; Fu, Z. A Data Provenance Scheme Based on Blockchain for Internet of Things. In Proceedings of the 2022 2nd International Conference on Computer Science and Blockchain (CCSB), Wuhan, China, 28–30 October 2022; pp. 42–45. [Google Scholar]
- Geng, Z.; Cao, Y.; Li, J.; Han, Y. Novel blockchain transaction provenance model with graph attention mechanism. Expert Syst. Appl. 2022, 209, 118411. [Google Scholar] [CrossRef]
- Marx, S. Verifying Contract Source Code. 2018. Available online: https://programtheblockchain.com/posts/2018/01/16/verifying-contract-source-code/ (accessed on 29 December 2023).
- Benet, J. IPFS—Content Addressed, Versioned, P2P File System. arXiv 2014, arXiv:1407.3561. [Google Scholar]
- @minimalsm. Verifying Smart Contracts. 2023. Available online: https://ethereum.org/en/developers/docs/smart-contracts/verifying/ (accessed on 29 December 2023).
- Lukic, M. A Guide to Smart Contract Verification. 2022. Available online: https://blog.tenderly.co/guide-to-smart-contract-verification-methods/ (accessed on 29 December 2023).
- Hardhat Network. Ethereum Development Environment for Professionals. Available online: https://hardhat.org/hardhat-network/docs/reference (accessed on 29 December 2023).
- Ethereum Foundation. Ethereum. REMIX IDE. Available online: https://remix.ethereum.org (accessed on 29 December 2023).
Name | Lines of Code | Bytecode Size |
---|---|---|
UserAM | 37 | 4583 Bytes |
ContextHandler | 24 | 2019 Bytes |
Policy1 | 17 | 1916 Bytes |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2023 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
García-Valls, M.; Chirivella-Ciruelos, A.M. Provenance Verification of Smart Contracts: Analysing the Cost of Ensuring Authenticity over the Logic Hosted in Blockchain Networks. Information 2024, 15, 24. https://doi.org/10.3390/info15010024
García-Valls M, Chirivella-Ciruelos AM. Provenance Verification of Smart Contracts: Analysing the Cost of Ensuring Authenticity over the Logic Hosted in Blockchain Networks. Information. 2024; 15(1):24. https://doi.org/10.3390/info15010024
Chicago/Turabian StyleGarcía-Valls, Marisol, and Alejandro M. Chirivella-Ciruelos. 2024. "Provenance Verification of Smart Contracts: Analysing the Cost of Ensuring Authenticity over the Logic Hosted in Blockchain Networks" Information 15, no. 1: 24. https://doi.org/10.3390/info15010024
APA StyleGarcía-Valls, M., & Chirivella-Ciruelos, A. M. (2024). Provenance Verification of Smart Contracts: Analysing the Cost of Ensuring Authenticity over the Logic Hosted in Blockchain Networks. Information, 15(1), 24. https://doi.org/10.3390/info15010024