Gating lifelong learning method for multi-smart contract vulnerability detection

Through the lifelong gating learning method, combined with the class diagram neural network and the class gated loop unit, the message retention mechanism and EWC regularization item are adopted, which solves the problem that smart contract vulnerability detection methods are difficult to cope with new and complex vulnerabilities, and realizes accurate detection of new vulnerabilities and long-term memory of old vulnerabilities information.

CN120145384APending Publication Date: 2025-06-13FUJIAN NORMAL UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510061867.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-15
Publication Date
2025-06-13

AI Technical Summary

Technical Problem

The existing smart contract vulnerability detection methods cannot effectively deal with new and complex vulnerabilities, and the model is difficult to continuously learn new vulnerability features, which lacks sufficient flexibility for new attacks.

Method used

The gated lifelong learning method is adopted, and the gated loop unit is combined with the message retention mechanism and EWC regularization term to achieve accurate detection of new smart contract vulnerabilities and long-term memory of old vulnerability information.

Benefits of technology

Accurate detection of new types of smart contract vulnerabilities is achieved, avoiding the model from forgetting learned vulnerability information, maintaining long-term identification of historical vulnerabilities types, and continuously enhancing the ability to detect new vulnerabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120145384A_ABST
    Figure CN120145384A_ABST
Patent Text Reader

Abstract

The invention discloses a multi-smart contract vulnerability detection-oriented gating lifelong learning method. The method comprises the steps of converting each smart contract source code into a contract graph; converting graph data of the contract graph into an embedded vector; the node state is initialized at the time step # imgabs0 #, and the state of the node at the first time step is calculated; for a # imgabs1 # time step, carrying out a message passing process of a class graph neural network to obtain a graph embedding vector; for a # imgabs2 time step, carrying out a message transmission process of a class gating circulation unit to obtain a new hidden state of the node; performing round iteration on the # imgabs3 # to obtain a final representation of each node, and then performing average pooling processing; summarizing the final representation of each node to calculate the representation of the graph level; constructing a graph-level intelligent contract vulnerability detection model, and generating a prediction label; a Fisher information matrix of weight parameters is estimated after each task is trained; and when the subsequent next task is trained, adding an EWC regularization item into the total loss. According to the invention, accurate detection of the novel vulnerability of the smart contract is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the fields of blockchain technology and artificial intelligence technology, and particularly to a gated lifelong learning method for multi-smart contract vulnerability detection. Background Art

[0002] With the rapid development of blockchain technology, smart contracts have been widely used in many fields such as finance, the Internet of Things, and supply chain. In blockchain technology, smart contracts are used to automatically execute and verify contract terms. However, the security vulnerability problems of smart contracts have gradually attracted wide attention. Common vulnerabilities such as re-entrancy attacks and integer overflows have brought serious security threats to the blockchain ecosystem, such as fund loss and data leakage. Most of the existing smart contract vulnerability detection methods are based on static or dynamic analysis, which cannot effectively deal with new and complex vulnerabilities, and the models are difficult to continuously learn new vulnerability features, and there is a problem of lack of sufficient flexibility for new attacks. Lifelong learning is a technology that enables a model to continuously learn and improve from new data, has long-term memory ability, helps to overcome the problem of "catastrophic forgetting" of traditional machine learning models, and is suitable for dynamically changing security environments. Summary of the Invention

[0003] The purpose of the present invention is to provide a gated lifelong learning method for multi-smart contract vulnerability detection. Through the lifelong learning mechanism, continuously learn and accumulate knowledge from newly added smart contract data, realize the accurate detection of new smart contract vulnerabilities while avoiding the model forgetting the learned vulnerability information, and also through the message retention mechanism, retain the original information and enhance the expression ability of the model.

[0004] The technical solution adopted by the present invention is as follows:

[0005] A gated lifelong learning method for multi-smart contract vulnerability detection, which includes the following steps:

[0006] Step 1, for each smart contract in the set of smart contracts containing multiple vulnerabilities , convert the smart contract source code into a contract graph, that is, expressed as , where each node has a feature vector , and each edge has a feature vector ;

[0007] Further, the specific steps of Step 1 are as follows:

[0008] Step 1-1, for the custom or built-in functions that are closely related to the vulnerabilities, set them as sensitive nodes; for the global variables or key variables of the contract, set them as dependent nodes; for the functions related to the fallback function, set them as fallback nodes;

[0009] Step 1-2: For the control flow path, set it as a control flow edge; for the propagation and use of variable values, set it as a data flow edge; for the call relationship between functions, set it as a call edge.

[0010] Step 1-3: For the temporal relationship of tasks, extract the edge features as a tuple , which is used to simulate the relationship between nodes, where and represent the source node and the destination node, represents the chronological order;

[0011] Step 2: Convert the graph data into an embedding vector as the input of the model;

[0012] Step 3: At time step 0, the node state is initialized to , if it is for the state of node at the first time step, then it can be composed of the input vector and an additional zero vector: ;

[0013] Step 4: For each round of message passing , perform the message passing process of the graph neural network to obtain the graph embedding vector ;

[0014] Furthermore, the specific method for obtaining the graph embedding vector in Step 4 is as follows:

[0015] Step 4-1: Initialize the hidden state of each node ;

[0016] Step 4-2: Information generation: Each node receives information from all its adjacent nodes , and the information is usually the feature representation of the adjacent nodes processed by the edge weight ;

[0017] Step 4-3: Information aggregation: Node aggregates the information received from all adjacent nodes , usually through summation or averaging operations;

[0018] Step 4-4: The graph embedding vector is obtained from the adjacency matrix , the hidden states of adjacent nodes, and the bias value :

[0019]

[0020] where, is the transpose of the adjacency matrix ; is the embedding vector of node at time ; represents the set of all nodes; represents the number of all nodes; is the -th node's hidden state at time , where ; is the transpose of the hidden state ;

[0021] Step 5, for each round of message passing , perform the message passing process of the gated recurrent unit to obtain the new hidden state of the node;

[0022] Furthermore, the specific steps in Step 5 are as follows:

[0023] Step 5-1, the calculation method of the update gate Z is: ;

[0024] Step 5-2, the calculation method of the reset gate r is: ;

[0025] Step 5-3, use the information of neighboring nodes and the previous hidden state to calculate the new candidate hidden state: ; where and are trainable matrix parameters;

[0026] Step 5-4, after receiving the information, the node updates its hidden state by aggregating all the received information and the previous state information. The final update of the hidden state: ;

[0027] Step 6, after performing rounds of message passing of the graph neural network and message passing iteration of the gated recurrent unit, the final representation of each node will be obtained. Then perform average pooling, that is, for each node, calculate the average value of the features of its neighbor nodes;

[0028] Step 7, in order to adapt to graph-level supervised learning, after rounds of iteration, it is necessary to aggregate these representations through the readout function to calculate the graph-level representation. In the readout stage, the final hidden states of all nodes are used to calculate the label of graph , and at the same time, a message retention mechanism is adopted, where the initial message is directly added to the finally updated message, and then the node representations of each graph are integrated into a unified graph representation: ;

[0029] Step 8, a graph-level smart contract vulnerability detection model was constructed by applying a multi-layer perceptron (MLP) and a Sigmoid layer to the graph representation, generating a prediction label , that is: ; where is the bias value;

[0030] Step 9, estimate the Fisher information matrix of the weight parameters (i.e., the importance of the parameters) after training each task . When training subsequent tasks , the present invention adds an EWC regularization term to the total loss to limit the significant change of important parameters in the previous several tasks;

[0031] Furthermore, the specific steps of Step 9 are as follows:

[0032] Step 9-1, if the task , only calculate the task loss , and the total loss is the task loss, and end the current task; where is the predicted value, generated by the sigmoid function in Step 8, is the label (true value);

[0033] Step 9-2, if the task , first calculate the task loss ;

[0034] 9-3, for the current task , calculate the EWC loss: , is the weight parameter of the current task, is the optimal parameter of the previous task, is the weight of the Fisher information; furthermore, the specific steps of calculating the EWC loss in Step 9-3 are as follows:

[0035] Step 9-3-1, the input is the previous model parameters , the Fisher information matrix , the old task parameters , the regularization strength ;

[0036] Step 9-3-2, initialize the EWC loss ;

[0037] Step 9-3-3, for each parameter in, perform the following loop steps:

[0038] Step 9-3-3-1, calculate the parameter difference: ;

[0039] Step 9-3-3-2, calculate the contribution of EWC to the parameter ;

[0040] Step 9-3-3-3, include the loss in the total EWC loss: ;

[0041] Step 9-3-4, return the final as the EWC loss for the current task ; ;

[0042] Step 9-4, add the EWC regularization term to the total loss:

[0043] Step 9-5, update the parameters using backpropagation to optimize the model. The specific steps are as follows:

[0044] Step 9-5-1, the inputs are the task-specific loss , the EWC loss (if applicable), the model parameters , the learning rate ;

[0045] Step 9-5-2, if i > 1: , otherwise: ; where is a global variable representing the loss result of task ;

[0046] Step 9-5-3, calculate the gradient of the total loss with respect to the model parameters : ;

[0047] Step 9-5-4, update the model parameters using gradient descent or an adaptive optimizer : ;

[0048] Step 9-5-5, return the updated model parameters .

[0049] Step 10, use the trained smart contract vulnerability detection model to detect vulnerabilities in the new smart contract and output the prediction result.

[0050] Specifically, in Step 10, the new smart contract is processed according to Steps 1-9, and the model will output a predicted value of 1 or 0. If the predicted value is 1, the contract has vulnerabilities; if it is 0, the contract is secure.

[0051] The present invention adopts the above technical solution. By learning a function with parameters, it can relate the task objective to the feature vector related to the node and the feature vector related to the edge , minimize the predefined loss on the new task without destroying the previously learned tasks and potentially improving the performance of the previously learned tasks, and then estimate the objective for each smart contract. Indicates that there is a certain type of vulnerability in the smart contract, while indicates that it is secure. In the experiment, the reentrancy vulnerability (Task A) and the timestamp vulnerability (Task B) are trained in sequence and compared with other methods. To verify the stability of memory, the trained model is evaluated on the test set of Task A as the baseline performance. Then, Task B is introduced and the model is further trained based on Task A to obtain a new model. After that, the test set of Task A is used again for evaluation.

[0052] The effective effects of the present invention are as follows: 1. Adopt the message retention mechanism to directly add the initial message to the message finally updated in each layer. This method helps to retain the original information and enhance the expression ability of the model. 2. EWC ensures that the model does not overly modify the knowledge of the old task when learning a new task by constraining the weights of important model parameters. Through this mechanism, the model can retain the effect of detecting old vulnerabilities while maintaining the ability to detect new vulnerabilities. 3. The model can maintain the long-term recognition of historical vulnerability types while continuously enhancing the ability to detect new vulnerabilities. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] The present invention will be further described in detail below in conjunction with the drawings and specific embodiments;

[0054] Figure 1 FIG. is a schematic diagram of the system framework adopted by a gated lifelong learning method for multi-smart contract vulnerability detection according to the present invention;

[0055] Figure 2 FIG. is a flowchart of a gated lifelong learning method for multi-smart contract vulnerability detection according to the present invention;

[0056] Figure 3 FIG. is a schematic diagram of the EWC mechanism in a gated lifelong learning method for multi-smart contract vulnerability detection according to the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0057] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of this application.

[0058] Deep learning-based methods for detecting smart contract vulnerabilities usually only excel in single-task performance and cannot handle continuous data streams. Additionally, due to storage limitations or privacy issues, they are unable to adjust their behavior when data is temporarily available. The objective of the present invention is to be able to utilize the knowledge in previously processed smart contracts when dealing with new tasks, continuously learn and accumulate knowledge in new tasks, and apply the acquired knowledge to subsequent tasks. To achieve this goal, first, based on the data and control dependencies between program statements, the smart contract source code is transformed into a contract graph, so that the graph data can be converted into embedding vectors as the input of the model. After rounds of iterative message passing of the graph neural network for class diagrams and message passing of the gated recurrent unit for classes, the final representation of each node can be obtained.

[0059] To capture the rich semantic dependencies between nodes, the present invention also conducts different analyses on different edges. Control flow edges help understand the execution logic and sequence of the program; data flow edges help track data flows and data dependencies; call edges help understand the interactions and call hierarchies between functions.

[0060] The present invention proposes a method that can achieve continuous learning ability in smart contract vulnerabilities. To achieve this goal, after training for each task t, the present invention estimates the Fisher information matrix of the weight parameters. When training a new task , the present invention introduces an EWC regularization term into the total loss to prevent significant changes in the important parameters of the previous task. EWC restricts parameter changes to the shared area between task A and task B, ensuring the retention of the knowledge of task A (as Figure 3 shown). By introducing the EWC regularization term, the present invention restricts the changes in model parameters, retains important knowledge, and effectively reduces the forgetting of the knowledge of the previous task during the training of the new task. This enables the model to continuously learn new tasks while maintaining good performance on previous tasks.

[0061] To adapt to graph-level supervised learning, in the readout stage, the final hidden states of all nodes are read to calculate the label of the graph, and the node representations of each graph are integrated into a graph representation. Finally, a graph-level smart contract vulnerability detection model is constructed by applying a multi-layer perceptron (MLP) and a Sigmoid layer to the graph representation to generate prediction labels .

[0062] The present invention conducts experiments using reentrancy vulnerabilities and timestamp dependency vulnerabilities. Reentrancy vulnerabilities are common and serious security vulnerabilities in smart contracts. This vulnerability occurs when a contract fails to properly manage the order of state updates during an external call, allowing an external contract to call back into the functions of the original contract in its callback function. Attackers can take advantage of differences in contract state updates to repeatedly execute functions and perform unexpected operations, including multiple fund transfers. The timestamp dependency vulnerability occurs when a smart contract relies on the blockchain timestamp to perform critical operations or trigger certain events. The reason for this vulnerability is that Ethereum miners can freely set the block timestamp within a very short time interval (<900 seconds). Therefore, miners may manipulate the block timestamp to obtain illegal benefits. The present invention first trains reentrancy vulnerabilities and timestamp dependency vulnerabilities separately to obtain a detection model. The present invention randomly selects 80% of the contracts in the dataset as the training set, and the remaining contracts as the test set. The reentrancy vulnerability is represented as task A, and the timestamp dependency vulnerability is represented as task B. The performance metrics are calculated on the test set as the baseline performance for these two types of tasks. The present invention assumes that tasks A and B arrive sequentially, and the training samples are incremented batch by batch. Once the data is observed, it is no longer available. The objective of the present invention is to propose the GLN model and use this model to train tasks A and B sequentially. By comparing with the method that only uses stochastic gradient descent and the method that combines Dropout regularization, the present invention focuses on the forgetting rate to prove that the EWC method can better adapt to and perform lifelong learning. At the same time, it is also compared with four other neural network-based methods to ensure that the method using EWC maintains a low forgetting rate while the overall performance is not adversely affected.

[0063] As Figures 1 to 3 shown in one of them, the present invention discloses a gated lifelong learning method for multi-smart contract vulnerability detection, which includes the following steps:

[0064] 1) For each smart contract in the set of smart contracts containing multiple vulnerabilities , convert the smart contract source code into a contract graph, which is represented as , where each node has a feature vector , and each edge has a feature vector ; The specific steps of step 1 are:

[0065] 1-1, for custom or built-in functions that are closely related to vulnerabilities, set them as sensitive nodes; for global variables or key variables of the contract, set them as dependent nodes; for functions related to the fallback function, set them as fallback nodes;

[0066] 1-2. For the control flow path, it is set as a control flow edge; for the propagation and use of variable values, it is set as a data flow edge; for the call relationship between functions, it is set as a call edge.

[0067] 1-3. For the temporal relationship of tasks, extract the edge features as a tuple , used to simulate the relationship between nodes, where and represent the source node and the destination node, representing the chronological order;

[0068] 2) Convert the graph data into an embedding vector as the input of the model;

[0069] 3) At time step , the node state is initialized to . If it is the state of node at the first time step, then it can be composed of the input vector and an additional zero vector: ;

[0070] 4) For each round of message passing , perform the message passing process of the graph neural network to obtain the graph embedding vector ; The specific method for obtaining the graph embedding vector in step 4 is as follows:

[0071] 4-1. Initialize the hidden state of each node ;

[0072] 4-2. Information generation: Each node receives information from all its neighboring nodes . The information is usually the feature representation of the neighboring nodes processed by the edge weight ;

[0073] 4-3. Information aggregation: Node aggregates the information received from all neighboring nodes , usually through summation or averaging operations;

[0074] 4-4. The graph embedding vector is obtained from the adjacency matrix , the hidden states of neighboring nodes, and the bias value :

[0075]

[0076] where is the transpose of the adjacency matrix ; is the node At time the embedded vector; represents the set of all nodes; represents the number of all nodes; is the -th node's hidden state at time , where ; is the transpose of the hidden state ;

[0077] 5) For each round of message passing , perform the message passing process of the gated recurrent unit to obtain the new hidden state of the node; The specific method in step 5 is:

[0078] 5-1, The calculation method of the update gate Z is: ;

[0079] 5-2, The calculation method of the reset gate r is: ;

[0080] 5-3, Calculate the new candidate hidden state using the information of neighboring nodes and the previous hidden state: ; where and are trainable matrix parameters;

[0081] 5-4, After receiving the information, the node updates its hidden state by aggregating all the received information and the previous state information. The final update of the hidden state: ;

[0082] 6) After m rounds of message passing of the graph neural network and message passing iteration of the gated recurrent unit, the final representation of each node will be obtained. Then perform average pooling, that is, for each node, calculate the average value of the features of its neighbor nodes;

[0083] 7) To adapt to graph-level supervised learning, after rounds of iteration, it is necessary to aggregate these representations through the readout function to calculate the graph-level representation. In the readout stage, the final hidden states of all nodes are used to calculate the label of the graph , and at the same time, a message retention mechanism is adopted, where the initial message is directly added to the finally updated message, and then the node representations of each graph are integrated into a unified graph representation: ;

[0084] 8) By applying a multi-layer perceptron (MLP) and a Sigmoid layer to the graph representation, a graph-level smart contract vulnerability detection model is constructed to generate a prediction label , that is:

[0085] ; among which,

[0086] 9) After completing the training of each task estimate the Fisher information matrix of the weight parameters (i.e., the importance of the parameters). When training subsequent tasks , the present invention adds an EWC regularization term to the total loss to limit the significant change of important parameters in the previous several tasks; the specific steps of step 9 are as follows:

[0087] 9-1, if the task , only calculate the following task loss:

[0088] ,

[0089] among which, is the predicted value, generated by the sigmoid function in step 8, is the label (true value);

[0090] Let the total loss be the task loss, and then jump out of task 9;

[0091] 9-2, if the task , first calculate the task loss ;

[0092] 9-3, for each task , calculate the EWC loss: , is the weight parameter of the current task, is the optimal parameter of the previous task, is the weight of the Fisher information; the specific method for calculating the EWC loss is as follows:

[0093] 9-3-1, the input is the previous model parameter , the Fisher information matrix , the old task parameter , the regularization strength ;

[0094] 9-3-2, initialize the EWC loss ;

[0095] 9-3-3, for each parameter in, execute the following loop steps:

[0096] 9-3-3-1, calculate the parameter difference: ;

[0097] 9-3-3-2, Calculate the contribution of EWC to the parameters ,

[0098] 9-3-3-3, Incorporate the loss into the total EWC loss: ;

[0099] 9-3-4, Return the final as the EWC loss for the current task ;

[0100] 9-4, Add the EWC regularization term to the total loss: ;

[0101] 9-5, Update the parameters using backpropagation to optimize the model. The specific steps are as follows:

[0102] 9-5-1, The inputs are the task-specific loss , the EWC loss (if applicable), the model parameters , the learning rate ;

[0103] 9-5-2, If i > 1: , otherwise: where is a global variable representing the loss result of task ;

[0104] 9-5-3, Calculate the gradient of the total loss with respect to the model parameters : ;

[0105] 9-5-4, Update the model parameters using gradient descent or an adaptive optimizer : ;

[0106] 9-5-5, Return the updated model parameters ;

[0107] Step 10, Detect vulnerabilities in the new smart contract using the trained smart contract vulnerability detection model and output the prediction result.

[0108] Specifically, in Step 10, the new smart contract is processed according to Steps 1-9, and the model will output a predicted value of 1 or 0. If the predicted value is 1, the contract has vulnerabilities; if it is 0, the contract is secure.

[0109] The present invention adopts the above technical solution. By learning the function with as the parameter, it can map the task objective to the node-related feature vector Eigenvectors related to edges are associated to minimize a predefined loss on a new task , while not disrupting previously learned tasks and potentially improving the performance of previously learned tasks, and then estimating the objective for each smart contract . Indicates that there is a certain type of vulnerability in the smart contract, while indicates it is secure. In the experiment, the reentrancy vulnerability (Task A) and the timestamp vulnerability (Task B) are trained in sequence and compared with other methods. To verify the stability of memory, the trained model is evaluated on the test set of Task A as the baseline performance. Then, Task B is introduced and the model is further trained based on Task A to obtain a new model. After that, the test set of Task A is used for evaluation again.

[0110] The effective effects of the present invention are as follows: 1. Adopting a message retention mechanism, the initial message is directly added to the message finally updated in each layer. This method helps to retain the original information and enhance the expressive ability of the model. 2. EWC ensures that the model does not overly modify the knowledge of the old task when learning a new task by constraining the weights of important model parameters. Through this mechanism, the model can retain the effect of old vulnerability detection while maintaining the ability to detect new vulnerabilities. 3. The model can maintain long-term recognition of historical vulnerability types while continuously enhancing the ability to detect new vulnerabilities.

[0111] Obviously, the described embodiments are part of the embodiments of the present application, rather than all of the embodiments. Without conflict, the embodiments and the features in the embodiments of the present application can be combined with each other. Usually, the components of the embodiments of the present application described and illustrated in the accompanying drawings here can be arranged and designed in various different configurations. Therefore, the detailed description of the embodiments of the present application is not intended to limit the scope of the present application claimed, but merely represents the selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts fall within the scope of protection of the present application.

Claims

1. A gated lifelong learning method for multi-smart contract vulnerability detection, characterized by: It includes the following steps: Step 1: For each smart contract in the set of smart contracts containing multiple vulnerabilities , converting the smart contract source code into a contract graph, which is represented as , where each node There is a feature vector , each edge There is a feature vector ; Step 2: Convert the graph data into an embedding vector as the input of the model; Step 3, at time step ,node The state is initialized to , and calculate the node The state at the first time step ; Step 4: For time steps, perform the message passing process of the graph neural network, and obtain the graph embedding vector ; Step 5: For time steps, perform the message passing process of the gated recurrent unit to obtain the new hidden state of the node; Step 6, overall progress After iterating the graph neural network message passing and gated recurrent unit message passing, the final representation of each node is obtained, and then the average pooling process is performed, that is, for each node, the average value of the features of its neighboring nodes is calculated; Step 7, by reading out the function Aggregate the final representation of each node to compute a graph-level representation; Step 8: Apply the multi-layer perceptron MLP and Sigmoid layer to the graph representation, build a graph-level smart contract vulnerability detection model, and generate prediction labels. ,Right now: ; Step 9: After completing each task Fisher information matrix of estimated weight parameters after training; in training subsequent tasks When , the EWC regularization term is added to the total loss to update the model parameters to obtain the trained smart contract vulnerability detection model; Step 10: Use the trained smart contract vulnerability detection model to perform vulnerability detection on the new smart contract and output the prediction results.

2. A gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: The specific steps of step 1 are: Step 1-1: For calls to custom or built-in functions that are closely related to the vulnerability, set them as sensitive nodes; for global variables or key variables of the contract, set them as dependent nodes; for functions related to the fallback function, set them as fallback nodes; Step 1-2: For the control flow path, set it as a control flow edge; for the propagation and use of variable values, set it as a data flow edge; for the calling relationship between functions, set it as a call edge; Step 1-3: For the temporal relationship of the task, extract the edge features as tuples , used to simulate the relationship between nodes, where and Represents the source node and the destination node, Represents time sequence.

3. A gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: Node in step 3 The state at the first time step By input vector and an additional zero vector: ;in, is the input vector The transpose of Matches the shape of the zero vector in the concatenation dimension.

4. A gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: The specific method for obtaining the graph embedding vector in step 4 is: Step 4-1, initialize each node The hidden state ; Step 4-2, information generation: Each node All neighboring nodes receive The information is usually the neighboring nodes Edge weight Feature representation after processing; Step 4-3, Information Aggregation: Node Aggregate from all neighboring nodes The information received is usually summed or averaged; Step 4-4, the graph embedding vector is obtained by the adjacency matrix , the hidden states and bias values ​​of adjacent nodes It turns out that: in, is the adjacency matrix The transpose of Is a node In time The embedding vector of Represents the set of all nodes; Indicates the number of all nodes; It is Nodes at time The hidden state of ; It is a hidden state The transpose of .

5. The gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: The specific steps in step 5 are: Step 5-1, the calculation method of updating gate Z is: ; Step 5-2, the calculation method of the reset gate r is: ; Step 5-3, use the information of neighboring nodes and the previous hidden state to calculate the new candidate hidden state: ;in, and is a trainable matrix parameter; Step 5-4, after receiving the information, the node updates the hidden state by summarizing all received information and previous state information; the final update expression of the hidden state is: .

6. The gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: In step 7, during the readout phase, the final hidden states of all nodes are used to compute the graph ; at the same time, a message retention mechanism is adopted, the initial message is directly added to the final updated message, and then the node representation of each graph is integrated into a unified graph representation: ;in, Is a node The final node state is the output result obtained after the message is passed through the GRU class.

7. The gated lifelong learning method for multi-smart contract vulnerability detection according to claim 1, characterized in that: The specific steps of step 9 are: Step 9-1, if the task , only calculate the task loss , the total loss is the task loss, and the current task ends; among them, is the predicted value, generated by the sigmoid function; is the label, i.e. the true value; Step 9-2, if the task , first calculate the task loss ; Step 9-3, for the current task , calculate the EWC loss: , is the weight parameter of the current task, is the optimal parameter of the previous task, is the weight Fisher information; Step 9-4, add the EWC regularization term to the total loss: ; Is a global variable, indicating the task the loss results; In step 9-5, back propagation is used to update parameters and optimize the model.

8. A gated lifelong learning method for multi-smart contract vulnerability detection according to claim 7, characterized in that: The specific steps for calculating EWC loss in step 9-3 are: Step 9-3-1, input is the current model parameters , Fisher information matrix , old task parameters , regularization strength ; Step 9-3-2, initialize EWC loss ; Step 9-3-3, for Each parameter in , perform the following loop steps: Step 9-3-3-1, calculate the parameter difference: ; Step 9-3-3-2, calculate the contribution of EWC to the parameters ; Step 9-3-3-3, include the loss in the EWC total loss: ; Step 9-3-4, return to the final As current task EWC loss .

9. A gated lifelong learning method for multi-smart contract vulnerability detection according to claim 7, characterized in that: In step 9-5, back propagation is used to optimize the model. The specific steps are as follows: Step 9-5-1, input is task specific loss , loss , model parameters , learning rate ; Step 9-5-2, if you judge Is it true? If so, then ; otherwise, ; Step 9-5-3, calculate the total loss relative to the model parameters The gradient of is expressed as: ; Step 9-5-4, update model parameters using gradient descent or adaptive optimizer , the specific expression is: ; Step 9-5-5, return the updated model parameters .