Method for obtaining global feature vector based on smart contract

By constructing cross-contract call graphs and state dependency graphs for smart contracts and extracting global feature vectors, this technology addresses the lack of global semantic constraints in smart contract vulnerability repair, achieving highly accurate and reliable vulnerability repair results, and is applicable to Web3.0 smart contract platforms.

CN123158642APending Publication Date: 2026-11-24BEIHANG UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611366994.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-09-04
Publication Date
2026-11-24

AI Technical Summary

Technical Problem

Existing smart contract vulnerability repair technologies lack global semantic constraints in scenarios involving multi-contract interactions and complex business logic, making it difficult to achieve automated, reliable, and high-fidelity semantic guarantees for vulnerability repair, especially in terms of unified expression across call chains and state dependencies.

Method used

By decompiling the bytecode of smart contracts and tracing transactions, cross-contract call graphs and state dependency graphs are constructed. Features are extracted and heterogeneous feature graphs are formed. Global feature vectors are used to provide consistency constraints and verifiable semantic support, thereby improving the accuracy, interpretability, and credibility of vulnerability remediation.

Benefits of technology

It significantly improves the accuracy and reliability of smart contract vulnerability repair, is applicable to various Web3.0 smart contract platforms, has good scalability and versatility, and can provide solid global semantic support in complex multi-contract interaction scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123158642A_ABST
    Figure CN123158642A_ABST
Patent Text Reader

Abstract

This disclosure relates to the field of blockchain technology, specifically a method for obtaining global feature vectors based on smart contracts. The method includes: determining cross-contract call graphs and state dependency graphs by decompiling the smart contract's bytecode, as well as through transaction tracking and event logs; extracting features from both the cross-contract call graphs and state dependency graphs; and determining a heterogeneous feature graph using the extracted features, the cross-contract call graph, and the state dependency graph. A global feature vector is obtained using the heterogeneous feature graph, and the semantic representation of the global feature vector provides consistency constraints and verifiable semantic support for patch generation. This significantly improves the accuracy, interpretability, and credibility of vulnerability remediation, and exhibits good scalability and universality.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of blockchain technology, specifically to a method for obtaining global feature vectors based on smart contracts. Background Technology

[0002] With the rapid development of Web3.0 and the Internet of Value, smart contracts have become the core infrastructure for decentralized applications (DApps) and the circulation of digital assets. Their security and trustworthiness are directly related to the stable operation of the Internet of Value ecosystem. However, once smart contracts are deployed on the blockchain, they are difficult to modify, and vulnerability repair is costly and risky. Especially in scenarios involving multi-contract interactions and complex business logic, patch generation without global semantic constraints can easily lead to logical inconsistencies or new security vulnerabilities. Existing repair technologies mostly focus on local code analysis, making it difficult to capture the global semantic relationships across call chains and state dependencies at the context level, resulting in a lack of interpretability and consistency in the repair process. Therefore, there is an urgent need to propose a global feature vector acquisition method for smart contracts with context semantic awareness capabilities for the Web3.0 internet environment, in order to achieve automated, trustworthy, and high-fidelity semantic guarantees for vulnerability repair.

[0003] The core of smart contract vulnerability remediation lies in ensuring the correctness and completeness of patches, and the construction of semantic representations is a crucial prerequisite for achieving this goal. Semantic representation refers to transforming the contract's control flow, data flow, and state evolution process into a computable and analyzable structured form to support vulnerability localization, remediation pattern selection, and patch consistency assurance. Compared to remediation methods that rely solely on rule replacement or template matching, semantic representation methods place greater emphasis on characterizing multi-layered function calls, cross-contract interactions, and state dependencies, providing robust global semantic support for subsequent patch generation. In recent years, researchers both domestically and internationally have primarily developed three research paths in this area: source code-level remediation methods, bytecode-level automatic patching methods, and data-driven intelligent remediation methods.

[0004] Source code-level remediation methods locate and fix vulnerabilities by leveraging structured information such as Abstract Syntax Trees (ASTs) and symbolic execution trajectories. Contract execution paths are collected through symbolic execution and static analysis, and the vulnerability location is precisely pinpointed using the AST. Then, a predefined remediation template is matched for automatic remediation. Machine learning methods are introduced to model historical patch patterns, guiding template selection and optimization, significantly reducing manual intervention and redundant modifications during the remediation process. While the semantic representation of source code-level methods primarily relies on syntactic structure and path constraints, which can effectively explain the remediation logic, their context often remains within a single contract, limiting their support for complex cross-contract call scenarios.

[0005] Bytecode-level autopatching technology addresses the difficulty of rolling back deployed contracts. Typical research includes EVMPatch, which uses a minimally invasive bytecode rewriting mechanism to achieve immediate vulnerability patching, inserting patch logic without interrupting contract functionality. SMARTSHIELD combines control flow context to perform vulnerability detection and patching on bytecode, automatically covering multiple common defects. Furthermore, Elysium introduces a context-aware patching mechanism, performing contextual reasoning before template application to improve patch adaptability and accuracy. The advantage of these methods is their direct application to bytecode; however, their semantic representation is often limited to local code blocks and opcodes, and they are insufficient in acquiring global feature vectors of cross-contract interaction semantics.

[0006] With the development of deep learning and large-scale models, data-driven intelligent remediation methods are gradually emerging. Recent research shows that by fusing multimodal semantic information such as source code tokens, abstract syntax trees, control flow graphs, and bytecode, models more sensitive to vulnerability detection and remediation can be trained. For example, applying LLM to smart contract remediation tasks, combined with external validators filtering generated patches, demonstrates good adaptability and flexibility in real-world contract scenarios. Meanwhile, using GPT-4 and combining it with pre-discovered Role-Based Access Control (RBAC) patterns to guide LLM in remediating access control vulnerabilities achieves a 94.9% patch success rate; a multi-agent, multi-LLM collaborative framework is proposed, achieving detection and remediation of Solidity and Move contracts through division of labor, exhibiting strong generalization capabilities. However, these methods generally suffer from insufficient controllability and poor interpretability, and still lack uniformity in global semantics across call chains. Summary of the Invention

[0007] To address, or at least partially address, the aforementioned technical problems, embodiments of this disclosure provide a method for obtaining global feature vectors based on smart contracts. This method involves decompiling the smart contract bytecode and using transaction tracking and event logs to determine cross-contract call graphs and state dependency graphs. Feature extraction is then performed on both the cross-contract call graphs and state dependency graphs. The extracted features, along with the cross-contract call graphs and state dependency graphs, are used to determine a heterogeneous feature graph. A global feature vector is obtained using this heterogeneous feature graph. The semantic representation of the global feature vector provides consistency constraints and verifiable semantic support for patch generation, significantly improving the accuracy, interpretability, and credibility of vulnerability remediation. This method also exhibits good scalability and versatility.

[0008] In a first aspect, embodiments of this disclosure provide a method for obtaining global feature vectors based on smart contracts. The method includes: decompiling the bytecode of a smart contract to obtain an initial function call graph, the initial function call graph including a static function node set and a static call edge set; and determining a dynamic call edge set based on the actual execution path obtained from transaction tracking and event logs of the smart contract. A cross-contract call graph is determined based on the initial function call graph and dynamic call edges. The cross-contract call graph includes a set of cross-contract call edges and a set of cross-contract nodes. Feature extraction is performed on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features. A state dependency graph is determined based on the storage slot set and the cross-contract node set. The state dependency graph includes a set of state dependency edges and a set of state nodes. Feature extraction is performed on the state dependency graph to obtain state node features, state dependency edge features, and state weight features. Heterogeneity is determined based on the cross-contract call graph and the state dependency graph. A heterogeneous feature graph is determined based on the heterogeneous graph, cross-contract node features, cross-contract call edge features, cross-contract weight features, state node features, state call edge features, and state weight features. For each heterogeneous node in the heterogeneous feature graph, the heterogeneous node features are updated to obtain updated heterogeneous node features. The updated heterogeneous node features corresponding to all heterogeneous nodes are aggregated to obtain a global feature vector.

[0009] Secondly, embodiments of this disclosure also provide an electronic device, the electronic device comprising: one or more processors; a storage device for storing one or more programs; the one or more programs being executed by the one or more processors to implement the global feature vector acquisition method based on smart contracts as described above.

[0010] The embodiments of this disclosure provide a method for obtaining global feature vectors based on smart contracts. This method includes: decompiling the bytecode of the smart contract to obtain an initial function call graph, which includes a static function node set and a static call edge set; determining a dynamic call edge set based on the actual execution path obtained from the smart contract's transaction tracing and event logs; determining a cross-contract call graph based on the initial function call graph and the dynamic call edges, and establishing a complete cross-contract call graph by combining static decompilation with dynamic transaction tracing; determining a state dependency graph based on the storage slot set and the cross-contract node set, and constructing the state dependency graph based on storage slot read / write behavior to achieve state consistency constraints, fundamentally avoiding the risk of disrupting the original business logic or introducing new vulnerabilities during the repair process. Feature extraction is performed on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features; feature extraction is performed on the state dependency graph to obtain state node features, state dependency edge features, and state weight features; heterogeneity is determined based on the cross-contract call graph and the state dependency graph, and a heterogeneous feature graph is determined based on the heterogeneous graph, cross-contract node features, cross-contract call edge features, cross-contract weight features, state node features, state call edge features, and state weight features; by fusing the cross-contract call graph and the state dependency graph, the complex contextual relationships between multiple contracts and multiple function calls are comprehensively captured, overcoming the shortcomings of existing methods that only focus on local semantics and lack global dependency constraints. For each heterogeneous node in the heterogeneous feature graph, the heterogeneous node features are updated to obtain updated heterogeneous node features. The updated heterogeneous node features corresponding to all heterogeneous nodes are aggregated to obtain a global feature vector. Using graph representation learning and semantic embedding technology, the call chain and state dependency information are unified and integrated to form a high-fidelity global feature vector semantic representation. This provides consistency constraints and verifiable semantic support for patch generation, which can significantly improve the accuracy, interpretability and credibility of vulnerability repair. It has good scalability and versatility and is suitable for various Web3.0 smart contract platforms and value Internet application scenarios. Attached Figure Description

[0011] The above and other features, advantages, and aspects of the embodiments of this disclosure will become more apparent from the accompanying drawings and the following detailed description. Throughout the drawings, the same or similar reference numerals denote the same or similar elements. It should be understood that the drawings are schematic, and the originals and elements are not necessarily drawn to scale.

[0012] Figure 1 This is a flowchart of a method for obtaining global feature vectors based on smart contracts in an embodiment of this disclosure.

[0013] Figure 2 This is a schematic diagram of the structure of a cross-contract call graph in an embodiment of this disclosure.

[0014] Figure 3 This is a schematic diagram of the structure of a state dependency graph in an embodiment of this disclosure.

[0015] Figure 4 This is a schematic diagram of the structure for obtaining global feature vectors in an embodiment of this disclosure.

[0016] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of the present disclosure. Detailed Implementation

[0017] Embodiments of this disclosure will now be described in more detail with reference to the accompanying drawings. While some embodiments of this disclosure are shown in the drawings, it should be understood that this disclosure can be implemented in various forms and should not be construed as limited to the embodiments set forth herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of this disclosure. It should be understood that the accompanying drawings and embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of protection of this disclosure.

[0018] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are used only to distinguish different devices, modules or units, and are not used to limit the order of functions performed by these devices, modules or units or their interdependencies.

[0019] The names of messages or information exchanged between multiple devices in the embodiments of this disclosure are for illustrative purposes only and are not intended to limit the scope of such messages or information.

[0020] Overall, existing research has made initial progress in the semantic representation of smart contract vulnerability remediation, but it still faces three shortcomings: First, there is a lack of systematic modeling of cross-contract call chain semantics, making it difficult to handle complex multi-contract interaction scenarios such as DeFi; second, state variable dependencies and temporal conditions have not formed a unified expression, limiting the consistency verification of patches at the transaction level; and third, while data-driven methods are flexible, they lack global semantic priors, easily generating semantically inconsistent remediation schemes. Therefore, there is an urgent need to propose a context-aware global feature vector acquisition method based on smart contracts, integrating cross-call chain graphs, state dependency graphs, and contextual semantic reasoning to provide solid theoretical and technical support for the reliable remediation of smart contract vulnerabilities.

[0021] To address the aforementioned issues, embodiments of this disclosure provide a method for obtaining global feature vectors based on smart contracts. This method determines cross-contract call graphs and state dependency graphs by decompiling the smart contract bytecode and analyzing transaction traces and event logs. Feature extraction is then performed on both the cross-contract call graphs and state dependency graphs. The extracted features, along with the cross-contract call graphs and state dependency graphs, are used to determine a heterogeneous feature graph. A global feature vector is obtained using this heterogeneous feature graph. The semantic representation of the global feature vector provides consistency constraints and verifiable semantic support for patch generation, significantly improving the accuracy, interpretability, and credibility of vulnerability remediation. This method also exhibits good scalability and versatility.

[0022] Figure 1 This is a flowchart illustrating a method for obtaining global feature vectors based on smart contracts, as described in an embodiment of this disclosure. This method can be executed by a smart contract-based global feature vector acquisition device, which can be implemented in software and / or hardware and can be configured in an electronic device. Figure 1 As shown, the method may specifically include the following steps:

[0023] S110: By decompiling the bytecode of the smart contract, an initial function call graph is obtained, which includes a set of function nodes and a set of static call edges;

[0024] Specifically, at the static level, the smart contract bytecode is first decompiled to obtain intermediate representations, control flow information, and call instruction information. Function signatures, or four-byte function selectors calculated from function signatures, are used to identify external functions and their entry points, and function nodes are constructed accordingly. Each function node is uniquely determined by its contract address and function entry point; external function entry points are identified by the function selector, while internal function entry points are determined by the control flow recovery result. Control flow jump instructions such as JUMP and JUMPI are used to restore the reachability relationships between basic blocks, determine the internal control flow of functions, and identify identifiable internal function call relationships. Call instructions such as CALL, STATICCALL, and DELEGATECALL are used to identify call relationships between functions or contracts. When the call target can be statically parsed, static call edges are established between the corresponding function nodes. Let the set of function nodes obtained from static analysis be... The static edge set is The initial function call graph is then represented as follows: , Therefore, the initial function call graph includes both the set of function nodes obtained from static analysis and the set of static call relationships between functions.

[0025] S120: Determine the dynamic call edge set based on the actual execution path obtained from smart contract transaction tracking and event logs;

[0026] During the execution of a smart contract, transaction tracing refers to the sequence of call frames formed by blockchain nodes during the execution of a transaction. It records the caller's contract address, the callee's contract address, the input data, the call type (CALL or DELEGATECALL), the call hierarchy, and parent-child call relationships. The event log is a record of events written to the transaction receipt after a smart contract executes a LOG-type instruction; it includes the event subject and event data. Transaction tracing is used to reconstruct the actual call path, while the event log supplements contextual information such as events triggered during the call process; it is not used alone to determine the call path.

[0027] In one specific embodiment, determining the dynamic call edge set based on the actual execution path obtained from the transaction tracking and event logs of the smart contract includes: obtaining the call record set during the actual execution process of the smart contract through transaction tracking and event logs; using a mapping function to map each call record in the call record set as a directed call edge between function nodes, and determining the dynamic call edge set by all directed call edges.

[0028] In this context, the call relationships between functions and contracts often involve multiple levels of nesting and dynamic calling characteristics. Relying solely on static analysis can easily lead to missing paths or misjudgments. Therefore, a combined approach of "static analysis + dynamic tracing" is adopted. At the dynamic level, transaction tracing is used to obtain the call stack and call hierarchy during the actual execution of smart contracts. Each dynamic call record includes at least the caller's contract address, the callee's contract address, the call input data, the call type, and the call hierarchy. Let the set of dynamic call records be T. dyn The mapping function ϕ maps each record to a directed call edge between function nodes, thus forming a dynamic call edge set. =ϕ(T dyn For a dynamic call record, the called function node is determined based on the callee's contract address and the function selector in the first four bytes of the call input data. The calling function node is then determined based on its parent call record and call hierarchy, thereby enabling function mapping. Dynamic call records are mapped to directed call edges between function nodes. Event logs are used to supplement contextual information such as events triggered during the call process, but are not used alone to determine the call path. For functions that were not identified during the static analysis phase but actually appeared during dynamic execution, the corresponding function nodes can be supplemented based on their contract addresses and function selectors.

[0029] S130: Determine a cross-contract call graph based on the initial function call graph and the dynamic call edge set. The cross-contract call graph includes a cross-contract call edge set and a cross-contract node set.

[0030] When merging the static call graph and the dynamic call edge set, the dynamic information is used to supplement and verify the static analysis results, rather than replacing the static call graph as a whole: if a dynamic call edge already exists in the static call graph, then the actual execution information is added to that edge; if a dynamic call edge does not exist in the static call graph, then it is added as a new call edge; static call edges that are not covered by the current dynamic transaction are still retained.

[0031] In one specific embodiment, a cross-contract call graph is determined based on the initial function call graph and dynamic call edges. The cross-contract call graph includes a cross-contract call edge set and a cross-contract node set, including: determining a dynamic node set based on the dynamic call edge set; determining a cross-contract node set based on the static function node set and dynamic node set in the initial function call graph; determining a cross-contract call edge set based on the static call edge set and dynamic call edge set in the initial function call graph; and determining a cross-contract call graph based on the cross-contract call edge set and cross-contract node set.

[0032] Let the dynamic call edge set formed by the above mapping be . In the dynamic phase, the corresponding function node set is supplemented by dynamically calling the edge set. Then cross-contract node set and cross-contract call edge set They are respectively:

[0033] ,

[0034] = ∪ ,

[0035] Finally, the cross-contract call graph is determined based on the cross-contract call edge set and the cross-contract node set. : ( , ).

[0036] Summary, Reference Figure 2 As shown, Figure 2 This is a schematic diagram of a cross-contract call graph structure in an embodiment of this disclosure. The cross-contract call graph is determined by combining static and dynamic analysis. Specifically, in terms of static analysis, the contract bytecode is decompiled to obtain a set of static function nodes. and static call edge set In terms of dynamic analysis, execution paths are extracted based on transaction tracking and event logs to obtain dynamic call edge sets. Based on static function node set and static call edge set and dynamically calling edge sets By merging the static and dynamic call relationships, a cross-contract call graph is obtained. For example, merging the dynamic contract A.2-B.2-C.1 relationship with the static contract A.1-A.2-B.1-B.1-C.1-C.2 relationship yields a cross-contract call graph. .

[0037] S140: Perform feature extraction on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features.

[0038] Based on the above embodiments, the aforementioned steps obtain the cross-contract call graph through a combination of static analysis and dynamic tracing. Further context feature extraction and encoding are needed for the cross-contract node set and cross-contract call edge set in the cross-contract call graph.

[0039] In one specific embodiment, feature extraction is performed on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features, including: determining cross-contract call edge features based on function information, transaction tracking, and event logs in the cross-contract call graph; determining cross-contract weight features based on cross-contract call edge features and cross-contract node set; and determining cross-contract node features based on cross-contract call edge features, cross-contract weight features, and cross-contract node set.

[0040] For example, for cross-contract call edge e ij =(f i ,f j )∈ This indicates that the function f is called by the caller. i Pointer to the called function f j The cross-contract call relationship can be identified by static analysis, obtained by dynamic tracing, or determined by both static analysis and dynamic tracing. Based on the function information, transaction tracing, and event logs corresponding to the cross-contract call edge, cross-contract call edge characteristics are constructed:

[0041] x ij =[g ij sig ∥p ij ∥d ij ∥l ij ∥q ij ],

[0042] Where, x ij This indicates a cross-contract call edge feature, and ∥ indicates feature concatenation; g ij sig This indicates the function signature characteristics of the calling and called functions involved in this call. When the complete function signature cannot be obtained, a four-byte function selector is used for encoding; p ijThis indicates the parameter characteristics obtained based on the input data; when the ABI is available, the call parameters are parsed and encoded according to their type; when the ABI is not available, the call data after the function selector is truncated to a fixed length, padded, or hashed. ij Indicates the call depth of this call in the transaction call stack; ij Indicates the number of events triggered during the execution of this call; q ij This indicates the proxy call flag. The value is 1 when the call is a proxy forwarding or executed using the DELEGATECALL method, and 0 otherwise.

[0043] The above features are all derived from data obtained during the construction of the cross-contract call graph. Specifically, function signatures or function selectors are derived from bytecode decompilation results and call input data; call parameters, call depth, and call type are derived from transaction tracing; and the number of events is derived from event logs. For call edges obtained solely from static analysis and not actually executed in the current transaction, their missing dynamic features are filled with preset default values.

[0044] The cross-contract weight feature is jointly determined by the calling function, the called function, and the cross-contract call edge feature of this call:

[0045] α ij =softmax i∈N⁻(j) (Att(h i (0) ,h j (0) ,x ij )),

[0046] Where, α ij This indicates that the call is made to the cross-contract node f. j The cross-contract weight feature, Att(·) represents the attention calculation function, and softmax(·) is used to calculate the attention for all nodes pointing to cross-contract nodes f. j The edge weights are normalized using the call. j (0) Indicates cross-contract node f j The initial characteristics; N⁻(j) represents all nodes f with incoming edges pointing to functions. j The set of predecessor function nodes; h i (0) Indicates the initial characteristics of the caller across contract nodes; x ij This represents the characteristics of cross-contract call edges; through this weight feature, the degree of influence of different call relationships on the target function node can be distinguished. For example, call edges with different call parameters, call depths, or proxy call methods can obtain different aggregation weights.

[0047] For cross-contract nodes, the outer function obtains the initial node representation based on its function signature or function selector, while the inner function obtains its initial node representation based on its function entry point and intermediate representation features. Based on this, by combining the context features of adjacent function nodes and corresponding cross-contract call edges, adjacency aggregation is performed on the function nodes to obtain the cross-contract node features:

[0048] h j =σ(W0h j (0) +Σ i∈N⁻(j) α ij W1[h i (0) ∥x ij ]),

[0049] Among them, h j Indicates cross-contract node characteristics, h j (0) Indicates cross-contract node f j The initial characteristics; N⁻(j) represents all nodes with incoming edges pointing to cross-contract nodes f. j The set of predecessor function nodes; h i (0) Indicates the initial characteristics of the caller across contract nodes; x ij Indicates the cross-contract call edge feature; α ij This indicates that the call is made to the cross-contract node f. j Cross-contract weighting characteristics; h j This represents the cross-contract node features obtained after aggregating the call context. W0 represents the first feature mapping parameter, W1 represents the second feature mapping parameter, and σ represents the nonlinear transformation function; the feature mapping parameters and attention calculation parameters in this part are set separately from the parameters in the state dependency graph.

[0050] refer to Figure 2 As shown, after the above processing, the cross-contract call graph... Feature extraction is performed to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features; the set of cross-contract node features is denoted as H. c The set of cross-contract call edge features is denoted as X. c The set of cross-contract weight features is denoted as A. c This result represents node-level and edge-level feature representations, not the final graph-level global semantic vector. In the subsequent heterogeneous feature graph construction process, node representations are used as cross-contract node features, and cross-contract call edge features and their cross-contract weight features are used as call relationship features. These are then fused with the state node header text and state dependency edge features obtained from the state dependency graph. The final global semantic vector is obtained after heterogeneous graph feature aggregation.

[0051] S150: Determine a state dependency graph based on the storage slot set and the cross-contract node set, the state dependency graph including a state dependency edge set and a state node set.

[0052] During the execution of smart contracts, stored variables play a crucial role in maintaining the global state, such as account balances, access control flags, or collateral positions. If a patch fails to update the relevant state variables correctly, it can lead to serious consequences such as logical inconsistencies, state tampering, or asset loss. Therefore, a state dependency graph can be constructed by tracking the read and write behavior of the contract's storage slots.

[0053] In a specific embodiment, a state dependency graph is determined based on a storage slot set and a cross-contract node set. The state dependency graph includes a state dependency edge set and a state node set, including: determining the state node set based on the storage slot and the corresponding smart contract address, wherein the state node represents the state storage location of the smart contract; determining the state dependency edge set based on the state node set and the cross-contract node set; and determining the state dependency graph based on the state node set and the state dependency edge set.

[0054] Specifically, the intermediate representation of the smart contract bytecode is analyzed, and the read and write operations of the storage slots are identified based on the SLOAD and SSTORE instructions. State nodes in the state dependency graph represent the storage locations of the smart contract's state. To distinguish storage slots with the same number in different contracts, each state node is determined by its contract address and storage slot identifier; when the storage layout is available, it can be further mapped to specific state variables. For storage accesses generated by the DELEGATECALL call, the corresponding storage slot is assigned to the calling contract based on its actual storage context.

[0055] Therefore, let the set of state nodes be... The set of function nodes participating in state read / write analysis can be the same as the cross-contract node set in the aforementioned cross-contract call graph. This is only used to extract read and write relationships between functions and state nodes, and is not used as a node in the state dependency graph. The read and write relationships are defined as follows: Based on the above relationship, if the function And write Then, towards the state-dependent edge set Add a directed edge e ij dep =( , ), representing a state node Updates depend on state nodes The dynamic execution order is used to confirm or supplement the aforementioned state read-write relationships. Therefore, a state dependency graph is obtained based on the set of state nodes and the set of state dependency edges. :

[0056] e ij dep =( , )∈ ,

[0057] Summary, Reference Figure 3 As shown, Figure 3 This is a schematic diagram of a state dependency graph in an embodiment of the present disclosure. The intermediate representation of the bytecode is analyzed to identify the SLOAD and SSTORE instructions, determining the read / write relationship between functions and memory slots, such as function nodes. Read Write Among them, function nodes are only used to determine read-write relationships; state dependency edges are formed according to the read-write order, and based on the state dependency edges ( The state dependency graph is formed by the function nodes. .

[0058] S160: Extract features from the state dependency graph to obtain state node features, state dependency edge features, and state weight features;

[0059] Based on the above embodiments, in the state dependency graph Based on this, context features are further extracted and encoded for state nodes and state-dependent edges to obtain state node features, state-dependent edge features and their state weight features, which are used to construct heterogeneous feature maps in the future.

[0060] In a specific embodiment, feature extraction is performed on the state dependency graph to obtain state node features, state dependency edge features, and state weight features, including: determining initial features based on the smart contract address and storage slot; determining state dependency edge features based on the read / write order and dependency relationship of state dependency edges; determining state weight features based on the initial features, state dependency edge features, and state node set; and determining state node features based on the initial features, state weight features, state dependency edge features, and state nodes in the state node set.

[0061] For example, for state nodes ∈ Initial features are constructed based on the contract it belongs to, the identifier of the storage slot, and read / write statistics:

[0062] z i =[Emb(a i )∥Emb(u i )∥Norm(n i r )∥Norm(n i w )],

[0063] Among them, z i State node The initial features, ∥ represents feature concatenation; a i This represents the address identifier of the contract where the state node resides; u i Indicates the identifier of the storage slot; n i r and n i w These represent the number of times the state node is read and written, respectively; Emb(·) represents the encoding operation that converts the discrete identifier into a fixed-length vector; Norm(·) represents the normalization of the number of reads and writes.

[0064] For the state-dependent edge e ij dep =( , )∈ The direction of the edge is determined by the state node being read. Pointing to the state node being written Used to represent state nodes Updates depend on state nodes Based on the read / write order, the frequency of dependency occurrences, and whether they belong to the same storage slot for self-update relationships, state dependency edge features are constructed:

[0065] x ij dep =[o ij ∥Norm(c ij )∥m ij ],

[0066] Where, x ij dep Represents state-dependent edge features, o ij Indicates read To write The sequential characteristics, c ij This represents the number of times the state dependency occurs in the executable path or transaction execution trajectory, m. ij Indicates a self-updating flag, when = The value is 1 if the condition is met, and 0 otherwise.

[0067] After obtaining the initial features and state-dependent edge features, the state weight features are calculated based on the predecessor state node, the target state node, and the state-dependent edge features:

[0068] β ij =softmax i∈Ns-(j) (Att(z i ,z j ,xij dep )),

[0069] Where, N s − (j) represents all nodes pointing to the state in the state dependency graph. The set of predecessor state nodes, where Att(·) represents the attention computation function; β ij Represents the state-dependent edge e ij dep The weights of different predecessor state nodes relative to the target state node are determined through normalization. The sum of the dependency weights is 1.

[0070] Based on the state weight features, the features of the predecessor state nodes and their state dependency edges are weighted and aggregated to obtain the state nodes. State node characteristics:

[0071] h j s =σ(W2z j +Σ i∈Ns⁻(j) β ij W3[z i ∥x ij dep ]),

[0072] Among them, h j s This represents the state node feature obtained by fusing the target state node's own information, the predecessor state node's information, and the state dependency edge information, where j represents the target state node. i represents its predecessor state node. ; State node The set of predecessor state nodes; and Representing state nodes respectively and Initial characteristics; Indicates the state node Pointing to the state node State-dependent edge features; β ij This indicates the state weight of the edge that the state depends on; and σ represents the third and fourth feature mapping parameters, respectively; σ represents the nonlinear transformation function.

[0073] refer to Figure 3 As shown, after the above processing, the state dependency graph... Feature extraction is performed to obtain state node features, state call edge features, and state weight features. The state node features h are then processed. js The set is denoted as H s State-dependent edge features x ij dep The set is denoted as X dep State weight feature β ij The set is denoted as A dep .

[0074] S170: Determine a heterogeneous graph based on the cross-contract call graph and the state dependency graph, and assign the heterogeneous graph, cross-contract node features, cross-contract call edge features and cross-contract weight features, state node features, state call edge features and state weight features to the heterogeneous graph to obtain a heterogeneous feature graph.

[0075] The preceding steps yield the cross-contract node features, cross-contract call edge features, and their cross-contract weight features of the cross-contract call graph, as well as the state node features, state dependency edge features, and their state weight features of the state dependency graph, while preserving the read and write relationships between functions and state nodes. To address the issue of the separation between these two types of semantics, this study unifies the above graph structures and features into a heterogeneous feature graph. Through relationship-aware feature fusion and constraint-guided representation optimization, a global semantic representation that simultaneously characterizes function call relationships and state update dependencies is formed.

[0076] In one specific embodiment, determining a heterogeneous graph based on a cross-contract call graph and a state dependency graph includes: determining a heterogeneous node set based on the cross-contract node set in the cross-contract call graph and the state node set in the state dependency graph; and determining a heterogeneous call edge set based on the cross-contract call edge set in the cross-contract call graph, the state dependency edge set in the state dependency graph, and the read / write relationship between the state nodes in the state dependency graph, wherein the heterogeneous call edge set and the heterogeneous node set form a heterogeneous graph.

[0077] It's important to note that we're not directly adding the cross-contract call graph and the state dependency graph, or directly adding the two types of features from the cross-contract call graph and the state dependency graph. Instead, we first organize the structures of both graphs uniformly, and then load the features obtained in the preceding steps onto the corresponding nodes and edges. Let F be the set of cross-contract nodes in the cross-contract call graph, and let be the set of state nodes in the state dependency graph. The original identities and types of the two types of nodes are preserved, and a heterogeneous graph is constructed using call, read, write, and state dependencies as heterogeneous edges:

[0078] G h =(V,E,R), V=F∪ E=E c ∪R read ∪R write ∪E dep ,

[0079] Where V=F∪ This only indicates that cross-contract nodes and state nodes are included in the same node set; the two types of nodes are still retained as different types of nodes; E c Represents a cross-contract call edge between nodes; R read and R write These represent the relationship between function read and write state nodes, respectively, and serve as bridge edges connecting the function subgraph and the state subgraph; E dep The edges represent state dependencies between state nodes; R={call, read, write, state_dep} is a set of relation types used to distinguish the different technical semantics of the four types of relations: call, read, write, and state dependency. Therefore, the two graphs are not formed simply by the union of the node sets, but by connecting function nodes and state nodes through read edges and write edges.

[0080] In a specific embodiment, a heterogeneous feature graph is obtained by assigning the heterogeneous graph, cross-contract node features, cross-contract call edge features, cross-contract weight features, state node features, state call edge features, and state weight features to the heterogeneous graph, including:

[0081] Based on the cross-contract node mapping parameters, feature alignment is performed on the cross-contract node features to obtain the cross-contract node heterogeneous features.

[0082] Based on the state node mapping parameters, feature alignment is performed on the state node features to obtain the heterogeneous features of the state nodes.

[0083] The heterogeneous features of cross-contract node heterogeneous features, state node heterogeneous features, cross-contract call edge features and cross-contract weight features, state call edge features and state weight features are assigned to the heterogeneous graph to obtain a heterogeneous feature graph.

[0084] After completing the heterogeneous graph, relevant features are assigned to their corresponding positions within the graph. The graph structure of the heterogeneous graph represents how nodes are connected, and the node features describe the semantic information extracted from each node. The cross-contract node feature set H obtained from the aforementioned cross-contract call graph... c The state node feature set H obtained from the state dependency graph and / or state dependency graph s Each feature in the system corresponds one-to-one with a specific cross-contract node or state node.

[0085] First, since the sources and dimensions of cross-contract node features and state node features may differ, cross-contract node mapping parameters and state node mapping parameters are used respectively to transform them to the same node feature dimension:

[0086] h f (0) =W F h fc , f∈F; h s (0) =W S h s s ,s∈ ,

[0087] Among them, h f (0) h represents the heterogeneous characteristics of nodes across contracts. s (0) h represents the heterogeneous characteristics of state nodes. f c This represents the cross-contract node characteristic of cross-contract node f in the cross-contract call graph; h s s W represents the state node characteristics of state node s in the state dependency graph. F W represents the cross-contract node mapping parameter across contract nodes. S This represents the state node mapping parameters. This mapping is only used to make the two types of features have the same dimension; it does not indicate that the two types of features have been added or merged.

[0088] Secondly, the aforementioned cross-contract call edge feature set X is used. c and calling cross-contract weight feature set A c and the aforementioned state-dependent edge feature set X dep and state weight feature set A dep The read and write relationships serve as bridge edges connecting cross-contract nodes and state nodes, recording information such as relationship type, direction, and optional read / write counts. Each edge feature and weight corresponds to a specific relationship edge: heterogeneous features of cross-contract nodes are assigned to cross-contract nodes, while cross-contract call edge features and cross-contract weight features are assigned to cross-contract call edges; heterogeneous features of state nodes are assigned to state nodes, while state dependency edge features and state weight features are assigned to state dependency edges, forming a heterogeneous feature graph. Different types of edge features and weights are retained separately in this step and are not directly added together.

[0089] Therefore, this step yields a heterogeneous feature graph that simultaneously contains graph structure, node type, relation type, node features, edge features, and edge weights. This step completes the structural connection, feature loading, and dimension alignment of the two graphs; it does not yet aggregate information from function node features and state node features, nor does it obtain the final global semantic vector. In the next step, relation-aware feature fusion, node features will be passed along call, read, write, and state dependencies and aggregated. Since call, read, write, and state dependencies in the heterogeneous feature graph have different semantics, they cannot be directly aggregated using the same parameters. Therefore, a relation-aware message passing mechanism is used to generate and aggregate neighbor messages according to relation types to form a heterogeneous feature graph.

[0090] S180: For each heterogeneous node in the heterogeneous feature map, update the heterogeneous node features to obtain the updated heterogeneous node features.

[0091] In a specific embodiment, for each heterogeneous node in the heterogeneous feature graph, the heterogeneous node features are updated to obtain updated heterogeneous node features. The heterogeneous feature graph includes heterogeneous node features, including: using cross-contract node heterogeneous features and state node heterogeneous features as heterogeneous node features; determining call relationship neighbor information based on cross-contract call edge feature set and call cross-contract weight feature set; determining state dependency relationship neighbor information based on state dependency edge feature set and state weight feature set; determining read relationship neighbor information and write relationship neighbor information based on the state dependency graph; and determining the updated heterogeneous node features based on the heterogeneous node features, call relationship neighbor information, state dependency relationship neighbor information, read relationship neighbor information, and write relationship neighbor information.

[0092] For example, for any node, neighbor node features are used to determine the source of information, edge features are used to describe the specific relationship context, edge weights are used to determine the degree of influence of the relationship on the target node, and different relationship types use corresponding feature mapping parameters.

[0093] Specifically, for any cross-contract node f∈F or state node s∈ Collectively referred to as heterogeneous node v, cross-contract node heterogeneous characteristics Heterogeneous features of state nodes As input, i.e. .

[0094] For call relationships, the aforementioned cross-contract call edge feature set is used. and cross-contract weight feature set Transmit information about adjacent cross-contract nodes; for state dependencies, use the aforementioned state dependency edge feature set. and state weight feature set Transmit information between adjacent state nodes; for read and write relationships, transmit information between cross-contract nodes and state nodes according to the corresponding relationship direction.

[0095] Specifically, the heterogeneous features of the nodes in the l-th layer are updated according to the following formula:

[0096] ,

[0097] in, This represents the updated heterogeneous node characteristics of heterogeneous node v. The heterogeneous node characteristics represent the heterogeneous node v; Mapping parameters representing the characteristics of the heterogeneous node v itself; Indicates according to and Obtained neighbor information related to the call relationship; Indicates according to and Obtain the state dependency neighbor information; and σ represents the neighbor information obtained by reading and writing relationships, respectively; σ represents the nonlinear transformation function.

[0098] In one specific embodiment, during the node feature update process, the node feature mapping parameters and aggregation parameters of different relationships are adjusted using graph structure reconstruction constraints, so that the heterogeneous node features retain the original calling relationships, state dependencies, and read and write relationships after the update, and the updated heterogeneous node features are obtained after constraint optimization.

[0099] Specifically, during the node feature update process, the node feature mapping parameters and aggregation parameters of different relationships are adjusted using graph structure reconstruction constraints. This ensures that the heterogeneous node features retain the original call relationships, state dependencies, and read and write relationships after the update. The updated heterogeneous node features are then constrained, and the updated heterogeneous node features are obtained after constraint optimization.

[0100] S190: Aggregate the updated heterogeneous node features corresponding to all the heterogeneous nodes to obtain a global feature vector.

[0101] Specifically, the updated heterogeneous node features corresponding to all heterogeneous nodes are aggregated using a pooling method to obtain a global feature vector that represents the cross-contract call relationship and state dependency relationship as a whole. The semantic representation of the high-fidelity global feature vector provides consistency constraints and verifiable semantic support for patch generation, which can significantly improve the accuracy, interpretability and credibility of vulnerability repair. It has good scalability and versatility and is suitable for various Web3.0 smart contract platforms and value Internet application scenarios.

[0102] In summary, Figure 4 This is a schematic diagram illustrating the structure for obtaining global feature vectors in an embodiment of this disclosure, using multi-source graph features as input, such as cross-contract call graphs. The set H of cross-contract node characteristics c The set X of cross-contract call edge features c A set of cross-contract weight features c State dependency graph The set H of state node features s The set X of state-dependent edge features dep A set of state weight features dep and reading relationships and write relationship Node feature alignment is performed, and then a heterogeneous feature map is constructed; specifically, f1 and f2, which contain static and dynamic node features, are read. f1 write State-dependent edges ( Then, the nodes of the heterogeneous feature map are updated and the constraints are optimized. The node feature updates are perceived by reconstructing the constraint relationship through the graph structure, and the optimized updated heterogeneous node features are obtained. Then, graph pooling (i.e. feature aggregation) is performed on the optimized updated heterogeneous node features to obtain the global feature vector.

[0103] Figure 5 This is a schematic diagram of the structure of an electronic device according to an embodiment of this disclosure. See below for details. Figure 5 It shows a schematic diagram of the structure of an electronic device 500 suitable for implementing embodiments of the present disclosure. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0104] like Figure 5 As shown, the electronic device 500 may include a processing unit 501, a ROM 502, a RAM 503, a bus 504, an input / output (I / O) interface 505, an input device 506, an output device 507, a storage device 508, and a communication device 509. The processing unit (e.g., a central processing unit, a graphics processor, etc.) 501 can perform various appropriate actions and processes according to a program stored in the read-only memory (ROM) 502 or a program loaded from the storage device 508 into the random access memory (RAM) 503 to implement the sea ice prediction method as described in the embodiments of this disclosure. The RAM 503 also stores various programs and data required for the operation of the electronic device 500. The processing unit 501, the ROM 502, and the RAM 503 are interconnected via the bus 504. The input / output (I / O) interface 505 is also connected to the bus 504.

[0105] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts, thereby implementing the global feature vector acquisition method based on smart contracts as described above. In such embodiments, the computer program can be downloaded and installed from a network via communication device 509, or installed from storage device 508, or installed from ROM 502. When the computer program is executed by processing device 501, it performs the functions defined in the methods of embodiments of this disclosure.

[0106] It should be noted that the computer-readable medium described in this disclosure can be a computer-readable signal medium or a computer-readable storage medium, or any combination thereof. A computer-readable storage medium can be, for example,—but not limited to—an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination thereof. More specific examples of a computer-readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination thereof. In this disclosure, a computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, apparatus, or device. In this disclosure, a computer-readable signal medium can include a data signal propagated in baseband or as part of a carrier wave, carrying computer-readable program code. Such propagated data signals can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination thereof. A computer-readable signal medium can be any computer-readable medium other than a computer-readable storage medium, which can send, propagate, or transmit a program for use by or in connection with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to: wires, optical fibers, RF (radio frequency), etc., or any suitable combination thereof.

[0107] The aforementioned computer-readable medium may be included within the aforementioned electronic device; or it may exist independently and not assembled into the electronic device. The aforementioned computer-readable medium carries one or more programs, which, when executed by the electronic device, cause the electronic device to: decompile the smart contract's bytecode to obtain an initial function call graph, which includes a static function node set and a static call edge set; determine a dynamic call edge set based on the actual execution path obtained from the smart contract's transaction tracking and event logs; determine a cross-contract call graph based on the initial function call graph and dynamic call edges, which includes a cross-contract call edge set and a cross-contract node set; extract features from the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features; and, based on the storage slot... A state dependency graph is determined by the set of cross-contract nodes and the state dependency graph, which includes a set of state dependency edges and a set of state nodes. Features are extracted from the state dependency graph to obtain state node features, state dependency edge features, and state weight features. Heterogeneity is determined based on the cross-contract call graph and the state dependency graph, and a heterogeneous feature graph is determined based on the heterogeneous graph, cross-contract node features, cross-contract call edge features, cross-contract weight features, state node features, state call edge features, and state weight features. For each heterogeneous node in the heterogeneous feature graph, the heterogeneous node features are updated to obtain updated heterogeneous node features. The updated heterogeneous node features corresponding to all heterogeneous nodes are aggregated to obtain a global feature vector.

[0108] Optionally, when one or more of the above-described procedures are executed by the electronic device, the electronic device may also perform other steps described in the above embodiments.

[0109] In the context of this disclosure, a machine-readable medium can be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, apparatus, or device. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can be, but is not limited to, electronic, magnetic, optical, electromagnetic, infrared, or semiconductor systems, apparatus, or devices, or any suitable combination of the foregoing. More specific examples of machine-readable storage media include electrical connections based on one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the foregoing.

[0110] The above description is merely a preferred embodiment of this disclosure and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this disclosure is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the above-described concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features disclosed in this disclosure that have similar functions.

Claims

1. A method for obtaining global feature vectors based on smart contracts, characterized in that, The method includes: By decompiling the bytecode of the smart contract, an initial function call graph is obtained, which includes a set of static function nodes and a set of static call edges. Based on the actual execution path obtained from the transaction tracking and event logs of the smart contract, a dynamic call edge set is determined; Based on the initial function call graph and the dynamic call edges, a cross-contract call graph is determined, which includes a cross-contract call edge set and a cross-contract node set. Feature extraction is performed on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features; A state dependency graph is determined based on the storage slot set and the cross-contract node set, the state dependency graph including a state dependency edge set and a state node set; Feature extraction is performed on the state dependency graph to obtain state node features, state dependency edge features, and state weight features; Heterogeneity is determined based on the cross-contract call graph and state dependency graph, and a heterogeneous feature graph is determined based on the heterogeneous graph, cross-contract node features, cross-contract call edge features and cross-contract weight features, state node features, state call edge features and state weight features; For each heterogeneous node in the heterogeneous feature map, the heterogeneous node features are updated to obtain the updated heterogeneous node features; The updated heterogeneous node features corresponding to all the heterogeneous nodes are aggregated to obtain a global feature vector.

2. The method for obtaining global feature vectors based on smart contracts according to claim 1, characterized in that, Based on the actual execution path obtained from the transaction tracking and event logs of the smart contract, a dynamic call edge set is determined, including: Obtain a set of call records during the actual execution of smart contracts through transaction tracking and event logs; A mapping function is used to map each call record in the call record set to a directed call edge between function nodes, and all directed call edges are used to determine the dynamic call edge set.

3. The method for obtaining global feature vectors based on smart contracts according to claim 2, characterized in that... Based on the initial function call graph and dynamic call edges, a cross-contract call graph is determined. This cross-contract call graph includes a set of cross-contract call edges and a set of cross-contract nodes, including: The dynamic node set is determined based on the dynamic invocation of the edge set; The cross-contract node set is determined based on the static function node set and dynamic node set in the initial function call graph; The cross-contract call edge set is determined based on the static and dynamic call edge sets in the initial function call graph; The cross-contract call graph is determined based on the cross-contract call edge set and the cross-contract node set.

4. The method for obtaining global feature vectors based on smart contracts according to claim 3, characterized in that, Feature extraction is performed on the cross-contract call graph to obtain cross-contract node features, cross-contract call edge features, and cross-contract weight features, including: The characteristics of cross-contract call edges are determined based on function information, transaction traces, and event logs in the cross-contract call graph; The cross-contract call edge characteristics and cross-contract node set are used to determine the cross-contract weight characteristics; Cross-contract node features are determined based on the cross-contract call edge features, cross-contract weight features, and cross-contract node set.

5. The method for obtaining global feature vectors based on smart contracts according to claim 3, characterized in that... The state dependency graph is determined based on the storage slot set and the cross-contract node set. The state dependency graph includes a state dependency edge set and a state node set, comprising: A set of state nodes is determined based on the storage slot and the corresponding smart contract address, wherein the state node represents the state storage location of the smart contract's storage slot. Determine the set of state-dependent edges based on the set of state nodes and the set of cross-contract nodes; The state dependency graph is determined based on the set of state nodes and the set of state dependency edges.

6. The method for obtaining global feature vectors based on smart contracts according to claim 5, characterized in that, Feature extraction is performed on the state dependency graph to obtain state node features, state dependency edge features, and state weight features, including: Initial characteristics are determined based on the smart contract's contract address and storage slot; The characteristics of state-dependent edges are determined based on the read / write order and dependency relationship of the state-dependent edges; The state weight features are determined based on the initial features, state-dependent edge features, and state node set. The state node features are determined based on the initial features, state weight features, state dependency edge features, and state nodes in the state node set.

7. The method for obtaining global feature vectors based on smart contracts according to claim 6, characterized in that, Determining the heterogeneous graph based on the cross-contract call graph and state dependency graph includes: The heterogeneous node set is determined based on the cross-contract node set in the cross-contract call graph and the state node set in the state dependency graph. Heterogeneous call edge sets are determined based on the cross-contract call edge set in the cross-contract call graph, the state dependency edge set in the state dependency graph, and the read / write relationships between state nodes in the state dependency graph. The heterogeneous call edge set and the heterogeneous node set form a heterogeneous graph.

8. The method for obtaining global feature vectors based on smart contracts according to claim 7, characterized in that, Based on the heterogeneous graph, cross-contract node features, cross-contract call edge features, cross-contract weight features, state node features, state call edge features, and state weight features, a heterogeneous feature graph is obtained by assigning these features to the heterogeneous graph, including: Based on the cross-contract node mapping parameters, feature alignment is performed on the cross-contract node features to obtain the cross-contract node heterogeneous features. Based on the state node mapping parameters, feature alignment is performed on the state node features to obtain the heterogeneous features of the state nodes. The heterogeneous feature graph is obtained by assigning cross-contract node heterogeneous features, state node heterogeneous features, cross-contract call edge features, cross-contract weight features, state dependency edge features, and state weight features to the heterogeneous graph.

9. The method for obtaining global feature vectors based on smart contracts according to claim 8, characterized in that, For each heterogeneous node in the heterogeneous feature map, the heterogeneous node features are updated to obtain updated heterogeneous node features. The heterogeneous feature map includes heterogeneous node features, including: The cross-contract node heterogeneous features and state node heterogeneous features are used as heterogeneous node features; Based on the cross-contract call edge feature set and the cross-contract call weight feature set, determine the call relationship neighbor information; The state dependency relationship neighbor information is determined based on the state dependency edge feature set and the state weight feature set; The read and write relational neighbor information is determined based on the state dependency graph. The updated heterogeneous node characteristics are determined based on the heterogeneous node characteristics, the call to relational neighbor information, the state dependency relational neighbor information, the read relational neighbor information, and the write relational neighbor information.

10. The method for obtaining global feature vectors based on smart contracts according to claim 9, characterized in that... The method further includes: During the node feature update process, the node feature mapping parameters and aggregation parameters of different relationships are adjusted using graph structure reconstruction constraints. This ensures that the heterogeneous node features retain the original call relationships, state dependencies, and read and write relationships after the update, resulting in the updated heterogeneous node features after constraint optimization.