Blockchain consolidated as a disruptive technology across various domains and gained widespread adoption in the last decade. It enforces data integrity and traceability by storing data in an immutable chain of blocks, each linked to the previous one with a cryptographic hash value. Smart contracts enable decentralized applications by enforcing logic directly on the blockchain, eliminating the need for trusted intermediaries or central authorities. Despite their rapid adoption, immutability makes their development and maintenance particularly challenging, and current approaches provide limited support for continuous assurance after deployment. Existing research focused on security vulnerabilities and protocol design, with limited attention to lifecycle management, post-deployment maintenance, and empirical characterization of development practices. These characteristics require novel approaches that enable smart contracts to be observed, tested, and evolved without violating the constraints imposed on the chain. In this context, Digital Twin offers a promising paradigm for mirroring and analyzing smart contract behavior in a controlled, off-chain environment. Engineering the development process for smart contracts will help developers reduce errors and improve the lifecycle in blockchain-based applications. This thesis investigates how to support the continuous monitoring, testing, and controlled evolution of smart contracts throughout their lifecycle. The thesis introduces SmartCoach, a framework inspired by the Digital Twin paradigm that establishes a synchronized virtual counterpart of smart contracts. SmartCoach monitors deployed contracts, mirrors their state and behavior, executes test scenarios in a virtual environment, and supports controlled evolution through proxy- based upgrade mechanisms. By integrating existing tools for static and dynamic analysis, SmartCoach helps developers identify vulnerabilities, validate fixes, and safely evolve contracts. To address the lack of large-scale empirical evidence on how smart contracts are actually designed in practice, the thesis also presents a comprehensive study of micro patterns in Solidity smart contracts, grounded in the observation that recurring coding idioms influence structure, security, and maintainability. Using a custom detection pipeline, more than two million verified contracts across eight different EVM- compatible blockchains were analyzed. The study identifies the prevalence, co-occurrence, and evolution of micro patterns, providing a vocabulary for understanding structural properties of decentralized codebases. Together, the proposed framework and empirical findings bridge the gap between software engineering and blockchain research. They demonstrate how lifecycle-aware engineering approaches and data-driven insights can improve the reliability and maintainability of smart contracts. The thesis also discusses limitations and open challenges, including the development of fully autonomous contract evolution and the validation of detection precision, outlining directions toward more robust, maintainable, and future-proof smart contract ecosystems.
Engineering the Smart Contract Lifecycle through Digital Twins and Empirical Analysis
RUSCHIONI, LUCA
2026-06-23
Abstract
Blockchain consolidated as a disruptive technology across various domains and gained widespread adoption in the last decade. It enforces data integrity and traceability by storing data in an immutable chain of blocks, each linked to the previous one with a cryptographic hash value. Smart contracts enable decentralized applications by enforcing logic directly on the blockchain, eliminating the need for trusted intermediaries or central authorities. Despite their rapid adoption, immutability makes their development and maintenance particularly challenging, and current approaches provide limited support for continuous assurance after deployment. Existing research focused on security vulnerabilities and protocol design, with limited attention to lifecycle management, post-deployment maintenance, and empirical characterization of development practices. These characteristics require novel approaches that enable smart contracts to be observed, tested, and evolved without violating the constraints imposed on the chain. In this context, Digital Twin offers a promising paradigm for mirroring and analyzing smart contract behavior in a controlled, off-chain environment. Engineering the development process for smart contracts will help developers reduce errors and improve the lifecycle in blockchain-based applications. This thesis investigates how to support the continuous monitoring, testing, and controlled evolution of smart contracts throughout their lifecycle. The thesis introduces SmartCoach, a framework inspired by the Digital Twin paradigm that establishes a synchronized virtual counterpart of smart contracts. SmartCoach monitors deployed contracts, mirrors their state and behavior, executes test scenarios in a virtual environment, and supports controlled evolution through proxy- based upgrade mechanisms. By integrating existing tools for static and dynamic analysis, SmartCoach helps developers identify vulnerabilities, validate fixes, and safely evolve contracts. To address the lack of large-scale empirical evidence on how smart contracts are actually designed in practice, the thesis also presents a comprehensive study of micro patterns in Solidity smart contracts, grounded in the observation that recurring coding idioms influence structure, security, and maintainability. Using a custom detection pipeline, more than two million verified contracts across eight different EVM- compatible blockchains were analyzed. The study identifies the prevalence, co-occurrence, and evolution of micro patterns, providing a vocabulary for understanding structural properties of decentralized codebases. Together, the proposed framework and empirical findings bridge the gap between software engineering and blockchain research. They demonstrate how lifecycle-aware engineering approaches and data-driven insights can improve the reliability and maintainability of smart contracts. The thesis also discusses limitations and open challenges, including the development of fully autonomous contract evolution and the validation of detection precision, outlining directions toward more robust, maintainable, and future-proof smart contract ecosystems.I documenti in IRIS sono protetti da copyright e tutti i diritti sono riservati, salvo diversa indicazione.


