Method and device for tracking smart contract in state channel applied to block chain
By using pre-constructed tracking data structures in the status channel of the blockchain, the problem of difficult observation of smart contract execution is solved, zero-intrusion tracking and detailed process recording of smart contracts are achieved, and the timeliness and accuracy of monitoring are improved. .
Patent Information
- Application Number
- CN202410543634.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-30
- Publication Date
- 2025-01-14
AI Technical Summary
In blockchain distributed systems, the execution of smart contracts is difficult to be fully observed. Traditional network monitoring tools cannot ensure timeliness, comprehensiveness and accuracy. The code insertion method will change the internal state of the smart contract, resulting in the inability to obtain accurately. Its operating status.
By using a pre-constructed tracking data structure in the state channel, initialize and track the identification information and execution information of the smart contract, generate state tracking result data whenever a transaction is confirmed, and submit these data to the block when the state channel is closed. chain.
It achieves zero-intrusion tracking of smart contracts in the status channel, ensures the recording and storage of the detailed process of each transaction execution of the smart contract, and avoids the negative impact of instrumentation.
Smart Images

Figure CN119313454A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of blockchain technology, and more specifically to a method, apparatus, device, medium, and program product for a smart contract in a tracking state channel of a blockchain. Background Art
[0002] In a distributed system such as blockchain, the execution of smart contracts involves multiple nodes and services, and sometimes involves integration and analysis with external data sources. Using only traditional network monitoring tools and means during operation and maintenance or development cannot fully observe the operation of smart contract programs, and it is difficult to ensure the timeliness, comprehensiveness and accuracy of responding to various events. If the observation is carried out in the form of code plugging, the internal state of the original program of the smart contract will be changed, resulting in the inability to accurately obtain the internal state of the smart contract. In addition, the observation data provided by the developer through plugging can often only observe part of the operation of the smart contract and cannot cover the whole situation. Moreover, all the plugging codes are integrated into the operation logic of the smart contract code, without distinction and control. This often leads to the need to eliminate suspicion first when the smart contract has performance degradation or operation errors, even if the plugging code has been polished for a long time in actual combat. Summary of the invention
[0003] In view of the above problems, the present disclosure provides a method, apparatus, device, medium and program product that can achieve zero-intrusion tracking of smart contracts in a state channel.
[0004] In a first aspect of an embodiment of the present disclosure, a method for tracking smart contracts in a state channel is provided, which is applied to a blockchain. The method includes: in response to the opening of the state channel, initializing the state channel based on a pre-constructed tracking data structure and a participant list, wherein the tracking data structure includes fields of identification information and execution information of the smart contract, and the participant list is an information set of smart contracts participating in the interaction of the state channel; whenever a target transaction is confirmed to be valid in the state channel, for each first smart contract participating in the target transaction, the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction are used to fill the corresponding fields in the tracking data structure to generate a state tracking result data; wherein the first smart contract is a smart contract in the participant list; in response to the generation of each state tracking result data, the state tracking result data is stored in the state channel; and when the state channel is closed, all the state tracking result data stored in the state channel are submitted to the blockchain where the state channel is located.
[0005] According to an embodiment of the present disclosure, the execution information includes transaction party information, execution time information and execution result information; wherein the tracking data structure includes an identification information field, a transaction party information field, an execution time information field and an execution result information field.
[0006] According to an embodiment of the present disclosure, the use of the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction to fill the corresponding fields in the tracking data structure to generate a status tracking result data includes: using the identification information of the first smart contract to fill the identification information field in the tracking data structure; using the first smart contract to participate in the execution of the target transaction, calling the account information of the first smart contract and the account information called by the first smart contract to fill the transaction party information field in the tracking data structure; using the time information of the first smart contract participating in the execution of the target transaction to fill the execution time information field in the tracking data structure; and using the execution result information of the first smart contract participating in the execution of the target transaction to fill the execution result information field in the tracking data structure.
[0007] According to an embodiment of the present disclosure, different fields in the tracking data structure are combined into a string in a preset order, wherein each field includes a preset number of characters.
[0008] According to an embodiment of the present disclosure, the characters in each field in the tracking data structure are in hexadecimal.
[0009] According to an embodiment of the present disclosure, when the state channel is closed, after all the state tracking result data stored in the state channel are submitted to the blockchain where the state channel is located, the method also includes: sorting all the state tracking result data stored in the state channel according to generation time to form a state tracking sequence; using a preset mapping function to convert the state tracking sequence into a retrieval information sequence, the information in the retrieval information sequence is binary, decimal or natural language; and constructing a retrieval list based on the retrieval information sequence.
[0010] According to an embodiment of the present disclosure, when the state channel is closed, submitting all the state tracking result data stored in the state channel to the blockchain where the state channel is located includes: taking each smart contract in the participant list as a second smart contract, searching the state tracking result data with the latest generation time from the state tracking result data of the second smart contract to obtain the final state tracking result data of the second smart contract; based on the final state tracking result data, obtaining the final state result of the second smart contract; obtaining the account state data of the second smart contract in the state tree of the blockchain; determining the validity of the final state result based on the comparison between the final state result and the account state data; and when the final state results of all the smart contracts in the participant list are valid, submitting all the state tracking result data stored in the state channel to the blockchain.
[0011] According to an embodiment of the present disclosure, the account status data includes a first hash value of the code deployed by the second smart contract in the blockchain; the final status result includes a second hash value of the execution information obtained by the second smart contract executing the last transaction in the status channel. The determination of the validity of the final status result based on the comparison between the final status result and the account status data includes: performing an XOR operation on the first hash value and the second hash value; when the result of the XOR operation is true, determining that the final status result is valid; and when the result of the XOR operation is false, determining that the final status result is invalid.
[0012] In a second aspect of the embodiment of the present disclosure, there is provided a device for tracking smart contracts in a state channel, which is arranged in a blockchain. The device includes an initialization module, a generation module, a storage module and a submission module. The initialization module is used to initialize the state channel based on a pre-constructed tracking data structure and a participant list in response to the opening of the state channel, wherein the tracking data structure includes fields of identification information and execution information of the smart contract, and the participant list is an information set of smart contracts participating in the interaction of the state channel. The generation module is used to fill the corresponding fields in the tracking data structure with the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction for each first smart contract participating in the target transaction whenever a target transaction is confirmed to be valid in the state channel, so as to generate a state tracking result data; wherein the first smart contract is a smart contract in the participant list. The storage module is used to store the state tracking result data in the state channel in response to the generation of each state tracking result data. The submission module is used to submit all the state tracking result data stored in the state channel to the blockchain where the state channel is located when the state channel is closed.
[0013] A third aspect of the embodiments of the present disclosure provides an electronic device, comprising: one or more processors and a memory. The memory is used to store one or more programs, wherein when the one or more programs are executed by the one or more processors, the one or more processors execute the above method.
[0014] A fourth aspect of the embodiments of the present disclosure further provides a computer-readable storage medium having executable instructions stored thereon, which, when executed by a processor, causes the processor to execute the above method.
[0015] The fifth aspect of the embodiments of the present disclosure also provides a computer program product, including a computer program, which implements the above method when executed by a processor.
[0016] One or more of the above embodiments of the present disclosure can achieve the following beneficial effects or have the following advantages: in the state channel, a pre-constructed tracking data structure is used as a tracker. Whenever a smart contract in the state channel executes a transaction and the transaction is confirmed to be valid in the state channel, the execution information obtained by the smart contract executing the transaction can be captured by the tracker, thereby generating a state tracking result data of the smart contract and storing it. Finally, when the state channel is closed, all the state tracking result data stored in the state channel can be submitted to the blockchain for data chaining. In this way, when the number of transactions confirmed in the state channel, each smart contract in the state channel will generate the corresponding number of state tracking result data. In this way, the detailed process of each transaction execution of each smart contract in the state channel can be saved through a series of state tracking result data corresponding to each smart contract. In addition, there is no need to insert a stub for the smart contract, which realizes the effective tracking of the smart contract in the state channel and effectively avoids various negative effects caused by inserting a stub. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] The above contents and other objects, features and advantages of the present disclosure will become more apparent through the following description of the embodiments of the present disclosure with reference to the accompanying drawings, in which:
[0018] Figure 1 The application scenario diagram schematically shows the method, apparatus, device, medium and program product for tracking smart contracts in a state channel according to an embodiment of the present disclosure;
[0019] Figure 2 A workflow diagram of a state channel is schematically shown;
[0020] Figure 3 A flowchart of a method for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown;
[0021] Figure 4 A flowchart of constructing a tracking data structure according to an embodiment of the present disclosure is schematically shown;
[0022] Figure 5 A flowchart of initializing a state channel in a method according to an embodiment of the present disclosure is schematically shown;
[0023] Figure 6 The interactive process in the state channel in the method of an embodiment of the present disclosure is schematically shown;
[0024] Figure 7 The schematic diagram shows the processing flow of the state tracking result data after the state channel is closed in the method of one embodiment of the present disclosure;
[0025] Figure 8The schematic diagram shows the format conversion process of the state tracking result data after the state channel is closed in the method of an embodiment of the present disclosure;
[0026] Fig. 9 A block diagram schematically shows an apparatus for tracking smart contracts in a state channel according to an embodiment of the present disclosure; and
[0027] Fig.10 A block diagram of an electronic device suitable for implementing the method for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown. DETAILED DESCRIPTION
[0028] Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. However, it should be understood that these descriptions are exemplary only and are not intended to limit the scope of the present disclosure. In the following detailed description, for ease of explanation, many specific details are set forth to provide a comprehensive understanding of the embodiments of the present disclosure. However, it is apparent that one or more embodiments may also be implemented without these specific details. In addition, in the following description, descriptions of known structures and technologies are omitted to avoid unnecessary confusion of the concepts of the present disclosure.
[0029] The terms used herein are only for describing specific embodiments and are not intended to limit the present disclosure. The terms "comprise", "include", etc. used herein indicate the existence of the features, steps, operations and / or components, but do not exclude the existence or addition of one or more other features, steps, operations or components.
[0030] All terms (including technical and scientific terms) used herein have the meanings commonly understood by those skilled in the art, unless otherwise defined. It should be noted that the terms used herein should be interpreted as having a meaning consistent with the context of this specification, and should not be interpreted in an idealized or overly rigid manner.
[0031] Distributed link tracking of smart contract programs is a technology that uses blockchain distributed systems as operating infrastructure to track and record events during the execution of smart contracts. Some observation points can be set on the interface of smart contracts to observe changes in their status, helping developers and operation and maintenance personnel monitor and debug smart contracts to ensure their correct execution and provide valuable debugging information when problems occur.
[0032] The disclosed embodiments provide a method, apparatus, device, medium and program product for tracking smart contracts in a state channel. When the state channel is opened, the disclosed embodiments can input a pre-constructed tracking data structure into the state channel. The tracking data structure includes fields for identification information and execution information of the smart contract, and can be used as a tracker. Whenever a smart contract in the state channel executes a transaction and the transaction is confirmed to be valid in the state channel, the execution information obtained by the smart contract executing the transaction and the identification information of the smart contract can be captured by the tracker, and a state tracking result data of the smart contract can be generated and stored. In this way, when the number of transactions confirmed in the state channel, each smart contract in the state channel will generate the corresponding number of state tracking result data. In this way, the detailed process of each transaction execution of each smart contract in the state channel can be saved in the state channel through a series of state tracking result data corresponding to each smart contract. Then when the state channel is closed, the state tracking result data stored in the state channel can be submitted to the blockchain for data upload. In this way, after the state channel is closed, the blockchain can save information about the execution process of the smart contract in the state channel, making it convenient for users to check and analyze the specific execution process of the smart contract in the state channel from the blockchain, thereby achieving effective tracking of the smart contract in the state channel.
[0033] Figure 1 The application scenario diagram of the method, apparatus, device, medium and program product for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown.
[0034] like Figure 1 As shown, the application scenario 100 according to this embodiment may include a blockchain 101 and multiple terminal devices 102, wherein each terminal device 102 may be communicatively connected to the blockchain 101 via a network, wherein the network may include various connection types, such as wired, wireless communication links or fiber optic cables, etc.
[0035] The user can use the terminal device 102 to interact with the blockchain 101 through the network to receive or send messages, etc. The terminal device 102 may be installed with a client application for multi-party contract signing, etc. The terminal device 102 may be a variety of electronic devices with a display screen and supporting web browsing, including but not limited to smartphones, tablet computers, laptops, and desktop computers, etc.
[0036] The blockchain 101 may include multiple blockchain nodes, such as Figure 1Nodes A, B, C, and D are shown. The multiple blockchain nodes can communicate with each other through a communication network. The multiple blockchain nodes in the blockchain 101 can be deployed on servers in various places respectively, each blockchain node can be a server or a server cluster, and the server / server cluster can be a server / server cluster that provides various services. For example, a background management server that provides support for multi-party contract signing operations performed by users through the terminal device 101 (only as an example). The background management server can analyze and process the received user request and other data, and feedback the processing results (such as web pages, information, or data obtained or generated according to user requests) to the terminal device 101.
[0037] Each blockchain node corresponds to a database, and the multiple blockchain nodes can form a database storage system that is distributed in various places and can operate in a coordinated manner. Each blockchain node can reach a transaction consensus through a consensus mechanism (for example, a consensus protocol determined based on the Byzantine Fault Tolerance (PBFT) algorithm).
[0038] When a transaction reaches a consensus, the new block can be submitted to the local blockchain node for data storage. Other blockchain nodes in blockchain 101 will synchronize the new block according to a certain mechanism, so that the data in the database corresponding to all blockchain nodes in blockchain 100 is completely consistent. This process is referred to as data on-chain.
[0039] From the above introduction, it can be seen that before each transaction in blockchain 101 is uploaded to the blockchain, it needs to go through the consensus mechanism in blockchain 101 to reach a transaction consensus. This process consumes a lot of computing resources and time, resulting in a relatively slow transaction speed, which is not conducive to executing high-frequency, small-amount transactions in blockchain 101, such as IoT smart payment scenarios. To address this problem, one of the solutions is the state channel. The essence of the solution of the state channel is to balance the high throughput of transactions and the decentralization of verifiers. Specifically, the details of the two-way transaction are negotiated off-chain, and when the multi-step transaction is completed or a dispute occurs in the transaction, "arbitration" is carried out through the blockchain.
[0040] The purpose of smart contracts in blockchain is to trigger state changes of contract users through a series of logical executions and change the state of external accounts through transactions. Usually, detecting and analyzing state changes can be used to determine whether the execution process of smart contracts is in line with expectations. State channels allow contract users to communicate and update state directly without frequent interaction with the blockchain. Figure 2 The workflow of the state channel is illustrated below.
[0041] Figure 2 The following diagram schematically shows a workflow diagram of a state channel.
[0042] like Figure 2 As shown, suppose there are two participating users A and B. During the initialization of the state channel, the initial assets locked by A are 10, and the initial assets locked by B are also 10. A series of high-frequency micropayments will occur between the two. Figure 2 The process of A and B using state channel transactions is simulated.
[0043] The whole process is described in detail as follows.
[0044] (1) A or B creates a state channel smart contract Contract, hereinafter referred to as C. At this time, the state channel is in the Opening state. This process needs to be uploaded to the chain.
[0045] (2) A transfers 10 assets (tokens) into the contract, and then B also transfers 10 assets into the contract. At this time, the state channel is opened (Open), and this process must also be put on the chain. The distribution plan at this time is (A: 10, B: 10).
[0046] (3) Since the state channel has been opened, A and B can start trading. If A transfers an asset to B, the allocation plan is (A: 9, B: 11, N: 1), and B gets A's signature on the allocation status; then, B transfers 3 assets to A, and the allocation plan becomes (A: 12, B: 8, N: 2), and A gets B's signature on the allocation status. N represents Nonce, that is, each time the two parties change the asset allocation according to the agreement, they must increase the N value. Honest participating users will use the allocation plan with the largest N value as the current allocation plan, and the allocation plans with smaller N values are invalid plans and can be abandoned at any time.
[0047] (4) During the off-chain transaction, participating users can initiate status submission to smart contract C at any time. If A initiates status submission, C will verify B's signature and N value, and C will only accept allocation plans with a larger N value than the last on-chain allocation; conversely, if B initiates status submission, C will verify A's signature and N value; if the N value and signature of the newly submitted allocation plan are both legal, C will accept the new allocation plan and update the N value in the contract. The two parties continue to trade until the final allocation plan is reached. Here, the final allocation plan is (A: 1, B: 19, N: 50), and the final plan has been submitted to C and accepted by C.
[0048] (5) When the two parties reach a final allocation plan, that is, either party initiates a request to close the state channel, the allocation will be carried out according to the allocation plan on the contract chain. Once Contract C receives the request to close the channel, the state channel enters the Closing state and maintains a certain validity period. During the validity period of this state, the other party can still submit a new valid allocation plan to return the state channel to the Open state. If the other party fails to return the state channel to the Open state within the validity period of the Closing state, the state channel enters the Closed state.
[0049] (6) When the state channel enters the Close state, the contract performs actual asset allocation according to the last valid allocation plan determined on the chain.
[0050] Through the state channel, smart contracts can track and verify the state changes of targets (such as the account balances of A and B, the number of transactions N) without triggering transactions on the blockchain for each state change. Therefore, the state channel can be used to achieve zero-intrusion tracking of the running status of smart contracts.
[0051] It should be understood that Figure 2 The state channel shown only includes the state channel smart contract Contract. This smart contract is only an example. The solution of the embodiment of the present disclosure does not limit the number of smart contracts in the state channel. In addition, Figure 1 The number of terminal devices, networks and servers in the application scenario shown is also exemplary. Any number of terminal devices, networks and servers may be provided according to implementation requirements.
[0052] It should be noted that the method, apparatus, device, medium and program product for tracking smart contracts in the state channel of the embodiments of the present disclosure can be used in the financial field, and can also be used in any field other than the financial field. The present disclosure does not limit the application field.
[0053] The following will be based on Figure 1 and Figure 2 ,pass Figure 3 to Figure 8 The method for tracking smart contracts in a state channel according to an embodiment of the present disclosure is described in detail.
[0054] Figure 3 The flowchart of the method for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown.
[0055] like Figure 3 As shown, according to this embodiment, the method for tracking smart contracts in a state channel may include operations S301 to S304. Figure 2 Instructions are as follows.
[0056] First, in operation S301, in response to the opening of the state channel, the state channel is initialized based on the pre-constructed tracking data structure and the participant list, wherein the tracking data structure includes the identification information and execution information fields of the smart contract, and the participant list is the information collection of the smart contracts participating in the interaction of the state channel. Figure 2 middle
[0057] When A or B creates a state channel smart contract C to open the state, they can write the tracking data structure and the account address of smart contract C into the state channel smart contract C to initialize the state channel.
[0058] In operation S302, whenever a target transaction is confirmed to be valid in the state channel, for each first smart contract participating in the target transaction, the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction are used to fill in the corresponding fields in the tracking data structure to generate a state tracking result data, wherein the first smart contract is the smart contract in the participant list.
[0059] And in operation S303, in response to the generation of each state tracking result data, the state tracking result data is stored in the state channel.
[0060] For example, Figure 2 The first transaction allocation scheme confirmed by the state channel is (A: 12, B: 8, N: 2). The identification information of smart contract C (for example, account address information, account ID information, or binary value of application program interface, etc.) can be filled into the identification information field in the tracking data structure, and the execution information of the transaction allocation scheme can be filled into the corresponding field of the execution information in the tracking data structure to generate a state tracking result data. The execution information of the allocation scheme can include but is not limited to: execution process information (for example, A calls smart contract C to execute a transaction to realize the token transaction between A and B), execution result information (such as the state of the state channel after the transaction is executed A: 12, B: 8, N: 2), etc. In this way, the state tracking result data can record the execution process of smart contract C on the transaction allocation scheme (A: 12, B: 8, N: 2) confirmed to be valid in the state channel.
[0061] Accordingly, for Figure 2 The second transaction allocation scheme (A: 1, B: 19, N: 50) confirmed in the state channel can also generate a new state tracking result data in a similar way.
[0062] Among them, the state channel can store each state tracking result generated. In this way, when the number of transactions confirmed in the state channel, each smart contract in the state channel will generate the corresponding number of state tracking result data. That is, the state channel can save the detailed execution process of each smart contract through a series of state tracking result data corresponding to each smart contract.
[0063] Next, in operation S304, in response to the closing of the state channel, all state tracking result data stored in the state channel is submitted to the blockchain where the state channel is located. Figure 2 When the state channel is closed, the state tracking result data stored in the state channel will also be uploaded to the chain at the same time as the final allocation plan (A: 1, B: 19, N: 50) data is uploaded to the chain. In this way, after the state channel is closed, the blockchain still saves the information of the execution process of the smart contract in the state channel, which is convenient for users to check and analyze the specific execution process of the smart contract in the state channel from the blockchain, and realizes the effective tracking of the smart contract in the state channel.
[0064] In one embodiment, in the above operation S304, before submitting the status tracking result data to the blockchain, the validity of the final status result of each smart contract is first verified, and then all the status tracking result data are submitted to the blockchain when the final status results of all smart contracts are verified to be valid; otherwise, it indicates that there is an abnormality in the status tracking process of the smart contract, and in this case, the status tracking result data is not submitted to the blockchain.
[0065] Specifically, for each smart contract in the participant list, the state tracking result data with the latest generation time can be searched from the state tracking result data of the smart contract to obtain the final state tracking result data of the smart contract; then, based on the final state tracking result data, the final state result of the smart contract is obtained. At the same time, the account state data of the smart contract in the state tree of the blockchain is obtained. Then, based on the comparison between the final state result and the account state data, the validity of the final state result of the smart contract is determined.
[0066] For example Figure 2 In the example, the final state tracking result data of smart contract C is the state tracking result data obtained based on the second transaction allocation scheme (A: 1, B: 19, N: 50). The final state result of smart contract C can be extracted from the state tracking result data. For example, if C is the result of a transaction between A and B, then the final state result of smart contract C can be represented by the account balances of A and B. In some embodiments, the final state result of smart contract C can also include the value of N.
[0067] Since smart contract C submits a new state (i.e., the above-mentioned final state result) to the blockchain only when the state channel is closed, the state result in the account state data of smart contract C obtained from the state tree of the blockchain before smart contract C submits the final state result saves the state of smart contract C when the state channel is opened. In this way, the final state result of smart contract C is compared with the account state data obtained from the state tree of the blockchain to check whether the states of smart contract C are different. If they are different, it means that the final state result of smart contract C is valid, that is, the state tracking result data of smart contract C is valid. Otherwise, it means that the final state result of smart contract C is invalid. Because, in theory, the state tracking result data can only be generated when a transaction occurs in the state channel. If the state of smart contract C has not been changed, unless the transactions executed before and after the state channel offset each other (so that the state channel is meaningless), there must be an abnormality in the information recorded in the state tracking result data.
[0068] In one embodiment, the account status data of the smart contract obtained from the state tree of the blockchain includes the first hash value codehash of the code deployed by the smart contract in the blockchain; and the final state result of the smart contract may include the second hash value txhash of the execution information obtained by the smart contract executing the last transaction in the state channel. In this way, when determining the validity of the final state result of the second smart contract based on the comparison between the final state result and the account state data, it can be achieved in the following way: perform an XOR operation on the first hash value codehash and the second hash value final_txhash; when the result of the XOR operation is true, it means that codehash and final_txhash are different, then the final state result is determined to be valid; on the contrary, when the result of the XOR operation is false, the final state result is determined to be invalid.
[0069] Figure 4 The flowchart of constructing the tracking data structure according to an embodiment of the present disclosure is schematically shown.
[0070] like Figure 4 As shown, in one embodiment, the process of constructing a tracking data structure includes operations S401 to S403.
[0071] First, in operation S401, connect to the blockchain development platform. This is the first step to create a tracking data structure. First, you need to connect to the underlying blockchain platform and set up the main network. Create HTTP and Websocket URLs for the application used to build the tracking data structure.
[0072] Then in operation S402, various information of a smart contract execution is sorted out. The information can be recorded as the identification information of the smart contract, the information of the two parties in one execution of the smart contract, the execution time information timestamp and the execution result information. The identification information of the smart contract can be, for example, the abi value of the application binary interface application BinaryInterface, and the information of the two parties can include, for example, the account information addrhash of the smart contract and the account information to_address called by the smart contract. The execution result information can include, for example, but is not limited to: the return result (or the status of the status channel after the transaction is confirmed) txhash, and the exception information exption.
[0073] Next, in operation S403, a tracking data structure is constructed. In one embodiment, the tracking data structure can be identified in the form shown in the following reward:
[0074] reward=
[0075] {event(abi, addrHash, to_address, timestamp, txhash, exption)}.
[0076] The tracking data structure reward is in the event unit format, where abi, addrhash, to_address, timestamp, txhash, and exption are all fields to be filled.
[0077] When the tracking data structure is as shown in reward, the process of filling each field in reward in operation S302 to generate the status tracking result can be specifically: using the identification information of the smart contract to fill the identification information field (such as abi) in the tracking data structure; using the smart contract to participate in the execution of the target transaction, the account information of the smart contract and the account information called by the smart contract are used to fill the transaction party information fields (such as addrhash and to_address) in the tracking data structure; using the time information of the smart contract participating in the execution of the target transaction, fill the execution time information field (such as timestamp) in the tracking data structure; using the execution result information of the smart contract participating in the execution of the target transaction, fill the execution result information field (such as txhash, exption) in the tracking data structure.
[0078] In one embodiment, different fields in the tracking data structure reward can be combined into a string in a preset order, wherein each field includes a preset number of characters. In this way, a lightweight tracking data structure can be formed, so that each generated tracking status result data is a string of characters, which is convenient for storage and data chaining. In another embodiment, the characters in each field of reward in the tracking data structure are in hexadecimal, so that more information can be saved in each field of reward with a smaller number of characters. Further reduce the storage space and transmission consumption of each generated tracking status result data.
[0079] Figure 5 The flowchart of initializing the status channel in the method of one embodiment of the present disclosure is schematically shown.
[0080] like Figure 5 As shown, in one embodiment, the process of initializing the status channel in operation S301 includes operation S501 and operation S502.
[0081] In operation S501, in response to the opening of the state channel, a tracking data structure (such as the aforementioned reward), a participant list, a target state and its update rules are input.
[0082] In operation S502, the address and related information of the state channel are stored in the smart contract.
[0083] In the context of state channels, the tracking data structure is the entry point for participating users to join the channel, interact, and ultimately settle. The participant list can be a collection of smart contract addresses that participate in the interactions in the state channel. The participant list is determined when the state channel is initialized and remains unchanged throughout the channel lifecycle. The user participating in the transaction in the state channel (referred to as the participating user) can be any entity on the blockchain, such as a user, organization, or other smart contract. The participating user is authenticated and authorized through the smart contract address to ensure that only legitimate participating users can participate in the interaction of the state channel.
[0084] The target state refers to the state of a specific target or resource that is tracked and managed in the state channel. The target can be a variable, a condition, or any other information that needs to be tracked in the state channel, such as Figure 2 N in the example.
[0085] Update rules define how to change the target state and what conditions need to be met to make the change. These rules can be predefined or negotiated between participating users. In the state channel, participating users need to follow these rules to update the target state and ensure the consistency and validity of the state.
[0086] Figure 6 The interactive process within the state channel in the method of an embodiment of the present disclosure is schematically shown.
[0087] like Figure 6 As shown, according to this embodiment, the interaction process in the state channel may include operations S601 to S607, wherein the state channel in this embodiment only includes one smart contract, such as Figure 2 Smart contract C in.
[0088] In operation S601, a smart contract is called to generate a request.
[0089] In operation S602, the smart contract obtains and executes the state channel instance, and then creates and sends a transaction confirmation request to the state channel.
[0090] In operation S603, the state channel processes the transaction confirmation request. First, the validity of the transaction is verified. After the transaction is verified to be valid, the tracking data structure reward in the state channel is updated using the identification information of the smart contract and the execution information of the transaction, and a state tracking result data of the smart contract is generated, and then the state tracking result data is broadcast to the participating users in the state channel.
[0091] In operation S604, the participating user signs the status update. The participating user signs the status update and updates his / her own status. Figure 2 A and B can sign the confirmed valid transaction allocation plan and the generated status tracking result data after each transaction is confirmed in the status channel, and update their own account balance and other status.
[0092] In operation S605, the state channel verifies the signature of the participating user and updates the state, and stores the generated state tracking result data. For example, smart contract C can store its own state tracking result data.
[0093] In operation S606, when the state channel is to be closed, the tracking data structure reward is used as a tracker to capture the final state result finalstate in the state channel. Figure 2 The final state result finalstate of the state channel can be (a: 1, b: 19) or (a: 1, b: 19, n: 50). The tracking data structure reward can perform a hash calculation on the final state result finalstate to obtain a second hash value final_txhash, which is filled into the txhash field in reward. In another embodiment, the value of the txhash field can also be extracted from the last state tracking result data of the smart contract c to obtain the second hash value final_txhash.
[0094] In operation S607, the validity of the state channel operation is determined by comparing the hash value codehash of the account state data of the smart contract in the state tree in the blockchain with the above second hash value final_txhash.
[0095] Specifically, combined Figure 1 and Figure 2 , you can first determine whether the codehash of the smart contract C in the state tree in the blockchain is empty. If it is empty, do not proceed to the next step. Generally speaking, codehash is the hash value of the Ethereum Virtual Machine (EVM) code that stores account information in the account state. It represents the code hash value of the account in the blockchain virtual machine execution environment. When this address receives a message call, these codes will be executed; it is different from other fields and cannot be changed after creation.
[0096] Then, when codehash is not empty, final_txhash and codehash are compared by XOR calculation. If the XOR value of finalstate and codehash is true (indicating that the two data are inconsistent), the result is that the running state is valid, otherwise it is invalid. Among them, when the running state is judged to be valid, the state tracking result data stored in the state channel can be submitted to the blockchain in response to the closing of the state channel in operation S304.
[0097] Figure 7 The schematic diagram shows the processing flow of the state tracking result data after the state channel is closed in the method of one embodiment of the present disclosure.
[0098] like Figure 7 As shown, according to this embodiment, after operations S301 to S303, the method for tracking smart contracts in the state channel may further include operations S701 to S703.
[0099] In operation S701, format conversion. As described above, the state tracking result data uploaded to the blockchain in operation S303 can be represented in hexadecimal, which makes it difficult to find out which data corresponds to which block, and it is difficult to meet the data intuitiveness requirements of operation and maintenance personnel in actual retrieval. In view of this, the state tracking result data sequence in hexadecimal format can be converted into a binary, decimal or natural language time series or event log sequence format through format conversion. Among them, an embodiment of format conversion can refer to Figure 8 's hint.
[0100] Figure 8The schematic diagram shows the format conversion process of the state tracking result data after the state channel is closed in the method of one embodiment of the present disclosure.
[0101] In operation S7011, the state tracking result data submitted to the blockchain by the state channel is sorted according to the generation time to form a state tracking sequence. In one embodiment, the state tracking result data with the same identifier can be formed into a state tracking sequence according to the identifier of the smart contract in the state tracking result data.
[0102] In operation S7012, the state tracking sequence is converted into a retrieval information sequence using a preset mapping function, and the information in the retrieval information sequence is binary, decimal or natural language.
[0103] In operation S7013, a search list is constructed based on the search information sequence.
[0104] In one embodiment, the following function can be constructed:
[0105] for let i=0in blocksLenth:
[0106] data=reward[i].map(r==
[0107] >Math.round(Number(r) / 10**9))
[0108] In the above function, i is the operator in the function, blocksLenth is the total number of valid transactions confirmed by the state channel (that is, the number of state tracking result data recorded by each smart contract). data is the result after format conversion, map is the mapping function, r is the random value, and round is the function for rounding decimal places in the usual sense.
[0109] The state tracking sequence can be converted into a search list through the above function. The search list can be a dictionary list composed of the keyword key in the key-value, where the value corresponds to the state tracking result data, and the key is the data after the mapping of the above function. The key is, for example, a structure represented by binary, decimal or natural language. In one embodiment, the key in the search list can contain the information of the smart contract. In this way, when the operation and maintenance personnel search for the state tracking result data of a smart contract through the terminal device, they can send a search request to the blockchain, and then the blockchain can output the search list to the terminal device for the operation and maintenance personnel to select the smart contract to be retrieved, and then retrieve the corresponding state tracking result data. In this way, the trouble of developers and operation and maintenance personnel to query blocks one by one through the block browser, and then filter them one by one manually to find the required state tracking result data is greatly reduced, and the speed and efficiency of querying and analyzing the state tracking result data stored on the blockchain are improved.
[0110] Next, return to Figure 7 . After operation S701, perform operation S702 to mark the transmission. The collected data data needs to be marked or attached with meta information so that the order and context of events can be accurately reconstructed later. This usually involves adding the timestamp trans_timestamp when the data was downloaded from the blockchain, the source block identifier data_blocks (for example, expressed in the form of md5 hash value), and the event type event_type (the event category that triggers the smart contract, such as transaction events, query events, etc.) information to the data. For example, the state tracking data downloaded from the blockchain can be packaged or named as follows:
[0111] trans_data=data+trans_timestamp+data_blocks+event_type.
[0112] Next, in operation S703, the data is stored in a time series database to facilitate operation and maintenance personnel to retrieve and analyze the data according to the above field events and time sequence.
[0113] In this way, the embodiment of the present disclosure can realize the tracking function of the smart contract in the state channel without intrusion by deploying the tracking data structure in the state channel, wherein the off-chain interaction of the state channel reduces the frequent interaction with the blockchain and improves the performance. Moreover, by constructing the tracking data structure, it is possible to ensure the comprehensive observation of the operation of the smart contract program to a large extent. In the final settlement process of the state channel, the off-chain state is synchronized with the state on the blockchain to ensure the integrity and credibility of the data.
[0114] The disclosed embodiment is based on the state channel and utilizes a distributed algorithm to construct a tracking data structure as a tracker, and associates the execution process data of the smart contract in the state channel to determine the running status of the smart contract, thereby completing the collection, format conversion, tag transmission, and storage steps of the running state data of the smart contract.
[0115] It can be seen that the embodiments of the present disclosure can effectively solve the various problems caused by the fragmented distribution of data in the blockchain for developers and operation and maintenance personnel, such as the inability to quickly locate when it is necessary to track and integrate multiple contracts and transactions to grasp the running status of smart contracts. In order to quickly locate when querying and analyzing multiple data sources, the embodiments of the present disclosure can combine the state channel to achieve a zero-intrusive approach, without embedding tracking code in the smart contract, to achieve rapid monitoring and link tracking of the runtime smart contract status, and then to achieve the grasp of the execution path and process of the smart contract. Distributed link tracking is achieved in a zero-intrusive manner, ensuring the transparency and efficiency of monitoring the execution process of the smart contract from the perspective of the operator without interfering with the normal operation of the smart contract.
[0116] Based on the methods for tracking smart contracts in the state channel in the above embodiments, the present disclosure also provides a device for tracking smart contracts in the state channel. Fig. 9 The device is described in detail.
[0117] Fig. 9 A block diagram of an apparatus 900 for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown.
[0118] like Fig. 9 As shown, according to this embodiment, the device 900 for tracking smart contracts in a state channel may include an initialization module 910, a generation module 920, a storage module 930 and a submission module 940.
[0119] The initialization module 910 is used to respond to the opening of the state channel and initialize the state channel based on a pre-constructed tracking data structure and a participant list, wherein the tracking data structure includes fields for identification information and execution information of the smart contract, and the participant list is an information collection of smart contracts participating in the interaction of the state channel.
[0120] The generation module 920 is used to fill the corresponding fields in the tracking data structure for each first smart contract participating in the target transaction, using the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction, to generate a state tracking result data whenever a target transaction is confirmed to be valid in the state channel; wherein the first smart contract is the smart contract in the participant list.
[0121] The storage module 930 is used to store the state tracking result data in the state channel in response to the generation of each state tracking result data.
[0122] The submission module 940 is used to submit all state tracking result data stored in the state channel to the blockchain where the state channel is located when the state channel is closed.
[0123] According to other embodiments of the present disclosure, the device 900 may further include a format conversion module. The format conversion module may be used to: after the submission module 940 submits all the state tracking result data stored in the state channel to the blockchain where the state channel is located, sort all the state tracking result data stored in the state channel according to the generation time to form a state tracking sequence; use a preset mapping function to convert the state tracking sequence into a retrieval information sequence, and the information in the retrieval information sequence is binary, decimal or natural language; construct a retrieval list based on the retrieval information sequence; and when receiving a user retrieval instruction sent by a terminal device, output the retrieval list to the terminal device.
[0124] The apparatus 900 may perform reference Figure 3 to Figure 8 The method of tracking smart contracts in the state channel introduced above can be found in the previous article and will not be repeated here.
[0125] According to an embodiment of the present disclosure, any multiple modules among the initialization module 910, the generation module 920, the storage module 930, the submission module 940 and the format conversion module can be combined in one module for implementation, or any one of the modules can be split into multiple modules. Alternatively, at least part of the functions of one or more of these modules can be combined with at least part of the functions of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the initialization module 910, the generation module 920, the storage module 930, the submission module 940 and the format conversion module can be at least partially implemented as a hardware circuit, such as a field programmable gate array (FPGA), a programmable logic array (PLA), a system on a chip, a system on a substrate, a system on a package, an application specific integrated circuit (ASIC), or can be implemented by hardware or firmware such as any other reasonable way of integrating or packaging the circuit, or implemented in any one of the three implementation methods of software, hardware and firmware or in a suitable combination of any of them. Alternatively, at least one of the initialization module 910, the generation module 920, the storage module 930, the submission module 940 and the format conversion module may be at least partially implemented as a computer program module, which may perform corresponding functions when executed.
[0126] Fig.10A block diagram of an electronic device 1000 suitable for implementing the method for tracking smart contracts in a state channel according to an embodiment of the present disclosure is schematically shown.
[0127] like Fig.10 As shown, the electronic device 1000 according to an embodiment of the present disclosure includes a processor 1001, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage part 1008 into a random access memory (RAM) 1003. The processor 1001 may include, for example, a general-purpose microprocessor (e.g., a CPU), an instruction set processor and / or a related chipset and / or a special-purpose microprocessor (e.g., an application-specific integrated circuit (ASIC)), etc. The processor 1001 may also include an onboard memory for caching purposes. The processor 1001 may include a single processing unit or multiple processing units for performing different actions of the method flow according to an embodiment of the present disclosure.
[0128] In RAM 1003, various programs and data required for the operation of electronic device 1000 are stored. Processor 1001, ROM 1002 and RAM 1003 are connected to each other through bus 1004. Processor 1001 performs various operations of the method flow according to the embodiment of the present disclosure by executing the program in ROM 1002 and / or RAM 1003. It should be noted that the program can also be stored in one or more memories other than ROM 1002 and RAM 1003. Processor 1001 can also perform various operations of the method flow according to the embodiment of the present disclosure by executing the program stored in the one or more memories.
[0129] According to an embodiment of the present disclosure, the electronic device 1000 may further include an input / output (I / O) interface 1005, which is also connected to the bus 1004. The electronic device 1000 may further include one or more of the following components connected to the I / O interface 1005: an input portion 1006 including a keyboard, a mouse, etc.; an output portion 1007 including a cathode ray tube (CRT), a liquid crystal display (LCD), etc., and a speaker, etc.; a storage portion 1008 including a hard disk, etc.; and a communication portion 1009 including a network interface card such as a LAN card, a modem, etc. The communication portion 1009 performs communication processing via a network such as the Internet. A drive 1010 is also connected to the I / O interface 1005 as needed. A removable medium 1011, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 1010 as needed, so that a computer program read therefrom is installed into the storage portion 1008 as needed.
[0130] The present disclosure also provides a computer-readable storage medium, which may be included in the device / apparatus / system described in the above embodiments; or may exist independently without being assembled into the device / apparatus / system. The above computer-readable storage medium carries one or more programs, and when the above one or more programs are executed, the method according to the embodiment of the present disclosure is implemented.
[0131] According to an embodiment of the present disclosure, a computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present disclosure, a computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, an apparatus or a device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include the ROM 1002 and / or RAM 1003 described above and / or one or more memories other than ROM 1002 and RAM 1003.
[0132] The embodiment of the present disclosure also includes a computer program product, which includes a computer program, and the computer program contains program code for executing the method shown in the flowchart. When the computer program product is run in a computer system, the program code is used to enable the computer system to implement the method for tracking smart contracts in the state channel provided by the embodiment of the present disclosure.
[0133] The above functions defined in the system / device of the embodiment of the present disclosure are performed when the computer program is executed by the processor 1001. According to the embodiment of the present disclosure, the system, device, module, unit, etc. described above can be implemented by a computer program module.
[0134] In one embodiment, the computer program may rely on tangible storage media such as optical storage devices, magnetic storage devices, etc. In another embodiment, the computer program may also be transmitted and distributed in the form of signals on a network medium, and downloaded and installed through the communication part 1009, and / or installed from the removable medium 1011. The program code contained in the computer program may be transmitted using any appropriate network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the above.
[0135] In such an embodiment, the computer program can be downloaded and installed from the network through the communication part 1009, and / or installed from the removable medium 1011. When the computer program is executed by the processor 1001, the above functions defined in the system of the embodiment of the present disclosure are performed. According to the embodiment of the present disclosure, the system, device, means, module, unit, etc. described above can be implemented by a computer program module.
[0136] According to an embodiment of the present disclosure, the program code for executing the computer program provided by the embodiment of the present disclosure can be written in any combination of one or more programming languages. Specifically, these computing programs can be implemented using high-level process and / or object-oriented programming languages, and / or assembly / machine languages. Programming languages include, but are not limited to, Java, C++, python, "C" language or similar programming languages. The program code can be executed entirely on the user computing device, partially on the user device, partially on the remote computing device, or entirely on the remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user computing device through any type of network, including a local area network (LAN) or a wide area network (WAN), or can be connected to an external computing device (for example, using an Internet service provider to connect through the Internet).
[0137] The flow charts and block diagrams in the accompanying drawings illustrate the possible architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flow chart or block diagram can represent a module, a program segment, or a part of a code, and the above-mentioned module, program segment, or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs a specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0138] It will be appreciated by those skilled in the art that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations and / or combinations are not explicitly described in the present disclosure. In particular, the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways without departing from the spirit and teachings of the present disclosure. All of these combinations and / or combinations fall within the scope of the present disclosure.
[0139] The embodiments of the present disclosure are described above. However, these embodiments are only for illustrative purposes and are not intended to limit the scope of the present disclosure. Although the embodiments are described above separately, this does not mean that the measures in the various embodiments cannot be used in combination to advantage. The scope of the present disclosure is defined by the attached claims and their equivalents. Without departing from the scope of the present disclosure, those skilled in the art may make a variety of substitutions and modifications, which should all fall within the scope of the present disclosure.
Claims
1. A method for tracking smart contracts in a state channel, comprising: In response to the opening of the state channel, the state channel is initialized based on a pre-constructed tracking data structure and a participant list, wherein the tracking data structure includes fields for identification information and execution information of the smart contract, and the participant list is an information set of smart contracts participating in the interaction of the state channel; Whenever a target transaction is confirmed to be valid in the state channel, for each first smart contract participating in the target transaction, the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction are used to fill the corresponding field in the tracking data structure to generate a state tracking result data; wherein the first smart contract is a smart contract in the participant list; In response to the generation of each state tracking result data, storing the state tracking result data in the state channel; and In response to the closing of the state channel, all the state tracking result data stored in the state channel are submitted to the blockchain where the state channel is located.
2. The method according to claim 1, wherein: The execution information includes transaction party information, execution time information and execution result information; The tracking data structure includes an identification information field, a transaction party information field, an execution time information field, and an execution result information field.
3. The method according to claim 2, wherein: The using the identification information of the first smart contract and the execution information obtained by the first smart contract participating in the execution of the target transaction to fill the corresponding fields in the tracking data structure to generate a state tracking result data includes: Filling an identification information field in the tracking data structure with identification information of the first smart contract; In the process of using the first smart contract to participate in executing the target transaction, the account information of the first smart contract and the account information called by the first smart contract are called to fill the transaction party information field in the tracking data structure; Filling the execution time information field in the tracking data structure with the time information of the first smart contract participating in the execution of the target transaction; and The execution result information of the first smart contract participating in the execution of the target transaction is used to fill the execution result information field in the tracking data structure.
4. The method according to claim 1, wherein: Different fields in the tracking data structure are combined into a character string in a preset order, wherein each field includes a preset number of characters.
5. The method according to claim 4, wherein: The characters in each field in the tracking data structure are in hexadecimal.
6. The method according to claim 5, wherein: After submitting all the state tracking result data stored in the state channel to the blockchain where the state channel is located, the method further includes: Sorting all the state tracking result data stored in the state channel according to generation time to form a state tracking sequence; Using a preset mapping function to convert the state tracking sequence into a retrieval information sequence, wherein the information in the retrieval information sequence is in binary, decimal or natural language; and Based on the retrieval information sequence, a retrieval list is constructed.
7. The method according to claim 1, wherein: Submitting all the state tracking result data stored in the state channel to the blockchain where the state channel is located includes: Taking each smart contract in the participant list as a second smart contract, searching for the state tracking result data with the latest generation time from the state tracking result data of the second smart contract to obtain the final state tracking result data of the second smart contract; Based on the final status tracking result data, obtain the final status result of the second smart contract; Obtaining account status data of the second smart contract in the status tree of the blockchain; Determining the validity of the final status result based on a comparison between the final status result and the account status data; and When the final status results of all smart contracts in the participant list are valid, all the status tracking result data stored in the status channel are submitted to the blockchain.
8. The method according to claim 7, wherein: The account status data includes a first hash value of the code deployed by the second smart contract in the blockchain; the final status result includes a second hash value of the execution information obtained by the second smart contract executing the last transaction in the status channel; The determining the validity of the final status result based on the comparison between the final status result and the account status data includes: Performing an XOR operation on the first Hash value and the second Hash value; When the result of the XOR operation is true, determining that the final state result is valid; and When the result of the XOR operation is false, it is determined that the final state result is invalid.
9. A device for tracking smart contracts in a state channel, comprising: An initialization module, configured to, in response to the opening of a state channel, initialize the state channel based on a pre-constructed tracking data structure and a participant list, wherein the tracking data structure includes fields for identification information and execution information of a smart contract, and the participant list is an information set of smart contracts participating in the interaction of the state channel; A generating module, configured to fill corresponding fields in the tracking data structure with identification information of each first smart contract involved in the target transaction and execution information obtained by the first smart contract participating in the target transaction, so as to generate a state tracking result data whenever a target transaction is confirmed to be valid in the state channel; wherein the first smart contract is a smart contract in the participant list; a storage module, configured to store the state tracking result data in the state channel in response to the generation of each state tracking result data; and A submission module is used to submit all the state tracking result data stored in the state channel to the blockchain where the state channel is located in response to the closing of the state channel.
10. An electronic device comprising: one or more processors; a storage device for storing one or more computer programs, The one or more processors execute the one or more computer programs to implement the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having a computer program stored thereon, wherein: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.