Application Migration Methods from Client-Server Architecture to Blockchain Architecture

By modeling and taint analysis of traditional client-server architecture applications, identifying and reconstructing key modules, the application migration from client-server architecture to blockchain architecture is realized, solving the problems of low development efficiency, high cost and insufficient security in the existing technology, and improving the development efficiency and security of blockchain applications.

CN116521791BActive Publication Date: 2025-05-02FUZHOU UNIV
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202310366690.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-04-07
Publication Date
2025-05-02
Estimated Expiration
2043-04-07

AI Technical Summary

Technical Problem

During the application migration process from the existing client-server architecture to the blockchain architecture, the existing technology has problems of low development efficiency, high cost and insufficient security.

Method used

By modeling the application of the traditional client-server architecture, abstracting it into a program call tree, defining pollution propagation rules for stain analysis, identifying the key modules of the application, and setting code reconstruction rules to refactor the methods in the key modules to realize the application migration from the client-server architecture to the blockchain architecture.

Benefits of technology

This method effectively improves the development efficiency of blockchain applications, reduces migration costs, and enhances the security of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116521791B_ABST
    Figure CN116521791B_ABST
Patent Text Reader

Abstract

The present invention provides an application migration method from a client-server architecture to a blockchain architecture, including step 1: modeling the application of the traditional client-server architecture and abstracting it into a program call tree; step 2: using key data as tainted data, defining pollution propagation rules for taint analysis, and obtaining all polluted variables in the program; step 3: identifying the key modules of the application on the program call tree according to the pollution path, setting code refactoring rules to refactor the code of the methods in the key modules according to a specific program structure. The application of this technical solution can effectively improve the development efficiency of blockchain applications.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of blockchain technology, and in particular to a method for migrating applications from a client-server architecture to a blockchain architecture. Background Art

[0002] With the rapid development of blockchain technology, many organizations are now trying blockchain solutions. In this nascent stage, due to the scarcity of experts in the blockchain field, there is a growing trend to automatically convert legacy systems to blockchain-based systems. However, the transition from existing technology to blockchain technology is a challenge. The industry usually develops blockchain solutions from scratch or only transforms the database side of the original application. The former requires a lot of time and money, and the cost is huge, while the latter cannot be well guaranteed in terms of security. Summary of the invention

[0003] In view of this, an object of the present invention is to provide an application migration method from a client-server architecture to a blockchain architecture, which can effectively improve the development efficiency of blockchain applications.

[0004] To achieve the above-mentioned purpose, the present invention adopts the following technical scheme: an application migration method from a client-server architecture to a blockchain architecture, comprising step 1: modeling an application of a traditional client-server architecture and abstracting it into a program call tree; step 2: taking key data as tainted data, defining pollution propagation rules for taint analysis, and obtaining all tainted variables in the program; step 3: identifying key modules of the application on the program call tree according to the pollution path, setting code refactoring rules to refactor the methods in the key modules according to a specific program structure.

[0005] In a preferred embodiment, the step 1 specifically includes: establishing a program call tree, constructing a program call tree of the entire program starting from the main function through static code analysis, and marking key data on the call tree; the definition of the program call tree is as follows:

[0006] Definition 1: The program structure of a client-server application is represented by a program call tree Tree r =(M,R,K), where M = {m 1 ,m 2 ,…,m n} represents the node set of the program call tree; R represents the node call relationship set of the program call tree. Any r mi-mj ∈R represents an edge of the program call tree, representing method m i Call method m j ; K = {keydata 1 ,keydata 2 ,…,keydatan} represents the key data set in the system;

[0007] Definition 2: A method node in a program call tree includes the unique identifier of the method, the call path, the method statement set, and the set of key data in the method, which is represented by a four-tuple m i = <mSign i ,mPath,U i ,kset>, where mSign represents method m i The unique identifier of mPath indicates the path from the main function to m i A method call path; kset is used to record method m i All key data in U i Representation method m i A collection of statements;

[0008] Definition 3: mSign i ={mSig|mName,mParams,returnParams} represents the unique identifier of a method node in a program call tree; mName represents the method name, mParams represents the method entry parameter list, and returnParams represents the return parameter of the method;

[0009] Definition 4: mPath = {mSig main ,mSig a ,…,mSig i} represents a program call tree method m i The calling path is from m main to m i The combination of unique identifiers of the method nodes passed through constitutes a path that can reach m i Path;

[0010] Definition 5: Represents method node m on the program call tree i A set of statements, where Representation method m i The jth statement of ;

[0011] Definition 6: The key data of a system includes the unique identifier of the method where the key data is located and the key data name, which is represented by a tuple keydata i ={mSign i ,kname}, kname represents method m i The variable named kname in the data flow, all variables on the data flow branch where the key data is located may be key variables.

[0012] In a preferred embodiment, the program calls the tree extraction algorithm with the main function m main As the entry point of the application, construct the application with m main The program call tree with the root as the root uses HashMap to record R, and the key is stored in the form of <m i ,m j >, indicating m i Call m j , and its corresponding value represents m i Call m j The number of times; the algorithm's input program entry point m main and m main The set of statements U main , any of which Indicates U main The program call tree is recursively constructed by calling the method getTree(), which takes in the parameter m a , U a Respectively represent the method to be analyzed and the statement set of the method; among them, get Soot keyword, that is, the intermediate code defined in Soot; update the M set, that is, record method m a Call method m s ; Update the R set, that is, record the method call relationship and update the weight; recursively perform getTree() on method ms; when the recursive process ends, the algorithm outputs the program call tree.

[0013] In a preferred embodiment, the pollution propagation rules of step 2 include assignment statement rules and alias statement rules that summarize various ways of propagation between polluted variables within a method; method call statement rules, method return statement rules, and method declaration statement rules describe the way polluted variables propagate across methods; first, for each method node containing key data, each statement in the method is analyzed according to the pollution propagation rules, and when a statement satisfies any pollution propagation rule, it means that a new pollution source is found, and the new pollution source is added to the taint source set for recording; wherein, when a statement satisfies the method call statement rule, the method return statement rule, or the method declaration statement rule, it means that a new method node to be analyzed is generated, and the method node needs to be added to the method node set to be analyzed for recording; after a round of analysis of all statements of the method is completed, if a new pollution source is added to the taint source set, a new round of iterative analysis of this method is started; finally, the method node set to be analyzed is traversed, and each method node in the set is analyzed one by one.

[0014] In a preferred embodiment, step 3 includes key module identification, program structure, generation of method wrappers, construction of method forwarders, and JDBC reconstruction.

[0015] In a preferred embodiment, the key module identification is specifically: when a method node m cur When the kset set of its parent method node is not empty and the kest set of its parent method node is empty, m cur The subtree with the root node is a key code module of the application; the specific definition of the key code module is as follows:

[0016] Definition 7: The key code module of an application is represented by Module = (module 1 ,module 2 …module n ), Module∈Tree r ; Among them, module i It is Tree main A subtree of represents a key code module of the application, represented by module i =<M,R> (if i≠j, ); identify key modules, take the program call tree as input, and use the root node m of the program call tree a As the entry, first take the root node m a Add to the queue of method nodes to be analyzed; when the queue is not empty, obtain the method nodes in the queue. If the pollution source set of the node method is not empty, it means that a key module is found, and all its successor nodes are method nodes in this key module; if the pollution source set of the node method is empty, obtain all its child nodes and add them to the queue of nodes to be analyzed; finally, when the set is empty, the algorithm ends.

[0017] In a preferred embodiment, the structure and calling process of the native application and the target application are first described;

[0018] The core of the target program structure consists of two elements: the method wrapper Method_T_Wrapper and the method forwarder Method_T_Proxy, whose working principle is as follows: convert the direct call between Method_I and Method_T into an indirect call via Method_T_Proxy; Method_T_Wrapper completes the same function as Method_T and is responsible for performing the actual calculation. It transforms Method_T, finds its external variable references, and transforms it into a form that is passed in through parameters and returned through return values. The transformed class method is stateless; Method_T_Proxy is the proxy mechanism of method Method_T, its external behavior is consistent with Method_T, but no actual calculation is performed; it is responsible for determining the execution location of the method, and performing control forwarding and data synchronization.

[0019] In a preferred embodiment, the steps of generating the method wrapper are:

[0020] (1) Modify the parameter list and return value of the method; add the parameter params to represent the external variables of the original method, so that the external variables can be passed into the method body in the form of parameters; add a statement to assign the parameter params to the global variable global_params, so that all methods in the key module can call their own external variables; at the same time, add global_params to the return result, so that the changes of the external variables can be returned to the method caller;

[0021] (2) Modify all statements in the method that access external variables, and replace the external variable references c and d with the corresponding input parameters global_params.c and global_params.d, so that there are no more statements in the method that access external variables;

[0022] (3) Modify all return statements of the method and add the parameter global_params to the return result so that the changes in external variables can be returned to the method caller.

[0023] In a preferred embodiment, the method forwarder construction rule:

[0024] (1) Keep the method signature and return type of the method forwarder consistent with the original method;

[0025] (2) Add statements to process additional variables; construct a variable params of the Params type and assign values ​​to params using the method's external variable information;

[0026] (3) Add statements to call the method wrapper in the fabric chaincode; in Hyperledger Fabric, call the method wrapper Method_T_Wrapper in the chaincode chaincode through the fabricManager object provided by the SDK, and send the calling parameters of the method wrapper;

[0027] (4) Add a statement to receive the return result of the method call; wherein the result data is used to update the external variables of the method to ensure the consistency of the program state, and at the same time, the method call return value is returned to its caller.

[0028] In a preferred embodiment, the JDBC-reconstructed application uses a relational database, and its use requires first defining the relational table structure, and then writing the relevant business code of the application through the JDBC API; the database operation node is a function that has an SQL statement in the node and operates the database through the JDBC API. The statement is generally the landing point or starting point of the key data in the propagation path; the JDBC API is converted into the key-value database operation API of the corresponding blockchain, and the current mainstream open source blockchain architecture Fabric chaincode is taken as the target; Fabric chaincode uses the CouchDB key-value database, and our reconstruction method is divided into the parsing and verification of SQL statements, and the operation conversion of SQL statements to CouchDB.

[0029] Compared with the prior art, the present invention has the following beneficial effects: The present invention proposes an adaptive migration framework to facilitate the migration of existing client-server architecture applications to blockchain-based applications. First, a program call tree is established. A program call tree of the entire application starting from the main function is constructed through static code analysis, and key data is marked on the call tree; then, pollution propagation rules are defined, and key data is used as tainted data for taint analysis to obtain all tainted variables in the system; finally, the key modules of the application are identified on the program call tree in combination with the pollution propagation path, and code refactoring rules are set to refactor the methods in the key modules according to a specific program structure. The method is evaluated through case studies, and the experimental results show that this method can effectively improve the development efficiency of blockchain applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 The diagram is a diagram describing the structure and calling process of the native application and the target application according to the preferred embodiment of the present invention, wherein (a) is the source program structure and (b) is the target program structure;

[0031] Figure 2 Schematic diagram of the steps of generating a method wrapper according to a preferred embodiment of the present invention, wherein (a) is a source program, and (b) is a method wrapper;

[0032] Figure 3 Schematic diagram of the method forwarder construction rules of the preferred embodiment of the present invention, wherein (a) is the source code and (b) is the method forwarder. DETAILED DESCRIPTION

[0033] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0034] It should be noted that the following detailed descriptions are illustrative and are intended to provide further explanation of the present application. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present application belongs.

[0035] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present application; as used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or their combinations.

[0036] The application migration method from the client-server architecture to the blockchain architecture, step 1: model the application of the traditional client-server architecture and abstract it into a program call tree; step 2: take the key data as tainted data, define the pollution propagation rules to perform taint analysis, and obtain all the polluted variables in the program; step 3: identify the key modules of the application on the program call tree according to the pollution path, set the code refactoring rules to refactor the methods in the key modules according to the specific program structure.

[0037] Step 1: Establish a program call tree. Through static code analysis, a program call tree is constructed for the entire program starting from the main function, and key data is marked on the call tree. The definition of the program call tree is as follows:

[0038] Definition 1: The program structure of a client-server application can be represented as a program call tree Tree r =(M,R,K), where M = {m 1 ,m 2 ,…,m n} represents the node set of the program call tree; R represents the node call relationship set of the program call tree. Any r mi-mj ∈R represents an edge of the program call tree, representing method m i Call method m j ; K = {keydata 1 ,keydata 2 ,…,keydata n} represents the key data set in the system.

[0039] Definition 2: A method node in a program call tree includes the unique identifier of the method, the call path, the method statement set, and the set of key data in the method, which can be represented by a four-tuple m i = <mSign i ,mPath,U i,kset>, where mSign represents method m i The unique identifier of mPath indicates the path from the main function to m i A method call path; kset is used to record method m i All key data in U i Representation method m i A collection of statements.

[0040] Definition 3: mSign i ={mSig|mName, mParams, returnParams} represents the unique identifier of a method node in a program call tree, where mName represents the method name, mParams represents the method entry parameter list, and returnParams represents the method return parameter.

[0041] Definition 4: mPath = {mSig main ,mSig a ,…,mSig i} represents a program call tree method m i The calling path is from m main to m i The combination of unique identifiers of the method nodes passed through constitutes a path that can reach m i Path.

[0042] Definition 5: Represents method node m on the program call tree i A set of statements, where Representation method m i The jth statement of .

[0043] Definition 6: The key data of a system includes the unique identifier of the method where the key data is located and the key data name, which can be represented by a tuple keydata i ={mSign i ,kname}, kname represents method m i The variable named kname in the data flow, all variables on the data flow branch where the key data is located may be key variables.

[0044] The program call tree extraction algorithm is as follows:

[0045]

[0046] The algorithm describes the extraction process of the program call tree. The algorithm is based on the main function m main As the entry point of the application, construct the application with m main The program call tree with the root as the root uses HashMap to record R, and the key is stored in the form of <mi ,m j >, indicating m i Call m j , and its corresponding value represents m i Call m j The algorithm's input program entry point m main and m main The set of statements U main , any of which Indicates U main Lines 2-20 recursively construct the program call tree by calling the method getTree(), which takes in the parameter m a , U a Represent the method to be analyzed and the statement set of the method respectively. Among them, line 4 obtains Soot keywords, that is, intermediate codes defined in Soot. For example, the invoke keyword indicates that this is a method call statement. For complete keyword definitions, refer to the Soot manual. If the statement contains a method call keyword, lines 6-10 update the M set, that is, record method m a Call method m s Lines 11-16 update the R set, that is, record the method call relationship and update the weight. Line 17 recursively performs getTree() on method ms. When the recursive process ends, the algorithm outputs the program call tree.

[0047] Step 2:

[0048]

[0049]

[0050]

[0051]

[0052] The table above shows the defined pollution propagation rules: the assignment statement rules and alias statement rules summarize the various ways of propagation between polluted variables within a method; the method call statement rules, method return statement rules and method declaration statement rules describe the propagation of polluted variables across methods; the sql rule summarizes the situation where polluted variables are finally gathered in the database table, which is the key table at this time, and then supplements and summarizes the situation where new polluted variables are introduced by operating the key table. :

[0053] In order to find all pollution sources, it is necessary to analyze each statement in the program according to the pollution propagation rules. First, for each method node containing key data, each statement in the method is analyzed according to the pollution propagation rules. When the statement meets any pollution propagation rules, it means that a new pollution source is found, and the new pollution source is added to the taint source set of this method for recording. Among them, when the statement meets the method call statement rule, the method return statement rule or the method declaration statement rule, it means that a new method node to be analyzed is generated, and the method node needs to be added to the method node set to be analyzed for recording. After a round of analysis of all statements of the method is completed, if a new pollution source is added to the taint source set of this method, a new round of iterative analysis of this method is started. Finally, traverse the set of method nodes to be analyzed, and analyze each method node in the set one by one. The taint propagation analysis algorithm is as follows:

[0054]

[0055]

[0056]

[0057]

[0058]

[0059]

[0060] Step 3:

[0061] 3.1 Key module identification

[0062] The key code module is the main goal of realizing the adaptive migration of client-server architecture applications to blockchain architecture. It is the interpretation of key data calls in the program call tree: when a method node m cur When the kset set of its parent method node is not empty and the kest set of its parent method node is empty, m cur The subtree with the root node is a key code module of the application. The specific definition of the key code module is as follows: Definition 7: The key code module of the application is represented by Module = (module 1 ,module 2 …module n ), Module∈Tree r . Among them, module i It is Tree main A subtree of represents a key code module of the application, which can be represented as module i =<M,R> (ifi≠j, )

[0063] Key module partitioning algorithm

[0064]

[0065] Identify the key modules, take the program call tree as input, and use the root node m of the program call tree a As the entry, first take the root node m a Add to the queue of method nodes to be analyzed; when the queue is not empty, obtain the method nodes in the queue. If the pollution source set of the node method is not empty, it means that a key module is found, and all its successor nodes are method nodes in this key module; if the pollution source set of the node method is empty, obtain all its child nodes and add them to the queue of nodes to be analyzed; finally, when the set is empty, the algorithm ends.

[0066] 3.2 Program Structure

[0067] refer to Figure 1 ,First, the organization and calling process of the native application and the target ,application are described.

[0068] The core of the target program structure consists of two elements: the method wrapper Method_T_Wrapper and the method forwarder Method_T_Proxy, which works as follows:

[0069] ① Convert the direct call from Method_I to Method_T into an indirect call via Method_T_Proxy.

[0070] ②Method_T_Wrapper performs the same functions as Method_T and is responsible for performing the actual calculation. It transforms Method_T, finds its external variable references, and transforms it into a form that is passed in through parameters and returned through return values. The transformed class method is stateless.

[0071] ③Method_T_Proxy is the proxy mechanism of method Method_T. Its external behavior is consistent with Method_T, but it does not perform actual calculations. It is responsible for determining the execution location of the method, and performing control forwarding (remote call), as well as data synchronization (including: initializing and serializing the actual parameter data required for the execution of the method wrapper, and deserializing the return value of the method wrapper to update the corresponding local variables)

[0072] 3.3 Method Wrappers

[0073] Steps to generate method wrapper:

[0074] (1) Modify the parameter list and return value of the method. Figure 2 (a) and Figure 2As shown in line 2 of (b), the parameter params is added to represent the external variables of the original method, so that the external variables can be passed into the method body in the form of parameters; a statement is added to assign the parameter params to the global variable global_params, so that all methods in the key module can call their own external variables. At the same time, global_params is added to the return result, so that the changes of the external variables can be returned to the method caller.

[0075] (2) Modify all statements in the method that access external variables, see Figure 2 (a) row 3 and Figure 2 In line 6 of (b), the external variable references c and d are replaced with the corresponding input parameters global_params.c and global_params.d, so that there are no more statements accessing external variables in the method.

[0076] (3) Modify all return statements of the method, see Figure 2 (a) row 4 and Figure 2 In lines 7-10 of (b), the parameter global_params is added to the return result so that changes in external variables can be returned to the method caller.

[0077] 3.4 Method Forwarder

[0078] Method forwarder construction rules:

[0079] (1) Keep the method signature (name, parameter list) and return type of the method forwarder consistent with the original method;

[0080] (2) Add statements to process additional variables. Construct a variable params of type Params and assign values ​​to params using the external variable information of the method;

[0081] (3) Add statements to call the method wrapper in the fabric chain code. In Hyperledger Fabric, Java applications can use Fabric-Sdk-Java to access the chain code, call the method wrapper Method_T_Wrapper in the chain code through the fabricManager object provided by the SDK, and send the calling parameters of the method wrapper.

[0082] (4) Add a statement to receive the return result of the method call. The result data is used to update the external variables of the method to ensure the consistency of the program state. Figure 3 At the same time, the method call return value is returned to its caller, see Figure 3 of 13 lines.

[0083] 3.5 JDBC Refactoring

[0084] Applications generally use relational databases, which require the definition of relational table structures before writing relevant business codes through the JDBC API. A database operation node is a function that contains SQL statements in the node and operates the database through the JDBC API. This statement is generally the landing point or starting point of key data in the propagation path.

[0085] Since most blockchain databases use key-value databases and do not support SQL operations, the reconstruction requires converting the JDBC API into the key-value database operation API of the corresponding blockchain. Here, the current mainstream open source blockchain architecture Fabricchaincode is used as the target.

[0086] Fabric chaincode uses the CouchDB key-value database. Our reconstruction method is divided into the parsing and verification of SQL statements and the conversion of SQL statements to CouchDB operations.

[0087] Experimental Evaluation

[0088] In order to verify the effectiveness and feasibility of this method, an experimental evaluation is conducted on this method. 10 web open source applications are collected from GitHub and the United Development Network. The experimental environment is as follows:

[0089] Tool Name Version Number illustrate Hyperledger Fabric 2.2.5 Hyperledger docker 20.10.20 Container management tools docker-compose 1.24.1 Container deployment tools java 1.8.0 programming language

[0090] Application performance comparison: The performance of the blockchain application reconstructed by this method is compared with the blockchain application developed by professionals, mainly evaluating the read and write performance of the application. Apache JMeter, a stress testing tool developed by the Apache organization based on Java, is used to stress test the Web application, and the test indicator is the number of transactions processed per second (tps). The two schemes of each system are stress tested 10 times respectively, and the average value is taken. The experimental results show that the use of this framework for blockchain application development improves the efficiency of blockchain application development while causing performance loss within 8%.

[0091]

[0092]

Claims

1. A method for migrating applications from a client-server architecture to a blockchain architecture, characterized in that It includes,step 1: modeling the application of traditional client-server architecture and abstracting it into a program call tree; Step 2: Take the key data as tainted data, define the pollution propagation rules to perform taint analysis, and obtain all the polluted variables in the program; Step 3: Identify the key modules of the application on the program call tree according to the pollution path, set the code refactoring rules to refactor the methods in the key modules according to the target program structure; The step 1 is specifically as follows: establishing a program call tree, constructing a program call tree of the entire program starting from the main function through static code analysis, and marking key data on the call tree; the definition of the program call tree is as follows: Definition 1: The program structure of a client-server application is represented by a program call tree Tree r =(M,R,K), where M = {m1,m2,…,m n } represents the node set of the program call tree; R represents the node call relationship set of the program call tree. Any r mi-mj ∈R represents an edge of the program call tree, representing method m i Call method m j ;K={keydata1,keydata2,…,keydata n } represents the key data set in the system; Definition 2: A method node in a program call tree includes the unique identifier of the method, the call path, the method statement set, and the set of key data in the method, which is represented by a four-tuple m i = <mSign i ,mPath,U i ,kset>, where mSign i Representation method m i unique identifier; mPath indicates the path from the main function to m i A method call path; kset is used to record method m i All key data in U i Representation method m i A collection of statements; Definition 3: mSign i ={mSig\mName,mParams,returnParams} represents the unique identifier of a method node in a program call tree; mName represents the method name, mParams represents the method entry parameter list, and returnParams represents the return parameter of the method; Definition 4: mPath = {mSig main ,mSig a ,…,mSig i } represents a program call tree method m i The calling path is from m main to m i The combination of unique identifiers of the method nodes passed through constitutes a path that can reach m i Path; Definition 5: Represents method node m on the program call tree i A set of statements, where u i j Representation method m i The jth statement of ; Definition 6: The key data of a system includes the unique identifier of the method where the key data is located and the key data name, which is represented by a tuple keydata i ={mSign i ,kname}, kname represents method m i The variable named kname in the data flow where all key data are located may be key variables.

2. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 1, characterized in that: The algorithm for extracting the program call tree is based on the main function m main As the entry point of the application, construct the application with m main The program call tree with R as the root is recorded using HashMap. The key is stored in the form of <m i ,m j >, indicating m i Call m j , and its corresponding value represents m i Call m j The number of times; the algorithm's input program entry point m main and m main The set of statements U main , any of which Indicates U main The program call tree is recursively constructed by calling the method getTree(), which takes as parameter m a , U a Respectively represent the method to be analyzed and the statement set of the method; among them, get Soot keyword, that is, the intermediate code defined in Soot; update the M set, that is, record method m a Call method m s ; Update the R set, that is, record the method call relationship and update the weight; for method m a Perform getTree() recursion; when the recursive process ends, the algorithm outputs the program call tree.

3. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 1, characterized in that: The pollution propagation rules of step 2 include the assignment statement rules and the alias statement rules, which summarize various ways of propagation between polluted variables within a method; the method call statement rules, the method return statement rules and the method declaration statement rules describe the propagation methods of polluted variables across methods; first, for each method node containing key data, each statement in the method is analyzed according to the pollution propagation rules, and when the statement satisfies any pollution propagation rule, it means that a new pollution source is found, and the new pollution source is added to the taint source set for recording; wherein, when the statement satisfies the method call statement rule, the method return statement rule or the method declaration statement rule, it means that a new method node to be analyzed is generated, and the method node needs to be added to the method node set to be analyzed for recording; after a round of analysis of all statements of the method is completed, if a new pollution source is added to the taint source set, a new round of iterative analysis of this method is started; finally, the method node set to be analyzed is traversed, and each method node in the set is analyzed one by one.

4. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 1, characterized in that: The step 3 includes key module identification, program structure, generation of method wrapper, construction of method forwarder and JDBC reconstruction.

5. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 4, characterized in that: The key module identification is specifically as follows: when a method node m cur When the kset set of its parent method node is not empty and the kest set of its parent method node is empty, m cur The subtree with the root node is a key code module of the application; the specific definition of the key code module is as follows: Definition 7: The key code module of an application is represented by Module = (module1, module2…module n ), Module∈Tree r ; Among them, module i It is Tree r A subtree of represents a key code module of the application, represented by module i =<M,R> (if i≠j, ); identify key modules, take the program call tree as input, and use the root node m of the program call tree a As the entry, first take the root node m a Add to the queue of method nodes to be analyzed; when the queue is not empty, obtain the method nodes in the queue. If the pollution source set of the node method is not empty, it means that a key module is found, and all its successor nodes are method nodes in this key module; if the pollution source set of the node method is empty, obtain all its child nodes and add them to the queue of nodes to be analyzed; finally, when the set is empty, the algorithm ends.

6. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 4, characterized in that: First, the organization and calling process of the native application and the target application are described; The core of the target program structure consists of two elements: method wrapper Method_T_Wrapper and method forwarder Method_T_Proxy, which works as follows: convert the direct call between Method_I and Method_T into an indirect call via Method_T_Proxy; Method_T_Wrapper performs the same functions as Method_T and is responsible for performing the actual calculation. It transforms Method_T, finds its external variable references, and transforms it into a form in which it is passed in through parameters and returned through return values. The transformed class method is stateless. Method_T_Proxy is the proxy mechanism of method Method_T. Its external behavior is consistent with Method_T, but it does not perform actual calculations. It is responsible for determining the execution location of the method, and performing control forwarding and data synchronization.

7. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 4, characterized in that: Steps to generate method wrapper: (1) Modify the parameter list and return value of the method; add the parameter params to represent the external variables of the original method, so that the external variables can be passed into the method body in the form of parameters; add a statement to assign the parameter params to the global variable global_params, so that all methods in the key module can call their own external variables; at the same time, add global_params to the return result, so that the changes of the external variables can be returned to the method caller; (2) Modify all statements in the method that access external variables, and replace the external variable references c and d with the corresponding input parameters global_params.c and global_params.d, so that there are no more statements in the method that access external variables; (3) Modify all return statements of the method and add the parameter global_params to the return result so that the changes in external variables can be returned to the method caller.

8. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 4, characterized in that: Method forwarder construction rules: (1) Keep the method signature and return type of the method forwarder consistent with the original method; (2) Add statements to process additional variables; construct a variable params of type Params and assign values ​​to params using the external variable information of the method; (3) Add statements to call the method wrapper in the Fabric chaincode; in Hyperledger Fabric, call the method wrapper Method_T_Wrapper in the chaincode chaincode through the fabricManager object provided by the SDK, and send the calling parameters of the method wrapper; (4) Add a statement to receive the return result of the method call; wherein the result data is used to update the external variables of the method to ensure the consistency of the program state, and at the same time, the method call return value is returned to its caller.

9. The method for migrating applications from a client-server architecture to a blockchain architecture according to claim 4, characterized in that: JDBC refactored applications use relational databases. To use them, you need to define the relational table structure first, and then write the relevant business code of the application through the JDBC API. A database operation node is a node that contains SQL statements and operates the database through the JDBC API. This statement is generally the landing point or starting point of key data in the propagation path; Convert JDBC API to the key-value database operation API of the corresponding blockchain. Here, the current mainstream open source blockchain architecture Fabricchaincode is taken as the target; Fabricchaincode uses CouchDB key-value database. Our reconstruction method is divided into SQL statement parsing and verification, and SQL statement to CouchDB operation conversion.

Citation Information

Patent Citations

  • SQL (Structured Query Language) access method oriented to Hyperledger Fabric

    CN113157723A