Intelligent contract Temporal Property monitoring method and system based on dynamic instrumentation
Through the Temporal Property monitoring method of smart contracts based on dynamic instrumentation, the problem of uninitial resource reading vulnerability detection in smart contracts is solved, efficient and accurate monitoring is achieved, and the security and reliability of smart contracts are improved.
Patent Information
- Application Number
- CN202411302020.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-18
- Publication Date
- 2025-01-10
- Estimated Expiration
- 2044-09-18
AI Technical Summary
The existing technology is difficult to effectively detect and monitor uninitialized global resource reading vulnerabilities in smart contracts, especially in complex runtime scenarios and cross-contract calls, resulting in high false alarm and missed alarm rates and lack of flexible monitoring tools. .
Adopting the Temporal Property monitoring method of smart contracts based on dynamic instrumentation, the LTL conversion algorithm is optimized by designing the Temporal Property Specification language (TPSL), realizing the Vector Clock mechanism and resource state tracking, and providing multi-layer Mapping traceability SHA3 instruction cache and Slot inverse The analysis system combines lightweight EVM modification scheme and state reconstruction algorithm to achieve efficient and accurate monitoring of smart contracts.
It significantly improves the accuracy and efficiency of monitoring, can handle complex timing logic and state constraints, reduces false alarms and missed alarm rates, enhances the processing ability of complex data structures, and improves the security and reliability of smart contracts.
Smart Images

Figure CN119293793A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of blockchain technology, specifically to a method and system for monitoring TemporalProperty in smart contracts based on dynamic instrumentation. Background Technology
[0002] Smart contracts are a core component of blockchain technology. Uninitialized global resource access is a common and serious security vulnerability that can lead to abnormal contract behavior, asset loss, and other severe consequences. This vulnerability typically occurs in the following situations: 1. Contract developers forget to initialize certain global variables. 2. During complex contract interactions, the initialization of certain resources is omitted. 3. Incorrect assumptions about the state of other contracts during cross-contract calls.
[0003] For the above problems, common solutions include: 1. Using static analysis methods to detect potential vulnerabilities in smart contracts: However, this approach struggles to handle complex runtime scenarios, especially those involving cross-contract calls. It may generate numerous false positives or false negatives, requiring manual verification. 2. Using general-purpose formal tools supplemented by manual verification to prove the correctness of smart contracts. This approach requires significant manual effort to build formal models. The verification process is complex and requires specialized knowledge. It is difficult to scale to large and complex contracts. 3. Implementing this through variable instrumentation, commonly found in general-purpose programming languages. The monitoring logic in this approach is usually hard-coded, lacking flexibility. There are currently no runtime monitoring tools specifically for smart contracts. 4. Using Specification languages, but this approach has limited expressive power and cannot describe temporary properties. Integration with the actual execution environment is also low. Summary of the Invention
[0004] To address the shortcomings of existing technologies, the present invention aims to provide a method and system for monitoring the Temporal Property of smart contracts based on dynamic instrumentation, thereby solving the problems mentioned in the background. The present invention achieves a highly efficient, accurate, and non-intrusive security detection method by implementing the Vector Clock mechanism and resource status tracking at the Ethereum Virtual Machine (EVM) level.
[0005] To achieve the above objectives, the present invention is implemented through the following technical solution: a smart contract Temporal Property monitoring method based on dynamic instrumentation, the monitoring method including the following: designing a temporal property specification language for smart contracts, optimizing the LTL conversion algorithm, and implementing dynamic monitoring of variables appearing in the specification. The method implements the Vector Clock mechanism and resource status tracking at the Ethereum Virtual Machine (EVM) level, and provides a multi-layer mapping traceability SHA3 instruction cache and slot reverse analysis system.
[0006] Furthermore, the temporal property specification language supports the expression of complex temporal logic and state constraints, and has built-in support for special data structures such as mapping; the LTL conversion algorithm converts the specification into linear temporal logic (LTL) and generates efficient and executable monitoring logic.
[0007] Furthermore, the SHA3 instruction cache and slot reverse analysis system is used to implement intelligent caching of EVM SHA3 instructions, support recursive tracing and analysis of multi-level mappings, and provide real-time monitoring capabilities for complex data structures.
[0008] Furthermore, it also includes developing a lightweight EVM modification scheme to achieve efficient tracking of key state variables; and designing a state reconstruction algorithm to support the verification of complex temporal properties.
[0009] A monitoring system as described in the monitoring method above includes the following components: a TPSL parser, an LTL converter, a multi-layer mapping analysis system, and a dynamic variable monitoring framework. The TPSL parser is the system's entry point, responsible for processing user-defined temporal property specifications. The LTL converter receives the internal representation generated by the TPSL parser and converts it into executable monitoring logic. The multi-layer mapping analysis system handles complex multi-layered nested mapping structures in smart contracts. The dynamic variable monitoring framework monitors changes in key state variables in real time during smart contract execution.
[0010] Furthermore, the workflow of the TPSL parser is as follows:
[0011] S1-1, Lexical Analysis: Decompose the TPSL specification text into a series of tokens;
[0012] S1-2, Syntax Analysis: Based on predefined TPSL syntax rules, the token sequence is constructed into an Abstract Syntax Tree (AST);
[0013] S1-3, Semantic Analysis: Perform semantic checks on the AST to ensure type consistency and reference integrity;
[0014] S1-4 Internal Representation Generation: Convert the verified AST into an intermediate representation used internally by the system.
[0015] Furthermore, the conversion steps of the LTL converter include:
[0016] S2-1, LTL Formula Conversion: Convert the internal representation of TPSL into a standard linear sequential logic (LTL) formula;
[0017] S2-2, Büchi automaton generation: Transform the LTL formula into a Büchi automaton using an optimized algorithm;
[0018] S2-3, Monitoring Automaton Optimization: Optimize and simplify the generated Büchi automaton;
[0019] S2-4, Executable monitoring logic generation: Converts the optimized automaton into efficient monitoring code that can be executed in a smart contract environment.
[0020] Furthermore, the core functions of the multi-layer mapping analysis system include:
[0021] S3-1, EVM Modification: Modify the EVM to capture and record the input and output of SHA3 instructions;
[0022] S3-2, SHA3 instruction cache: Implements a multi-layer cache mechanism to store the input and output relationships of SHA3 instructions;
[0023] S3-3, Slot Analysis: Analyze the read and write operations of the storage slot and track the updates of the mapping;
[0024] S3-4, Recursive Tracing: Implements a recursive tracing algorithm for multi-level nested mappings;
[0025] S3-5, State View Construction: Based on the collected information, construct and maintain a global structural view of the mapping.
[0026] Furthermore, the main components of the dynamic variable monitoring framework include:
[0027] S4-1, Code Instrumentation: Analyze the source code or bytecode of smart contracts and insert monitoring logic at key points;
[0028] S4-2, Runtime Monitor: Collects information on changes in state variables during contract execution;
[0029] S4-3, State Reconstruction: Dynamically reconstruct the complete state of the contract based on the collected information;
[0030] S4-4, Property Validation: Validate predefined temporal properties using the reconstructed state information.
[0031] Furthermore, it includes an integrated verification environment, which consolidates all components into a unified system to provide an end-to-end verification solution. The workflow is as follows:
[0032] S5-1, User Input: Through a graphical interface or command-line interface, the user inputs the TPSL specification and the smart contract to be verified.
[0033] S5-2, Preprocessing: TPSL parser processing specifications, LTL converter generation monitoring logic;
[0034] S5-3 Contract Analysis: The multi-layered mapping analysis system performs static analysis on contracts;
[0035] S5-4, Dynamic Monitoring: Deploy a smart contract containing monitoring logic, and the dynamic variable monitoring framework begins real-time monitoring;
[0036] S5-5. Results Analysis: Collect and analyze the verification results, and generate a detailed report;
[0037] S5-6. Feedback: Show the user the verification results, including whether the specified temporal properties were violated, and related details.
[0038] The beneficial effects of this invention are:
[0039] 1. This monitoring method and system can improve expressiveness and accuracy: TPSL allows developers to accurately express complex temporal attributes and state constraints. It significantly reduces ambiguity in specification descriptions and improves the accuracy of verification.
[0040] 2. This monitoring method and system enhances the ability to handle complex data structures: the multi-layer mapping analysis system makes monitoring of deeply nested data structures possible, overcoming the limitations of existing technologies in handling complex mappings. Furthermore, it improves execution efficiency; the optimized LTL transformation algorithm generates more efficient monitoring logic; and the SHA3 instruction caching mechanism reduces redundant calculations, improving runtime performance.
[0041] 3. This monitoring method and system enhance dynamic analysis capabilities: the dynamic variable monitoring framework provides in-depth insights into contract runtime behavior; it supports real-time verification of complex temporary properties. It reduces false positives and false negatives: combining static analysis and dynamic monitoring significantly improves verification accuracy; multi-layer mapping analysis reduces false positives caused by data structure complexity. Attached Figure Description
[0042] Figure 1 This is a diagram of the overall architecture of the present invention;
[0043] Figure 2 This is a diagram of the mapping analysis system architecture of the present invention. Detailed Implementation
[0044] To make the technical means, creative features, objectives and effects of this invention easier to understand, the invention will be further described below in conjunction with specific embodiments.
[0045] Please see Figures 1 to 2 This invention provides the following technical solution: a method for monitoring the Temporal Property of smart contracts based on dynamic instrumentation. The basic scheme and idea of this method are as follows:
[0046] 1. Temporal Property Specification Language (TPSL) for smart contracts:
[0047] Design a high-level specification language tailored to the characteristics of smart contracts; support the expression of complex temporal logic and state constraints; and provide built-in support for special data structures such as mappings.
[0048] 2. Optimized LTL conversion algorithm:
[0049] Develop a dedicated LTL-to-monitoring automaton conversion algorithm for smart contracts; considering EVM characteristics, generate efficient and executable monitoring logic.
[0050] 3. A multi-layered mapping traceability SHA3 instruction cache and slot reverse analysis system:
[0051] Implements intelligent caching of EVM SHA3 instructions; supports recursive tracing and analysis of multi-level mappings; and provides real-time monitoring capabilities for complex data structures.
[0052] 4. Dynamic Variable Monitoring and State Reconstruction Framework:
[0053] Develop a lightweight EVM modification scheme to achieve efficient tracking of key state variables; design a state reconstruction algorithm to support the verification of complex temporal properties.
[0054] This embodiment also provides a monitoring system used in the above-described monitoring method, designed to address the challenges faced by existing technologies in handling complex smart contracts. The system includes the following core components and workflow:
[0055] I. TPSL (Temporal Property Specification Language) Parser
[0056] The TPSL parser is the system's entry point, responsible for processing user-defined temporal property specifications. Its workflow is as follows:
[0057] a) Lexical analysis: Decompose the TPSL specification text into a series of tokens.
[0058] b) Syntax analysis: Construct an abstract syntax tree (AST) from the token sequence according to the predefined TPSL syntax rules.
[0059] c) Semantic analysis: Perform semantic checks on the AST to ensure type consistency and reference integrity.
[0060] d) Internal representation generation: Convert the validated AST into an intermediate representation used internally by the system.
[0061] II. LTL Converter
[0062] The LTL converter receives the internal representation generated by the TPSL parser and converts it into executable monitoring logic. The main steps include:
[0063] a) LTL Formula Conversion: Convert the internal representation of TPSL into a standard linear sequential logic (LTL) formula.
[0064] b) Büchi automaton generation: The LTL formula is converted into a Büchi automaton using an optimized algorithm.
[0065] c) Monitoring Automaton Optimization: Considering the characteristics of the EVM (Ethereum Virtual Machine), the generated Büchi automaton is optimized and simplified.
[0066] d) Executable monitoring logic generation: Convert the optimized automaton into efficient monitoring code that can be executed in a smart contract environment.
[0067] III. Multi-layer Mapping Analysis System
[0068] This system is specifically designed to handle complex, multi-layered nested mapping structures in smart contracts. Its core functionalities include:
[0069] a) EVM Modification: Modify the EVM to capture and record the input and output of SHA3 instructions.
[0070] b) SHA3 instruction cache: Implements a multi-layer cache mechanism to store the input and output relationships of SHA3 instructions.
[0071] c) Slot analysis: Analyze the read and write operations of the storage slot and track the updates of the mapping.
[0072] d) Recursive tracing: Implement a recursive tracing algorithm for multi-level nested mappings.
[0073] e) State view construction: Based on the collected information, construct and maintain a global structural view of the mapping.
[0074] IV. Dynamic Variable Monitoring Framework
[0075] This framework is responsible for monitoring changes in key state variables in real time during smart contract execution. Its main components include:
[0076] a) Code instrumentation: Analyze the source code or bytecode of smart contracts and insert monitoring logic at key points.
[0077] b) Runtime Monitor: Collects information on changes in state variables during contract execution.
[0078] c) State Reconstruction: Based on the collected information, dynamically reconstruct the complete state of the contract.
[0079] d) Property validation: Validate predefined temporal properties using the reconstructed state information.
[0080] V. Integrated Verification Environment
[0081] The integrated verification environment integrates all the above components into a unified system, providing an end-to-end verification solution. Its workflow is as follows:
[0082] a) User input: Through a graphical interface or command-line interface, the user inputs the TPSL specification and the smart contract to be verified.
[0083] b) Preprocessing: TPSL parser processing specifications, LTL converter generation monitoring logic.
[0084] c) Contract Analysis: The multi-layered mapping analysis system performs static analysis on the contracts.
[0085] d) Dynamic monitoring: Deploy a smart contract containing monitoring logic, and the dynamic variable monitoring framework begins real-time monitoring.
[0086] e) Results analysis: Collect and analyze the verification results and generate detailed reports.
[0087] f) Feedback: Show the user the verification results, including whether the specified temporal properties were violated, and related details.
[0088] Through this comprehensive approach, the present invention can effectively monitor and verify the temporal properties of complex smart contracts, significantly improving the reliability and security of the contracts. This system not only handles the complex data structures and logic in current smart contracts but also possesses good scalability, enabling it to adapt to future developments in smart contract technology.
[0089] In this embodiment, an alternative to the TPSL language is also provided, including:
[0090] 1. Extensions based on existing specification languages: Instead of developing entirely new TPSLs, extend existing LTL or CTL languages. Utilize existing tools and theoretical foundations to reduce learning costs.
[0091] 2. Graphical Specification Definition Tool: Develop a visual interface that allows users to define temporary properties by dragging and connecting graphical elements. This approach is more intuitive and suitable for non-professional users.
[0092] In this embodiment, an alternative to multi-layer mapping analysis is also provided, including:
[0093] 1. Symbolic execution-based analysis: This approach uses symbolic execution techniques to analyze the mapping structure. This method may uncover deeper-level issues.
[0094] 2. Combining static and dynamic analysis: Static analysis is performed before contract deployment, while dynamic analysis is performed at runtime. This combines the advantages of both methods, improving analysis efficiency and accuracy.
[0095] The foregoing has shown and described the basic principles and main features of the present invention and its advantages. It will be apparent to those skilled in the art that the present invention is not limited to the details of the above exemplary embodiments, and that the present invention can be implemented in other specific forms without departing from the spirit or basic features of the present invention.
[0096] Furthermore, it should be understood that although this specification describes embodiments, not every embodiment contains only one independent technical solution. This narrative style is merely for clarity. Those skilled in the art should consider the specification as a whole, and the technical solutions in each embodiment can also be appropriately combined to form other embodiments that can be understood by those skilled in the art.
Claims
1. A smart contract Temporal Property monitoring method based on dynamic plugging, characterized in that: The monitoring approach includes the following: Design a temporal property specification language for smart contracts, optimize the LTL conversion algorithm, and implement dynamic monitoring of variables appearing in the specification. This method implements the Vector Clock mechanism and resource status tracking at the Ethereum Virtual Machine (EVM) level, and provides a multi-layer Mapping traceable SHA3 instruction cache and Slot reverse analysis system.
2. According to claim 1, a smart contract Temporal Property monitoring method based on dynamic plugging is characterized in that: The temporal property specification language supports the expression of complex temporal logic and state constraints, and has built-in support for special data structures such as mapping; the LTL conversion algorithm converts the specification into linear temporal logic (LTL) and generates efficient and executable monitoring logic.
3. According to claim 1, a smart contract Temporal Property monitoring method based on dynamic plugging is characterized in that: The SHA3 instruction cache and Slot reverse analysis system is used to realize intelligent caching of EVM SHA3 instructions, support recursive tracing and analysis of multi-layer mapping, and provide real-time monitoring capabilities for complex data structures.
4. According to claim 1, a smart contract Temporal Property monitoring method based on dynamic plugging is characterized in that: It also includes developing a lightweight EVM modification solution to achieve efficient tracking of key state variables; and designing a state reconstruction algorithm to support the verification of complex temporal properties.
5. A monitoring system used in the monitoring method according to claim 1, characterized in that: The monitoring system includes the following components: TPSL parser, LTL converter, multi-layer Mapping analysis system, and dynamic variable monitoring framework, wherein the TPSL parser is the entry point of the system and is responsible for processing user-defined temporal property specifications; the LTL converter receives the internal representation generated by the TPSL parser and converts it into executable monitoring logic; the multi-layer Mapping analysis system is used to process complex multi-layer nested mapping structures in smart contracts; the dynamic variable monitoring framework is used to monitor changes in key state variables in real time during the execution of smart contracts.
6. The monitoring system according to claim 5, characterized in that: The workflow of the TPSL parser is as follows: S1-1, Lexical analysis: decompose the TPSL standard text into a series of tokens; S1-2, Syntax analysis: According to the predefined TPSL grammar rules, the token sequence is constructed into an abstract syntax tree (AST); S1-3, Semantic analysis: Perform semantic checks on AST to ensure type consistency and reference integrity; S1-4, internal representation generation: Convert the verified AST into an intermediate representation used internally by the system.
7. The monitoring system according to claim 5, characterized in that: The conversion steps of the LTL converter include: S2-1, LTL formula conversion: convert the TPSL internal representation into a standard linear temporal logic (LTL) formula; S2-2, Büchi automaton generation: convert LTL formula into Büchi automaton using optimized algorithm; S2-3, monitoring automaton optimization: optimize and simplify the generated Büchi automaton; S2-4. Executable monitoring logic generation: Convert the optimized automaton into efficient monitoring code that can be executed in the smart contract environment.
8. The monitoring system according to claim 5, characterized in that: The core functions of the multi-layer Mapping analysis system include: S3-1. EVM modification: Modify the EVM to capture and record the input and output of the SHA3 instruction; S3-2, SHA3 instruction cache: implements a multi-layer cache mechanism to store the input and output relationship of SHA3 instructions; S3-3, Slot analysis: parse the read and write operations of the storage slot and track the update of the mapping; S3-4, recursive tracing: implement the recursive tracing algorithm for multi-layer nested mapping; S3-5, State view construction: Based on the collected information, build and maintain the global structure view of the mapping.
9. The monitoring system according to claim 5, characterized in that: The main components of the dynamic variable monitoring framework include: S4-1. Code instrumentation: Analyze the smart contract source code or bytecode and insert monitoring logic at key points; S4-2, runtime monitor: collects information about changes in state variables during contract execution; S4-3, State reconstruction: Dynamically reconstruct the complete state of the contract based on the collected information; S4-4. Property verification: Use the reconstructed state information to verify the predefined temporal properties.
10. The monitoring system according to claim 5, characterized in that: It also includes an integrated verification environment that integrates all components into a unified system to provide an end-to-end verification solution. The workflow is as follows: S5-1. User input: Through the graphical interface or command line interface, the user inputs the TPSL specification and the smart contract to be verified; S5-2, preprocessing: TPSL parser processes the specification, and LTL converter generates monitoring logic; S5-3. Contract analysis: The multi-layer Mapping analysis system performs static analysis on the contract; S5-4, Dynamic Monitoring: Deploy smart contracts containing monitoring logic, and the dynamic variable monitoring framework starts real-time monitoring; S5-5. Result analysis: Collect and analyze verification results and generate detailed reports; S5-6, Feedback: Display the verification results to the user, including whether the specified temporal properties are violated, and related detailed information.
Citation Information
Patent Citations
method for verifying a monitor during simplified operation based on a Buchi automaton
CN109522713A
Embedded real-time operation system verification method and system utilizing online model verification
CN110245085A
Extensible intelligent contract vulnerability detection method
CN110659494A
Efficient runtime monitoring method oriented to complete regular sequential logic property
CN116107862A
Operating code sequence generation method based on Ethereum transaction data replay
CN116204885A